• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB JNDI lookup not working  RSS feed

 
SachinD hingra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would anything be deployed within the bin folder of JBoss? Your EAR should be deployed in standalone/deployments, not bin/content. Unless you made some strange chances to the JBoss configuration that is, but why would you want to change the deployment folder?
 
SachinD hingra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,

I have deployed/placed the ear under standalone/deployments folder only but when server starts it deployed ear file (containing jar and war) it to its internal memory under some standalone\tmp\vfs folder.

Ear file structure:
|_ conf folder contains property file
|_ lib folder contains property file
|_ META-INF folder contains application.xml file
|_ resources folder contains messages file
|_ xsl folder
|_jar file
|_ war file

But in my code I am looking for the application root directory to create my log directory for my application log file which it returned <JBOSS_HOME>\bin\content\<earNameFolder>.

Also, the same application root is the one where I will look to find the conf directory containing properties file which will be specifying the logger property (DEBUG or INFO).

This conf directory is part of the ear file and my assumption was when server deployed the ear file it explodes the directory structure in application root folder just like websphere and weblogic.

But in JBOSS application root is <JBOSS_HOME>\bin\content\<earNameFolder> but it doesn't have the conf directory. Same is working fine in weblogic & websphere.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SachinD hingra wrote:This conf directory is part of the ear file and my assumption was when server deployed the ear file it explodes the directory structure in application root folder just like websphere and weblogic.

And there's your mistake. JBoss is not the same as Websphere or Weblogic. Even the assumption that your EAR file would be exploded cannot be made; you have to explicitly tell JBoss in its configuration file to explode deployed content (and even then it complains through a warning when starting up).

At work we had to load a properties file that was located inside the EAR. We even created a JBoss ticket for it. Their response: put the file inside a JAR / WAR file inside the EAR instead. That way you can load it as a resource (Class.getResource, Class.getResourceAsStream).
 
SachinD hingra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob for the explanation.

But do you have any idea about issue mentioned in pt# 2 i.e., JNDI Lookup to the EJB's?
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SachinD hingra wrote:

But do you have any idea about issue mentioned in pt# 2 i.e., JNDI Lookup to the EJB's?


Your JNDI lookup string is incorrect. You are using:



But as noted in the logs, it should be:

 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not necessarily. In EJB 3.1, there's also a no-interface view for JavaBeans. It's basically the same as using a local interface, but the JNDI name can omit the !<interface> part. The lookup is valid, since JBoss even mentions that "java:app/xxxHubEJB/TimerServiceBean" is a valid JNDI binding.
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SachinD

Assuming the class performing the JNDI lookup is in the same jar as the EJBs, have you tried using the module namespace for the lookup string?
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote: The lookup is valid, since JBoss even mentions that "java:app/xxxHubEJB/TimerServiceBean" is a valid JNDI binding.


You are right. I didn't notice from the logs that the bean exposed a no-interface view.
 
SachinD hingra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,

I have not tried the module namespace lookup. Quite a busy these days but will try and update.
 
SachinD hingra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,

Tried module way of JNDI lookup like below



It is still failing with below error:

 
SachinD hingra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:



Sorry Guys for not pasting the full stack trace of previous error which could helped to resolve the error much earlier,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!