4 Replies Latest reply on Nov 2, 2007 2:29 AM by benix

    Missing EJB 3.0 Session bean name in Global JNDI Namespace!!

    benix

      I have created an ear ?SampleEnterprise.ear? which consists of an ejb jar ?SampleEnterprise-ejb.jar? and a war file ?SampleEnterprise-war.war?. The ear file was deployed on a JBoss 4.0.5 server.

      There is a EJB 3.0 stateless session bean ?EmployeeServiceBean? present in the ejb jar file which I need to access from a servlet ?EmployeeServlet? in the war file

      Here?s the code from the servlet used to lookup the session bean

      try {
       Properties properties = new Properties();
       properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
       properties.put("java.naming.factory.url.pkgs","=org.jboss.naming:org.jnp.interfaces");
       properties.put("java.naming.provider.url","localhost:1099");
       Context context = new InitialContext(properties);
       EmployeeServiceRemote empService = (EmployeeServiceRemote)context.lookup("SampleEnterprise/EmployeeServiceBean/remote");
      } catch (Exception e) {}
      


      Here's the session bean
      package sessionBeans;
      import entityBeans.Employee;
      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      
      @Stateless()
      public class EmployeeServiceBean implements EmployeeServiceLocal, EmployeeServiceRemote {
      
       @PersistenceContext()
       EntityManager em;
      
       public EmployeeServiceBean() {}
      
       public Employee createEmployee(int id, String name, int salary) {
       Employee emp = new Employee(id);
       emp.setName(name);
       emp.setSalary(salary);
       em.persist(emp);
       return emp;
       }
      


      here's the JndiView
      Global JNDI Namespace
      
       +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
       +- jmx (class: org.jnp.interfaces.NamingContext)
       | +- invoker (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor (proxy: $Proxy42 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
       | +- rmi (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
       +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- UserTransactionSessionFactory (proxy: $Proxy12 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
       +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
       +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- queue (class: org.jnp.interfaces.NamingContext)
       | +- A (class: org.jboss.mq.SpyQueue)
       | +- testQueue (class: org.jboss.mq.SpyQueue)
       | +- ex (class: org.jboss.mq.SpyQueue)
       | +- DLQ (class: org.jboss.mq.SpyQueue)
       | +- D (class: org.jboss.mq.SpyQueue)
       | +- C (class: org.jboss.mq.SpyQueue)
       | +- B (class: org.jboss.mq.SpyQueue)
       +- topic (class: org.jnp.interfaces.NamingContext)
       | +- testDurableTopic (class: org.jboss.mq.SpyTopic)
       | +- testTopic (class: org.jboss.mq.SpyTopic)
       | +- securedTopic (class: org.jboss.mq.SpyTopic)
       +- console (class: org.jnp.interfaces.NamingContext)
       | +- PluginManager (proxy: $Proxy43 implements interface org.jboss.console.manager.PluginManagerMBean)
       +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
       +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
       +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
       +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
       +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
      


      however the EmployeeServiceBean does not appear in the above listing and I get the following exception when the lookup code is executed
      javax.naming.NameNotFoundException: SampleEnterprise not bound


      do i need to add any references to the session bean in the following files?

      jboss-app.xml (is a <loader-repository> required?)
      jboss.xml
      jboss-web.xml
      ejb-jar.xml
      web.xml

      or have i missed out something else?

      there aren't any exceptions during deployment

        • 1. Re: Missing EJB 3.0 Session bean name in Global JNDI Namespa
          jaikiran

          Are you sure the bean is being deployed?

          • 2. Re: Missing EJB 3.0 Session bean name in Global JNDI Namespa
            benix

            Here's the server log on startup. as found at the end of the log, the SampleEnterprise.ear does get deployed without any errors. also i could access a few pages of the application until the moment the lookup code is executed..

            ===============================================================================
            
             JBoss Bootstrap Environment
            
             JBOSS_HOME: D:\jboss-4.0.5.GA\bin\\..
            
             JAVA: C:\Program Files\Java\jdk1.6.0\bin\java
            
             JAVA_OPTS: -Dprogram.name=run.bat -server -Xms128m -Xmx512m -Dsun.rmi.dgc.cli
            ent.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000
            
             CLASSPATH: C:\Program Files\Java\jdk1.6.0\lib\tools.jar;D:\jboss-4.0.5.GA\bin\
            \run.jar
            
            ===============================================================================
            
            17:46:19,343 INFO [Server] Starting JBoss (MX MicroKernel)...
            17:46:19,359 INFO [Server] Release ID: JBoss [Zion] 4.0.5.GA (build: CVSTag=Bra
            nch_4_0 date=200610162339)
            17:46:19,359 INFO [Server] Home Dir: D:\jboss-4.0.5.GA
            17:46:19,359 INFO [Server] Home URL: file:/D:/jboss-4.0.5.GA/
            17:46:19,359 INFO [Server] Patch URL: null
            17:46:19,359 INFO [Server] Server Name: default
            17:46:19,359 INFO [Server] Server Home Dir: D:\jboss-4.0.5.GA\server\default
            17:46:19,359 INFO [Server] Server Home URL: file:/D:/jboss-4.0.5.GA/server/defa
            ult/
            17:46:19,359 INFO [Server] Server Log Dir: D:\jboss-4.0.5.GA\server\default\log
            
            17:46:19,359 INFO [Server] Server Temp Dir: D:\jboss-4.0.5.GA\server\default\tm
            p
            17:46:19,359 INFO [Server] Root Deployment Filename: jboss-service.xml
            17:46:20,156 INFO [ServerInfo] Java version: 1.6.0,Sun Microsystems Inc.
            17:46:20,156 INFO [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.6.0-b105,S
            un Microsystems Inc.
            17:46:20,156 INFO [ServerInfo] OS-System: Windows XP 5.1,x86
            17:46:20,921 INFO [Server] Core system initialized
            17:46:23,593 INFO [WebService] Using RMI server codebase: http://EDC-BENI:8083/
            
            17:46:23,625 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resour
            ce:log4j.xml
            17:46:33,296 INFO [ServiceEndpointManager] WebServices: jbossws-1.0.3.SP1 (date
            =200609291417)
            17:46:34,812 INFO [Embedded] Catalina naming disabled
            17:46:34,875 INFO [ClusterRuleSetFactory] Unable to find a cluster rule set in
            the classpath. Will load the default rule set.
            17:46:34,875 INFO [ClusterRuleSetFactory] Unable to find a cluster rule set in
            the classpath. Will load the default rule set.
            17:46:35,218 INFO [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0
            .0.0-8080
            17:46:35,234 INFO [Catalina] Initialization processed in 359 ms
            17:46:35,234 INFO [StandardService] Starting service jboss.web
            17:46:35,234 INFO [StandardEngine] Starting Servlet Engine: Apache Tomcat/5.5.2
            0
            17:46:35,265 INFO [StandardHost] XML validation disabled
            17:46:35,328 INFO [Catalina] Server startup in 94 ms
            17:46:35,656 INFO [TomcatDeployer] deploy, ctxPath=/invoker, warUrl=.../deploy/
            http-invoker.sar/invoker.war/
            17:46:36,578 INFO [WebappLoader] Dual registration of jndi stream handler: fact
            ory already defined
            17:46:37,296 INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=.../deploy/jbosswe
            b-tomcat55.sar/ROOT.war/
            17:46:37,984 INFO [TomcatDeployer] deploy, ctxPath=/jbossws, warUrl=.../tmp/dep
            loy/tmp26714jbossws-context-exp.war/
            17:46:38,687 INFO [TomcatDeployer] deploy, ctxPath=/jbossmq-httpil, warUrl=.../
            deploy/jms/jbossmq-httpil.sar/jbossmq-httpil.war/
            17:46:40,125 INFO [TomcatDeployer] deploy, ctxPath=/web-console, warUrl=.../dep
            loy/management/console-mgr.sar/web-console.war/
            17:46:41,390 INFO [MailService] Mail Service bound to java:/Mail
            17:46:41,843 INFO [RARDeployment] Required license terms exist, view META-INF/r
            a.xml in .../deploy/jboss-ha-local-jdbc.rar
            17:46:42,062 INFO [RARDeployment] Required license terms exist, view META-INF/r
            a.xml in .../deploy/jboss-ha-xa-jdbc.rar
            17:46:42,281 INFO [RARDeployment] Required license terms exist, view META-INF/r
            a.xml in .../deploy/jboss-local-jdbc.rar
            17:46:42,515 INFO [RARDeployment] Required license terms exist, view META-INF/r
            a.xml in .../deploy/jboss-xa-jdbc.rar
            17:46:42,625 INFO [RARDeployment] Required license terms exist, view META-INF/r
            a.xml in .../deploy/jms/jms-ra.rar
            17:46:42,828 INFO [RARDeployment] Required license terms exist, view META-INF/r
            a.xml in .../deploy/mail-ra.rar
            17:46:44,015 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca
            :service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
            17:46:44,453 INFO [A] Bound to JNDI name: queue/A
            17:46:44,468 INFO [B] Bound to JNDI name: queue/B
            17:46:44,468 INFO [C] Bound to JNDI name: queue/C
            17:46:44,468 INFO [D] Bound to JNDI name: queue/D
            17:46:44,468 INFO [ex] Bound to JNDI name: queue/ex
            17:46:44,500 INFO [testTopic] Bound to JNDI name: topic/testTopic
            17:46:44,500 INFO [securedTopic] Bound to JNDI name: topic/securedTopic
            17:46:44,500 INFO [testDurableTopic] Bound to JNDI name: topic/testDurableTopic
            
            17:46:44,515 INFO [testQueue] Bound to JNDI name: queue/testQueue
            17:46:44,593 INFO [UILServerILService] JBossMQ UIL service available at : /0.0.
            0.0:8093
            17:46:44,671 INFO [DLQ] Bound to JNDI name: queue/DLQ
            17:46:44,875 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca
            :service=DataSourceBinding,name=beniDataSource' to JNDI name 'java:beniDataSourc
            e'
            17:46:45,171 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jb
            oss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
            17:46:45,328 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../dep
            loy/jmx-console.war/
            17:46:45,859 INFO [EARDeployer] Init J2EE application: file:/D:/jboss-4.0.5.GA/
            server/default/deploy/SampleEnterprise.ear
            17:46:49,203 INFO [EJBDeployer] Deployed: file:/D:/jboss-4.0.5.GA/server/defaul
            t/tmp/deploy/tmp26747SampleEnterprise.ear-contents/SampleEnterprise-ejb.jar
            17:46:49,234 INFO [TomcatDeployer] deploy, ctxPath=/SampleEnterprise-war, warUr
            l=.../tmp/deploy/tmp26747SampleEnterprise.ear-contents/SampleEnterprise-war-exp.
            war/
            17:46:50,046 INFO [EARDeployer] Started J2EE application: file:/D:/jboss-4.0.5.
            GA/server/default/deploy/SampleEnterprise.ear
            17:46:50,187 INFO [Http11BaseProtocol] Starting Coyote HTTP/1.1 on http-0.0.0.0
            -8080
            17:46:50,812 INFO [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
            17:46:50,828 INFO [JkMain] Jk running ID=0 time=0/47 config=null
            17:46:50,859 INFO [Server] JBoss (MX MicroKernel) [4.0.5.GA (build: CVSTag=Bran
            ch_4_0 date=200610162339)] Started in 31s:500ms
            


            • 3. Re: Missing EJB 3.0 Session bean name in Global JNDI Namespa
              jaikiran

               

              17:46:49,203 INFO [EJBDeployer] Deployed: file:/D:/jboss-4.0.5.GA/server/defaul
              t/tmp/deploy/tmp26747SampleEnterprise.ear-contents/SampleEnterprise-ejb.jar


              Looks like your EJB is not being considered as a EJB3 module. I would have expected EJB3Deployer to be used, if your ejb jar was considered to be a EJB3 module.



              • 4. Re: Missing EJB 3.0 Session bean name in Global JNDI Namespa
                benix

                yes, you were right about the EJBDeployer!

                After googling for a while, i found that a patch jboss-EJB-3.0_RC9_Patch_1 needs to be installed for the JBoss 4.0.5 GA to enable ejb3 deployment. i ran the ant command(its found in the jboss-EJB-3.0_RC9_Patch_1.zip), the EJB3Deployer and other associated files got installed. now the ejbs are deployed by the EJB3Deployer and everythings working very well.

                jboss-EJB-3.0_RC9_Patch_1 is only compatible with JBoss 4.0.5 GA. different versions of the patch are available for other JBoss versions.

                thanks!!