2 Replies Latest reply on Mar 13, 2009 9:01 AM by Lucas Silva

    load-on-startup Servlet doesn't lookup EJB

    Lucas Silva Newbie

      Hi all, I need help... I am creating a multi-war project inside an EAR. So inside every WAR I have a Servlet
      load-on-startup and I lookup an EJB that is inside the same EAR too. The problem is that JBoss calls my Servlet
      before the EJB start and I got an error, of cource, then it shows on screen the EJB STARTED message and my Servlet
      had already called.

        • 1. Re: load-on-startup Servlet doesn't lookup EJB
          jaikiran pai Master

          Which version of JBossAS? Please post the console logs which show this behaviour.

          • 2. Re: load-on-startup Servlet doesn't lookup EJB
            Lucas Silva Newbie

            Hi jaikiran, thanks for helping...

            Which version of JBossAS? Please post the console logs which show this behaviour.


            Some detais
            My Stateless EJB is MenuServiceBean that is named MenuService which implements MenuService interface
            The package is ehum.ear within ehum-ejb-1.0-SNAPSHOT.jar, ehum-api-1.0-SNAPSHOT.jar and two war.
            Every pagkage is exploded and inside other directory that I defined in server/default/conf/bootstrap/profile-repository.xml

            <property name="applicationURIs">
             <array elementClass="java.net.URI">
             <value>${jboss.server.home.url}deploy</value>
             <value>file:/opt/deploy</value>
             </array>
            </property>
            



            tree -d -L 1
            /opt/deploy/ehum.ear
            |-- META-INF
            |-- ehdois-web-1.0-SNAPSHOT.war
            |-- ehtreis-web-1.0-SNAPSHOT.war
            |-- ehum-api-1.0-SNAPSHOT.jar
            |-- ehum-common-java-1.0-SNAPSHOT.jar
            |-- ehum-ejb-1.0-SNAPSHOT.jar
            |-- ehum-pu-1.0-SNAPSHOT.jar
            `-- tapestry5-annotations-5.0.18.jar
            


            -- the very begining --
            JBoss Bootstrap Environment
            JBOSS_HOME: /opt/jboss-5.0.0.GA
            JAVA: /usr/lib/jvm/java-6-sun/bin/java
            

            -- after a while --
            08:37:38,366 INFO [ServerImpl] Release ID: JBoss [Morpheus] 5.0.0.GA (build: SVNTag=JBoss_5_0_0_GA date=200812042120)
            08:40:08,957 INFO [StandardService] Starting service jboss.web
            08:40:09,009 INFO [StandardEngine] Starting Servlet Engine: JBoss Web/2.1.1.GA
            08:40:09,385 INFO [Catalina] Server startup in 731 ms
            08:40:34,743 INFO [JBossASKernel] installing bean: jboss.j2ee:ear=ehum.ear,jar=ehum-ejb-1.0-SNAPSHOT.jar,name=MenuService,service=EJB3
            08:40:34,747 INFO [JBossASKernel] with dependencies:
            08:40:34,748 INFO [JBossASKernel] and demands:
            08:40:34,749 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
            08:40:34,749 INFO [JBossASKernel] persistence.unit:unitName=ehum.ear/ehum-pu-1.0-SNAPSHOT.jar#menuPU
            08:40:34,749 INFO [JBossASKernel] and supplies:
            08:40:34,749 INFO [JBossASKernel] jndi:ehum/MenuService/remote
            08:40:34,749 INFO [JBossASKernel] jndi:ehum/MenuService/local
            08:40:34,749 INFO [JBossASKernel] jndi:ehum/MenuService/local-br.com.company.e.api.MenuService
            08:40:34,749 INFO [JBossASKernel] Class:br.com.company.e.api.MenuService
            -- here it looks like my EJB MenuService is deployed --
            08:40:34,750 INFO [JBossASKernel] Added bean(jboss.j2ee:ear=ehum.ear,jar=ehum-ejb-1.0-SNAPSHOT.jar,name=MenuService,service=EJB3) to KernelDeployment of: ehum-ejb-1.0-SNAPSHOT.jar
            

            -- after a while the init method of my servlet called by startup-on-load defined in web.xml --
            08:40:53,707 ERROR [STDERR] javax.naming.NameNotFoundException: ehum not bound
            08:40:53,708 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
            -- after a while the ejb is ready, then I can lookup in my servlet and it work --
            08:41:08,739 INFO [EJBContainer] STARTED EJB: br.com.company.e.ejb.MenuServiceBean ejbName: MenuService
            08:41:09,332 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
            
             ehum/MenuService/local - EJB3.x Default Local Business Interface
             ehum/MenuService/local-br.com.company.e.api.MenuService - EJB3.x Local Business Interface
            

            -- after a while --
            08:41:12,087 INFO [ServerImpl] JBoss (Microcontainer) [5.0.0.GA (build: SVNTag=JBoss_5_0_0_GA date=200812042120)] Started in 3m:33s:637ms
            

            -- and the server is ready, at this moment I called my servlet that lookup my EJB --