6 Replies Latest reply on Nov 13, 2013 7:29 AM by sachin.dhingra

    EJB JNDI lookup not working

    sachin.dhingra

      My ear file contains conf directory which has the properties file, jar (contans ejb's) and the war file (contains servlets and applicationlistener). I have deployed the ear file and now i am running into two problems here:

      1. conf folder is not getting deployed i.e., When my code looks for the properties file under <JBOSS_HOME>\bin\content\<earNameFolder>\conf\<propertiesFile> and it is not present and fails as below error:

       

      15:34:54,058 ERROR [stderr] (ServerService Thread Pool -- 82) log4j:ERROR Could not read configuration file [D:\Official\JBoss\jboss-eap-6.1.0\bin\content\xxxHubServer.ear/conf/xxxHubServerLog.properties].

       

      I am not sure why this folder including properties file is not getting uploaded to the server.

       

      2. I have some EJB's in my jar file which i am looking using JNDI lookup in some POJO class inside the jar file only, for that I am facing below error:

       

      15:34:54,168 ERROR [JDA_HUB_SERVER] (ServerService Thread Pool -- 82) checkForUrlContext: java:app/xxxHubEJB/xxxHubLogQueueBean

      15:34:54,171 ERROR [JDA_HUB_SERVER] (ServerService Thread Pool -- 82) The following validation errors were found: checkForUrlContext: java:app/xxxHubEJB/TimerServiceBean

      15:34:54,172 ERROR [stderr] (ServerService Thread Pool -- 82) NMSV0307E: A java: URL name was used, but Naming was not configured to handle java: URL names. The likely cause is a user in error attempting to specify a java: URL name in a non-J2EE client or server environment. Throwing ConfigurationException.

       

      The server.log shows below binding which is same what i am using in my code:

       

      15:34:53,089 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-7) JNDI bindings for session bean named TimerServiceBean in deployment unit subdeployment "xxxHubEJB.jar" of deployment "xxxHubServer.ear" are as follows:

          java:global/xxxHubServer/xxxHubEJB/TimerServiceBean!com.xxx.xxxhubserver.commons.workflow.ITimerServiceLocal

          java:app/xxxHubEJB/TimerServiceBean!com.xxx.xxxhubserver.commons.workflow.ITimerServiceLocal

          java:module/TimerServiceBean!com.xxx.xxxhubserver.commons.workflow.ITimerServiceLocal

          java:global/xxxHubServer/xxxHubEJB/TimerServiceBean

          java:app/xxxHubEJB/TimerServiceBean

          java:module/TimerServiceBean

       

      Code:

      InitialContext context = new InitialContext();

      ITimerServiceLocal timerSerivceBean = (ITimerServiceLocal) context.lookup("java:app/xxxHubEJB/" + TimerServiceBean.class.getSimpleName());

       

      Thanks in advance.

        • 1. Re: EJB JNDI lookup not working
          sfcoy
          1. The contents of EAR files are not available on the class path. Have a look at How to put an external file in the class path for an alternative approach.
          2. Where is the jar that is performing the JNDI lookup deployed?

           

          Please not that you will get more timely answers to questions if you use the JBoss AS 7 discussion list. This one used to be used for the developers of AS7, but not any more. Consequently people don't look in here very often.

          1 of 1 people found this helpful
          • 2. Re: EJB JNDI lookup not working
            rhusar

            Discussion successfully moved from JBoss AS 7 Development to JBoss AS 7

            • 3. Re: EJB JNDI lookup not working
              sachin.dhingra

              Stephen,

              The jar is directly inside the ear file. My ear file structure is as below:

               

              Ear file:
                |_ conf folder contains logger property file
                |_ lib folder contains external jar files
                |_ META-INF folder contains application.xml file and manifest.MF file with no classpath entry
                |_ resources folder contains messages file
                |_ xsl folder
                |_jar file (This is the one i was referring)
                |_ war file



              • 4. Re: EJB JNDI lookup not working
                sachin.dhingra

                Hi,

                 

                I just found out the problem why the JNDI lookup was not working by looking at the error more closely. The problem was the jar file which it was using for the InitialContext class was not invalid (websphere specific not java standardized javax.ejb.jar). Removal of that jar file solved the problem but now i am running into some other issue and getting below error:

                 

                17:58:16,941 DEBUG [org.hornetq.jms.server] (Periodic Recovery) Trying to connect recovery on XARecoveryConfig [transportConfiguration = [TransportConfiguration(name=99e333f2-4aca-11e3-91e7-9b8f9fad64f7, factory=org-hornetq-core-remoting-impl-invm-InVMConnectorFactory) ?server-id=0], discoveryConfiguration = null, username=null, password=null] of [XARecoveryConfig [transportConfiguration = [TransportConfiguration(name=99e333f2-4aca-11e3-91e7-9b8f9fad64f7, factory=org-hornetq-core-remoting-impl-invm-InVMConnectorFactory) ?server-id=0], discoveryConfiguration = null, username=null, password=null]]

                17:58:16,942 DEBUG [org.hornetq.core.client] (Periodic Recovery) Trying to connect with connector = org.hornetq.core.remoting.impl.invm.InVMConnectorFactory@11b93a10, parameters = {server-id=0} connector = null

                17:58:16,943 DEBUG [org.hornetq.core.client] (Periodic Recovery) Trying to connect towards ClientSessionFactoryImpl [serverLocator=ServerLocatorImpl [initialConnectors=[TransportConfiguration(name=99e333f2-4aca-11e3-91e7-9b8f9fad64f7, factory=org-hornetq-core-remoting-impl-invm-InVMConnectorFactory) ?server-id=0], discoveryGroupConfiguration=null], connectorConfig=TransportConfiguration(name=99e333f2-4aca-11e3-91e7-9b8f9fad64f7, factory=org-hornetq-core-remoting-impl-invm-InVMConnectorFactory) ?server-id=0, backupConfig=null]

                17:58:16,943 WARN  [org.hornetq.jms.server] (Periodic Recovery) HQ122015: Can not connect to XARecoveryConfig [transportConfiguration = [TransportConfiguration(name=99e333f2-4aca-11e3-91e7-9b8f9fad64f7, factory=org-hornetq-core-remoting-impl-invm-InVMConnectorFactory) ?server-id=0], discoveryConfiguration = null, username=null, password=null] on auto-generated resource recovery: HornetQException[errorType=NOT_CONNECTED message=HQ119007: Cannot connect to server(s). Tried with all available servers.]

                    at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:852) [hornetq-core-client-2.3.1.Final-redhat-1.jar:2.3.1.Final-redhat-1]

                    at org.hornetq.jms.server.recovery.HornetQXAResourceWrapper.connect(HornetQXAResourceWrapper.java:378) [hornetq-jms-server-2.3.1.Final-redhat-1.jar:2.3.1.Final-redhat-1]

                    at org.hornetq.jms.server.recovery.HornetQXAResourceWrapper.getDelegate(HornetQXAResourceWrapper.java:287) [hornetq-jms-server-2.3.1.Final-redhat-1.jar:2.3.1.Final-redhat-1]

                    at org.hornetq.jms.server.recovery.HornetQXAResourceWrapper.recover(HornetQXAResourceWrapper.java:75) [hornetq-jms-server-2.3.1.Final-redhat-1.jar:2.3.1.Final-redhat-1]

                    at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecoverySecondPass(XARecoveryModule.java:695) [jbossjts-jacorb-4.17.4.Final-redhat-2.jar:4.17.4.Final-redhat-2]

                    at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.bottomUpRecovery(XARecoveryModule.java:419) [jbossjts-jacorb-4.17.4.Final-redhat-2.jar:4.17.4.Final-redhat-2]

                    at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkSecondPass(XARecoveryModule.java:194) [jbossjts-jacorb-4.17.4.Final-redhat-2.jar:4.17.4.Final-redhat-2]

                    at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:789) [jbossjts-jacorb-4.17.4.Final-redhat-2.jar:4.17.4.Final-redhat-2]

                    at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [jbossjts-jacorb-4.17.4.Final-redhat-2.jar:4.17.4.Final-redhat-2]

                 

                17:58:16,945 DEBUG [org.hornetq.jms.server] (Periodic Recovery) HQ119007: Cannot connect to server(s). Tried with all available servers.: HornetQException[errorType=NOT_CONNECTED message=HQ119007: Cannot connect to server(s). Tried with all available servers.]

                    at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:852) [hornetq-core-client-2.3.1.Final-redhat-1.jar:2.3.1.Final-redhat-1]

                    at org.hornetq.jms.server.recovery.HornetQXAResourceWrapper.connect(HornetQXAResourceWrapper.java:378) [hornetq-jms-server-2.3.1.Final-redhat-1.jar:2.3.1.Final-redhat-1]

                    at org.hornetq.jms.server.recovery.HornetQXAResourceWrapper.getDelegate(HornetQXAResourceWrapper.java:287) [hornetq-jms-server-2.3.1.Final-redhat-1.jar:2.3.1.Final-redhat-1]

                    at org.hornetq.jms.server.recovery.HornetQXAResourceWrapper.recover(HornetQXAResourceWrapper.java:75) [hornetq-jms-server-2.3.1.Final-redhat-1.jar:2.3.1.Final-redhat-1]

                    at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecoverySecondPass(XARecoveryModule.java:695) [jbossjts-jacorb-4.17.4.Final-redhat-2.jar:4.17.4.Final-redhat-2]

                    at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.bottomUpRecovery(XARecoveryModule.java:419) [jbossjts-jacorb-4.17.4.Final-redhat-2.jar:4.17.4.Final-redhat-2]

                    at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkSecondPass(XARecoveryModule.java:194) [jbossjts-jacorb-4.17.4.Final-redhat-2.jar:4.17.4.Final-redhat-2]

                    at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:789) [jbossjts-jacorb-4.17.4.Final-redhat-2.jar:4.17.4.Final-redhat-2]

                    at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [jbossjts-jacorb-4.17.4.Final-redhat-2.jar:4.17.4.Final-redhat-2]

                 

                Sorry Guys for not pasting the full stack trace which could helped to resolve the error much earlier,

                • 5. Re: EJB JNDI lookup not working
                  wdfink

                  That sound as a HornetQ problem to me, could you open a new thread and share more details and the invocation code?

                  • 6. Re: EJB JNDI lookup not working
                    sachin.dhingra

                    I agree with you and i have opened a new thread for that problem.

                     

                    Also I want to bring one thing to notice is when I changed the jar file i.e., websphere specific jar file (com.ibm.ws.ejb.thinclient_7.0.0.jar - which has the implementaion for the lookup methods) to javax.ejb.jar, javax.jms.jar (which only has the interfaces not the implementation of EJB methods or context lookup methods), it is not even deploying the my ear file for quite a long time and finally failed due to timeout and it is not logging anything to the log file (server.log and application.log) which it used to write when it is logging when used websphere specific jar file.

                     

                    I don't know what is happening here.

                     

                    Please help.