It's not a secret anymore!*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes using EJB annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "using EJB annotation" Watch "using EJB annotation" New topic
Author

using EJB annotation

Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
I am trying to use EJB annotaton, but it throws an exception.


Exception:
22:32:48,656 INFO [EJBContainer] STOPPED EJB: com.ejb3inaction.actionbazaar.buslogic.StatelessBean ejbName: StatelessBean
22:32:48,656 WARN [ServiceController] Problem starting service jboss.j2ee:ear=myEJB.ear,jar=myEJB-ejb.jar,name=StatelessBean,service=EJB3
java.lang.RuntimeException: could not resolve global JNDI name for @EJB for container StatelessBean: reference class: com.ejb3inaction.actionbazaar.buslogic.WelcomeBean ejbLink: not used by any EJBs
at org.jboss.injection.EjbEncInjector.inject(EjbEncInjector.java:88)
at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:570)
at org.jboss.ejb3.SessionContainer.start(SessionContainer.java:154)
at org.jboss.ejb3.stateless.StatelessContainer.start(StatelessContainer.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at org.jboss.Main$1.run(Main.java:508)
at java.lang.Thread.run(Thread.java:595)
22:32:48,671 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
22:32:48,671 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=myEJB.ear,jar=myEJB-ejb.jar,name=WelcomeBean,service=EJB3 with dependencies:
22:32:48,687 INFO [EJBContainer] STARTED EJB: com.ejb3inaction.actionbazaar.buslogic.WelcomeBean ejbName: WelcomeBean
22:32:48,796 INFO [EJB3Deployer] Deployed: file:/E:/DJ/Java Certifications/SCBCD/eBooks/Application Servers/JBOSS/jboss-4.2.3.GA/server/default/tmp/deploy/tmp59087myEJB.ear-contents/myEJB-ejb.jar
22:32:48,796 INFO [EARDeployer] Started J2EE application: file:/E:/DJ/Java Certifications/SCBCD/eBooks/Application Servers/JBOSS/jboss-4.2.3.GA/server/default/deploy/myEJB.ear
22:32:48,812 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

--- MBeans waiting for other MBeans ---
ObjectName: jboss.j2ee:ear=myEJB.ear,jar=myEJB-ejb.jar,name=StatelessBean,service=EJB3
State: FAILED
Reason: java.lang.RuntimeException: could not resolve global JNDI name for @EJB for container StatelessBean: reference class: com.ejb3inaction.actionbazaar.buslogic.WelcomeBean ejbLink: not used by any EJBs

--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.j2ee:ear=myEJB.ear,jar=myEJB-ejb.jar,name=StatelessBean,service=EJB3
State: FAILED
Reason: java.lang.RuntimeException: could not resolve global JNDI name for @EJB for container StatelessBean: reference class: com.ejb3inaction.actionbazaar.buslogic.WelcomeBean ejbLink: not used by any EJBs



I renamed WelcomeBean to AWelcomeBean still i seee the same error
22:46:18,000 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=myEJB.ear,jar=myEJB-ejb.jar,name=AWelcomeBean,service=EJB3 with dependencies:
22:46:18,062 INFO [EJBContainer] STARTED EJB: com.ejb3inaction.actionbazaar.buslogic.AWelcomeBean ejbName: AWelcomeBean
22:46:18,390 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
22:46:18,390 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=myEJB.ear,jar=myEJB-ejb.jar,name=StatelessBean,service=EJB3 with dependencies:
22:46:18,390 INFO [EJBContainer] STOPPED EJB: com.ejb3inaction.actionbazaar.buslogic.StatelessBean ejbName: StatelessBean
22:46:18,406 WARN [ServiceController] Problem starting service jboss.j2ee:ear=myEJB.ear,jar=myEJB-ejb.jar,name=StatelessBean,service=EJB3
java.lang.RuntimeException: could not resolve global JNDI name for @EJB for container StatelessBean: reference class: com.ejb3inaction.actionbazaar.buslogic.AWelcomeBean ejbLink: not used by any EJBs
at org.jboss.injection.EjbEncInjector.inject(EjbEncInjector.java:88)
at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:570)

How to get this working?


SCJP, SCWCD, SCBCD
prashant k. gupta
Ranch Hand

Joined: May 15, 2008
Posts: 62
Originally posted by Deepak Jain:
How to get this working?



I think DI should perform on bean class remote interface , instead on Bean itself since you are going to invoke call on buisness interface reference only. In your case it should be:-

@EJB (beanname="WelcomeBean")
HelloUser bean;

correct me i am wrong
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Solution
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: using EJB annotation
 
Similar Threads
Deployment errors in JBoss 5.1
Error while doing DI in statefull session bean
@PostConstruct is never called.
Logging JNDI Name
Problem with EJB 3. Name not bound error