2 Replies Latest reply on Nov 18, 2002 1:23 PM by mitchell ackerman

    configuring EJB access from Servlet

    mitchell ackerman Newbie

      not sure if this is the right forum, but got a problem figuring out how to access EJBs from a servlet. i have a web app deployed within an ear (i think), but the servlet gets NameNotFoundException. actually i never see the name bound in the console so perhaps my ear is not deployed correctly. it all worked within 2.4.4, but having problems getting it to work in 3. is there anything i have to do to get the ear to deploy other than provide an application.xml for the ear and ejb-jar.xml for the ejbs?

      thanks, Mitchell

        • 1. Re: configuring EJB access from Servlet
          Adrian Brock Master

          It worked on 2.4.4 but doesn't on 3

          You won't get many answers with vague information. :-(

          How are you referencing the ejb?
          ejb-link?
          direct lookup into global jndi?

          Have you used the JNDIView service on the JMX console
          to verify the ejb is bound correctly?
          Or used the Enumeration available on the initial
          context to see what is bound?

          Show your deployment descriptors if you have a deployment
          problem.

          Finally, if I remember correctly, 2.4 had a bug
          where it interrupted <ejb-link> in web.xml as the
          <jndi-name> when it should be the <ejb-name>

          Regards,
          Adrian

          • 2. Re: configuring EJB access from Servlet
            mitchell ackerman Newbie

            i looked in JNDIView, but did not see anything there. this being the case i suspect that the ejbs are not getting deployed correctly. see below for (part of) my configuration. thanks, Mitchell

            application.xml:

            <!DOCTYPE application PUBLIC
            "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
            "http://java.sun.com/dtd/application_1_3.dtd">


            <display-name>RMD Application Display Name</display-name>



            <web-uri>rmd.war</web-uri>
            <context-root>rmd</context-root>





            ejb-jar.xml:

            <?xml version="1.0"?>
            <!DOCTYPE ejb-jar
            PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
            "http://java.sun.com/dtd/ejb-jar_2_0.dtd"
            >

            <ejb-jar>

            <enterprise-beans>


            <ejb-name>CrewLeadBean</ejb-name>
            <table-name>tblCrewLead</table-name>
            <create-table>false</create-table>

            rmd.model.ejb.CrewLeadHome
            rmd.model.ejb.CrewLead
            <ejb-class>rmd.model.ejb.CrewLeadBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>java.lang.Integer</prim-key-class>
            False

            <cmp-field><field-name>crewLeadID</field-name></cmp-field>
            <cmp-field>
            <field-name>workmanID</field-name>
            <column-name>tblWorkmanID</column-name>
            </cmp-field>
            <cmp-field><field-name>firstName</field-name></cmp-field>
            <cmp-field><field-name>lastName</field-name></cmp-field>
            <cmp-field><field-name>middleName</field-name></cmp-field>
            <cmp-field><field-name>crewTypeID</field-name></cmp-field>
            <cmp-field><field-name>comment</field-name></cmp-field>
            <cmp-field><field-name>phoneID</field-name></cmp-field>
            <cmp-field><field-name>active</field-name></cmp-field>
            <cmp-field><field-name>createDate</field-name></cmp-field>

            <primkey-field>crewLeadID</primkey-field>




            <ejb-name>SupervisorBean</ejb-name>
            <table-name>tblSup</table-name>
            <create-table>false</create-table>

            rmd.model.ejb.SupervisorHome
            rmd.model.ejb.Supervisor
            <ejb-class>rmd.model.ejb.SupervisorBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>java.lang.Integer</prim-key-class>
            False

            <cmp-field><field-name>supID</field-name></cmp-field>
            <cmp-field><field-name>supFirstName</field-name></cmp-field>
            <cmp-field><field-name>supLastName</field-name></cmp-field>
            <cmp-field><field-name>supSort</field-name></cmp-field>
            <cmp-field><field-name>phoneID</field-name></cmp-field>
            <cmp-field><field-name>active</field-name></cmp-field>

            <primkey-field>supID</primkey-field>



            <ejb-name>ViewAssignedJobsBean</ejb-name>
            <table-name>ViewAssignedJobs</table-name>
            <create-table>false</create-table>

            rmd.model.ejb.ViewAssignedJobsHome
            rmd.model.ejb.ViewAssignedJobs
            <ejb-class>rmd.model.ejb.ViewAssignedJobsBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>java.lang.Integer</prim-key-class>
            False

            <cmp-field><field-name>jobnum</field-name></cmp-field>
            <cmp-field><field-name>address</field-name></cmp-field>
            <cmp-field><field-name>subDiv</field-name></cmp-field>
            <cmp-field>
            <field-name>jobWorkID</field-name>
            <column-name>tblJobWorkID</column-name>
            </cmp-field>
            <cmp-field><field-name>phoneID</field-name></cmp-field>
            <cmp-field><field-name>percentageComplete</field-name></cmp-field>
            <cmp-field>
            <field-name>priority</field-name>
            <column-name>priorityName</column-name>
            </cmp-field>
            <cmp-field><field-name>crewTypeDescription</field-name></cmp-field>
            <cmp-field><field-name>strDay</field-name></cmp-field>
            <cmp-field><field-name>budget</field-name></cmp-field>

            <primkey-field>jobWorkID</primkey-field>



            <ejb-name>WorkmanBean</ejb-name>
            <table-name>tblWorkman</table-name>
            <create-table>false</create-table>

            rmd.model.ejb.WorkmanHome
            rmd.model.ejb.Workman
            <ejb-class>rmd.model.ejb.WorkmanBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>java.lang.Integer</prim-key-class>
            False

            <cmp-field><field-name>tblWorkmanID</field-name></cmp-field>
            <cmp-field><field-name>clockNumber</field-name></cmp-field>
            <cmp-field><field-name>firstName</field-name></cmp-field>
            <cmp-field><field-name>lastName</field-name></cmp-field>
            <cmp-field><field-name>middleName</field-name></cmp-field>
            <cmp-field><field-name>crewTypeID</field-name></cmp-field>
            <cmp-field><field-name>active</field-name></cmp-field>
            <cmp-field><field-name>crewChief</field-name></cmp-field>

            <primkey-field>tblWorkmanID</primkey-field>



            <ejb-name>JobWorkerBean</ejb-name>
            <table-name>tblJobWorker</table-name>
            <create-table>false</create-table>

            rmd.model.ejb.JobWorkerHome
            rmd.model.ejb.JobWorker
            <ejb-class>rmd.model.ejb.JobWorkerBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>java.lang.Integer</prim-key-class>
            False

            <cmp-field><field-name>tblJobWorkerID</field-name></cmp-field>
            <cmp-field><field-name>tblJobWorkID</field-name></cmp-field>
            <cmp-field><field-name>tblWorkmanID</field-name></cmp-field>
            <cmp-field><field-name>splitPercentage</field-name></cmp-field>

            <primkey-field>tblJobWorkerID</primkey-field>



            <ejb-name>JobWorkBean</ejb-name>
            <table-name>tblJobWork</table-name>
            <create-table>false</create-table>

            rmd.model.ejb.JobWorkHome
            rmd.model.ejb.JobWork
            <ejb-class>rmd.model.ejb.JobWorkBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>java.lang.Integer</prim-key-class>
            False

            <cmp-field><field-name>tblJobWorkID</field-name></cmp-field>
            <cmp-field><field-name>percentageComplete</field-name></cmp-field>

            <primkey-field>tblJobWorkID</primkey-field>



            <ejb-name>JobTimeEntryBean</ejb-name>
            <table-name>tblJobTimeEntry</table-name>
            <create-table>false</create-table>

            rmd.model.ejb.JobTimeEntryHome
            rmd.model.ejb.JobTimeEntry
            <ejb-class>rmd.model.ejb.JobTimeEntryBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>java.lang.Integer</prim-key-class>
            False

            <cmp-field>
            <field-name>jobTimeEntryID</field-name>
            <column-name>tblJobTimeEntryID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>jobWorkerID</field-name>
            <column-name>tbljobWorkerID</column-name>
            </cmp-field>
            <cmp-field><field-name>phoneID</field-name></cmp-field>
            <cmp-field><field-name>jobDate</field-name></cmp-field>
            <cmp-field><field-name>hours</field-name></cmp-field>

            <primkey-field>jobTimeEntryID</primkey-field>


            </enterprise-beans>

            </ejb-jar>