• Post Reply Bookmark Topic Watch Topic
  • New Topic

Lookup pbm for a local EJB in JBOSS  RSS feed

 
Sylvain Bouchard
Ranch Hand
Posts: 41
Java ME Objective C Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I try to make a working example of a local EJB.
Everything is deployed on the server with no errors.
But when I try to run the servlet, I got this error.
I use jboss-4.0.3SP1

I've searched on the JBOSS web site but didn't find any help.
Hope someone had this problem before...

15:35:31,375 INFO [EARDeployer] Started J2EE application: file:/D:/App/jboss-4.0.3SP1/server/default/deploy/HeadFirstEAR.ear
15:35:50,593 INFO [STDOUT] javax.naming.NameNotFoundException: ejb not bound
15:35:50,593 INFO [STDOUT] at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)

-------------------------------------------------------------------------
Here's my files
-------------------------------------------------------------------------
EJB-JAR.XML



JBOSS-WEB.XML



WEB.XML



CLIENT



Thanks
Sylvain
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sylvain,

Since you're using ejb references (which by the way is a very good practice), I'd recommand you looking up the bean using the Environment Naming Context (ENC):



Regards.
 
Sylvain Bouchard
Ranch Hand
Posts: 41
Java ME Objective C Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think it's not the problem.
I've take a look in the JBoss console and this is the message I've found

16:54:43,734 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'TaxeCalculatorLocalBean' to jndi 'local/TaxeCalculatorLocalBean@19287172'

It seems that JBoss bound my local EJB to local/TaxeCalculatorLocalBean@19287172

that's why I cannot get it...
Anyone have a solution?

Thanks
Sylvain
 
James Atkins
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sylvain,

Here is the solution. I banged my head for many hours on this same problem.

I found this on JBoss site but sheer luck it seems

http://wiki.jboss.org/wiki/Wiki.jsp?page=WhyDoesTheLocalNameContainARandomNumber

After reading that all I did was modify the jboss.xml file of my ejb jar file to create a local name of my choosing. For example:

<jboss>
<enterprise-beans>
<entity>
<ejb-name><MyBean></ejb-name>
<local-jndi-name><any path and name I want for MyBean></local-jndi-name>
</entity>
</enterprise-beans>
</jboss>

Redeploy the ejb jar file and you should see the fruits of your labor displayed to JBoss console.

NOTE: I have no magic entries in the web.xml or jboss-web.xml, all I did was modify the one jboss.xml file in the ejb jar file.
[ December 25, 2005: Message edited by: James Atkins ]
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even though this works, I won't recommend it. You should understand that the developer must declare all the EJB references using the ejb-ref elements of the deployment descriptor. The Deployer then binds the EJB references to the enterprise bean's homes in the target operational environment, which in this case is JBOSS. So, should you need to change EJB server, it's only the binding which must change and not the hard-coded JNDI names.

Picking up Valentin's point, the JNDI lookup should be done as he says by using the EJB reference. Furthermore, if you add an ejb-link element (whose value must match the <ejb-name> of the bean) to the web.xml file like this:



Your JNDI lookup can be done like this:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!