3 Replies Latest reply on May 20, 2009 3:08 AM by Arthur Zhang

    ServletContextListener invoked before ejb JNDI binding

    Arthur Zhang Newbie

      It seems that ear file are deployed in below sequence:
      ...
      1. EjbDeployer: install ejb but doesn't bind it to JNDI tree.
      2. TomcatDeployment -> Initial servlet context and call listener: deploy war file and invoke servlet config listener
      3. EjbModule -> BaseLocalProxyFactory: Bould EJB LocalHome to jndi tree.
      ...

      The problem here is if we want to invoke ejb method in ServletContextListener.contextInitialized() , it will fail due to the fact that jndi name is not bound.

      Any suggestion/work around to solve this issue would be highly appreciated.

      Best regards,
      Arthur

        • 1. Re: ServletContextListener invoked before ejb JNDI binding
          Arthur Zhang Newbie

          We wrote a simple application to verify above steps. This javaee project has one ejb module and one web module. Ejb module use ejb2.0 and has one local EJB - HelloEjb.

          In web module, I have one ServletContextListener which try to get local ejb HelloLocal through jndi lookup; it will fail with error in console.
          Besides of that, we put a simple jsp file in this module which does the same thing as listener. After web app startup, access url http://localhost:8080/MyTestWeb/index.jsp will trigger it. In this case, Jndi lookup pass without error, invocation on ejb could be found in console, too.

          Below is content of jboss console:


          05:58:41,867 INFO [ServerImpl] Home Dir: C:\jboss-5.0.1.GA
          05:58:41,867 INFO [ServerImpl] Home URL: file:/C:/jboss-5.0.1.GA/
          05:58:41,867 INFO [ServerImpl] Library URL: file:/C:/jboss-5.0.1.GA/lib/
          05:58:41,867 INFO [ServerImpl] Patch URL: null
          05:58:41,867 INFO [ServerImpl] Common Base URL: file:/C:/jboss-5.0.1.GA/common/
          05:58:41,882 INFO [ServerImpl] Common Library URL: file:/C:/jboss-5.0.1.GA/common/lib/
          05:58:41,882 INFO [ServerImpl] Server Name: standard
          05:58:41,882 INFO [ServerImpl] Server Base Dir: C:\jboss-5.0.1.GA\server
          05:58:41,882 INFO [ServerImpl] Server Base URL: file:/C:/jboss-5.0.1.GA/server/
          05:58:41,882 INFO [ServerImpl] Server Config URL: file:/C:/jboss-5.0.1.GA/server/standard/conf/
          05:58:41,882 INFO [ServerImpl] Server Home Dir: C:\jboss-5.0.1.GA\server\standard
          05:58:41,882 INFO [ServerImpl] Server Home URL: file:/C:/jboss-5.0.1.GA/server/standard/
          05:58:41,882 INFO [ServerImpl] Server Data Dir: C:\jboss-5.0.1.GA\server\standard\data
          05:58:41,882 INFO [ServerImpl] Server Library URL: file:/C:/jboss-5.0.1.GA/server/standard/lib/
          05:58:41,882 INFO [ServerImpl] Server Log Dir: C:\jboss-5.0.1.GA\server\standard\log
          05:58:41,882 INFO [ServerImpl] Server Native Dir: C:\jboss-5.0.1.GA\server\standard\tmp\native
          05:58:41,882 INFO [ServerImpl] Server Temp Dir: C:\jboss-5.0.1.GA\server\standard\tmp
          05:58:41,882 INFO [ServerImpl] Server Temp Deploy Dir: C:\jboss-5.0.1.GA\server\standard\tmp\deploy
          05:58:43,538 INFO [ServerImpl] Starting Microcontainer, bootstrapURL=file:/C:/jboss-5.0.1.GA/server/standard/conf/bootstrap.xml
          05:58:46,007 INFO [VFSCacheFactory] Initializing VFSCache [org.jboss.virtual.plugins.cache.CombinedVFSCache]
          05:58:46,023 INFO [VFSCacheFactory] Using VFSCache [CombinedVFSCache[real-cache: null]]
          05:58:46,835 INFO [CopyMechanism] VFS temp dir: C:\jboss-5.0.1.GA\server\standard\tmp
          05:58:46,867 INFO [ZipEntryContext] VFS force nested jars copy-mode is enabled.
          05:58:50,492 INFO [ServerInfo] Java version: 1.6.0_07,Sun Microsystems Inc.
          05:58:50,492 INFO [ServerInfo] Java Runtime: Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
          05:58:50,492 INFO [ServerInfo] Java VM: Java HotSpot(TM) Client VM 10.0-b23,Sun Microsystems Inc.
          05:58:50,492 INFO [ServerInfo] OS-System: Windows XP 5.1,x86
          05:58:50,679 INFO [JMXKernel] Legacy JMX core initialized
          05:58:55,632 INFO [ProfileServiceImpl] Loading profile: standard from: org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository@1091857(root=C:\jboss-5.0.1.GA\server, key=org.jboss.profileservice.spi.ProfileKey@664cb3f[domain=default,server=default,name=standard])
          05:58:55,648 INFO [ProfileImpl] Using repository:org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository@1091857(root=C:\jboss-5.0.1.GA\server, key=org.jboss.profileservice.spi.ProfileKey@664cb3f[domain=default,server=default,name=standard])
          05:58:55,648 INFO [ProfileServiceImpl] Loaded profile: ProfileImpl@98ebea{key=org.jboss.profileservice.spi.ProfileKey@664cb3f[domain=default,server=default,name=standard]}
          05:59:00,242 INFO [WebService] Using RMI server codebase: http://localhost:8083/
          05:59:26,914 INFO [NativeServerConfig] JBoss Web Services - Stack Native Core
          05:59:26,914 INFO [NativeServerConfig] 3.0.5.GA
          05:59:45,898 INFO [Ejb3DependenciesDeployer] Encountered deployment AbstractVFSDeploymentContext@17541938{vfsfile:/C:/jboss-5.0.1.GA/server/standard/deploy/MyTestApplication.ear/MyTestEJB.jar/}
          05:59:45,898 INFO [Ejb3DependenciesDeployer] Encountered deployment AbstractVFSDeploymentContext@17541938{vfsfile:/C:/jboss-5.0.1.GA/server/standard/deploy/MyTestApplication.ear/MyTestEJB.jar/}
          05:59:45,898 INFO [Ejb3DependenciesDeployer] Encountered deployment AbstractVFSDeploymentContext@17541938{vfsfile:/C:/jboss-5.0.1.GA/server/standard/deploy/MyTestApplication.ear/MyTestEJB.jar/}
          05:59:51,570 INFO [CorbaNamingService] CORBA Naming Started
          05:59:55,773 INFO [MailService] Mail Service bound to java:/Mail
          06:00:00,164 WARN [JBossASSecurityMetadataStore] WARNING! POTENTIAL SECURITY RISK. It has been detected that the MessageSucker component which sucks messages from one node to another has not had its password changed from the installation default. Please see the JBoss Messaging user guide for instructions on how to do this.
          06:00:00,242 WARN [AnnotationCreator] No ClassLoader provided, using TCCL: org.jboss.managed.api.annotation.ManagementComponent
          06:00:00,930 INFO [TransactionManagerService] JBossTS Transaction Service (JTA version) - JBoss Inc.
          06:00:00,930 INFO [TransactionManagerService] Setting up property manager MBean and JMX layer
          06:00:02,633 INFO [TransactionManagerService] Initializing recovery manager
          06:00:04,351 INFO [TransactionManagerService] Recovery manager configured
          06:00:04,351 INFO [TransactionManagerService] Binding TransactionManager JNDI Reference
          06:00:04,492 INFO [TransactionManagerService] Starting transaction recovery manager
          06:00:07,086 INFO [Http11Protocol] Initializing Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8080
          06:00:07,101 INFO [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
          06:00:07,101 INFO [StandardService] Starting service jboss.web
          06:00:07,101 INFO [StandardEngine] Starting Servlet Engine: JBoss Web/2.1.2.GA
          06:00:07,351 INFO [Catalina] Server startup in 474 ms
          06:00:07,398 INFO [TomcatDeployment] deploy, ctxPath=/juddi
          06:00:10,320 INFO [RegistryServlet] Loading jUDDI configuration.
          06:00:10,352 INFO [RegistryServlet] Resources loaded from: /WEB-INF/juddi.properties
          06:00:10,352 INFO [RegistryServlet] Initializing jUDDI components.
          06:00:11,164 INFO [TomcatDeployment] deploy, ctxPath=/jbossws
          06:00:11,711 INFO [RARDeployment] Required license terms exist, view vfszip:/C:/jboss-5.0.1.GA/server/standard/deploy/jboss-local-jdbc.rar/META-INF/ra.xml
          06:00:11,758 INFO [RARDeployment] Required license terms exist, view vfszip:/C:/jboss-5.0.1.GA/server/standard/deploy/jboss-xa-jdbc.rar/META-INF/ra.xml
          06:00:11,820 INFO [RARDeployment] Required license terms exist, view vfszip:/C:/jboss-5.0.1.GA/server/standard/deploy/jms-ra.rar/META-INF/ra.xml
          06:00:15,383 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
          06:00:17,820 INFO [ServerPeer] JBoss Messaging 1.4.1.GA server [0] started
          06:00:18,227 WARN [ConnectionFactoryJNDIMapper] supportsFailover attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support failover
          06:00:18,227 WARN [ConnectionFactoryJNDIMapper] supportsLoadBalancing attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support load balancing
          06:00:18,711 INFO [ConnectionFactory] Connector bisocket://localhost:4457 has leasing enabled, lease period 10000 milliseconds
          06:00:18,711 INFO [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@1636de started
          06:00:18,789 INFO [QueueService] Queue[/queue/ExpiryQueue] started, fullSize=200000, pageSize=2000, downCacheSize=2000
          06:00:19,367 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
          06:00:19,398 INFO [TomcatDeployment] deploy, ctxPath=/
          06:00:19,680 INFO [TomcatDeployment] deploy, ctxPath=/jmx-console
          06:00:19,836 INFO [EjbDeployer] installing bean: ejb/MyTestEJB.jar#Hello,uid10210059
          06:00:19,836 INFO [EjbDeployer] with dependencies:
          06:00:19,836 INFO [EjbDeployer] and supplies:
          06:00:19,836 INFO [EjbDeployer] jndi:ejb/Hello
          06:00:19,836 INFO [EjbDeployer] jndi:Hello
          06:00:20,086 INFO [TomcatDeployment] deploy, ctxPath=/MyTestWeb
          06:00:20,273 INFO [STDOUT] ===========================================EJB lookup failed in listener!!javax.naming.NameNotFoundException: ejb not bound
          06:00:20,695 INFO [EjbModule] Deploying Hello
          06:00:20,836 WARN [EjbModule] EJB configured to bypass security. Please verify if this is intended. Bean=Hello Deployment=vfsfile:/C:/jboss-5.0.1.GA/server/standard/deploy/MyTestApplication.ear/MyTestEJB.jar/
          06:00:21,508 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'Hello' to jndi 'ejb/Hello'
          06:00:21,586 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8080
          06:00:21,633 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
          06:00:21,648 INFO [ServerImpl] JBoss (Microcontainer) [5.0.1.GA (build: SVNTag=JBoss_5_0_1_GA date=200902231221)] Started in 1m:39s:766ms
          06:00:47,492 INFO [STDOUT] hello
          06:00:47,508 INFO [STDOUT] ===========================================EJB lookup succeeded after web app started -- Hello World


          • 3. Re: ServletContextListener invoked before ejb JNDI binding
            Arthur Zhang Newbie

            It works, thank you very much.

            Best wishes