Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot inject ejb into jsf application in wildfly

 
Heiko Wiesner
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

i want to use an ejb from a framework in a jsf application.
the framework hannymede is deployed as an ear.
the webapp is deployed in a seperate war.

Here the jndi names:

java:global/hannymede-server-ear-0.0.2-SNAPSHOT/hannymede-server-ejb-0.0.2-SNAPSHOT/GenericFactoryBean!de.itwiesner.hannymede.common.interfaces.GenericFactoryBeanLocal
java:app/hannymede-server-ejb-0.0.2-SNAPSHOT/GenericFactoryBean!de.itwiesner.hannymede.common.interfaces.GenericFactoryBeanLocal
java:module/GenericFactoryBean!de.itwiesner.hannymede.common.interfaces.GenericFactoryBeanLocal
java:global/hannymede-server-ear-0.0.2-SNAPSHOT/hannymede-server-ejb-0.0.2-SNAPSHOT/GenericFactoryBean!de.itwiesner.hannymede.common.interfaces.GenericFactoryBeanRemote
java:app/hannymede-server-ejb-0.0.2-SNAPSHOT/GenericFactoryBean!de.itwiesner.hannymede.common.interfaces.GenericFactoryBeanRemote
java:module/GenericFactoryBean!de.itwiesner.hannymede.common.interfaces.GenericFactoryBeanRemote
java:jboss/exported/hannymede-server-ear-0.0.2-SNAPSHOT/hannymede-server-ejb-0.0.2-SNAPSHOT/GenericFactoryBean!de.itwiesner.hannymede.common.interfaces.GenericFactoryBeanRemote

Here my EJB Client Class:


I tried all the names from the jndi names list as @EJB(name="...").

but always get Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: ejb/GenericFactoryBean

How can i reference the ejb?

best regards

Heiko
 
Francesco Marchioni
author
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
assumed that you have correctly solved the dependencies to the EJB Contained in the EAR file (for example including in the Web application Dependencies: deployment.YouEarApp.ear.YourEJBApp.jar) then there is no need to specify the EJB name, it should work out of the box with:



Besides this, the JNDI name you specified is uncorrect. For an external application you had to specify the java:/app namespace (if you really need to do it):


Regards
Francesco
 
Heiko Wiesner
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your answer.

When i include the ejb's in my war - it works, but i want to have the framework in it's own ear cause i want to use it in other Apps too.

The java:app namespace does unfortunately not work.

What do you mean with correctly solved the dependencies? I referenced it in maven as provided.

best regards

Heiko
 
Heiko Wiesner
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

for all with the same problem: mappedName was the problem.
Following worked for me:

@EJB(mappedName = "java:jboss/exported/hannymede-server-ear-0.0.2-SNAPSHOT/hannymede-server-ejb/GenericFactory!de.itwiesner.hannymede.common.interfaces.GenericFactoryBeanRemote")

best regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic