[jboss-user] [EJB 3.0] - Re: NullPointerException in JavaEEComponentHelper with JBoss

jaikiran do-not-reply at jboss.com
Fri Apr 24 01:48:09 EDT 2009


Ah, you have circular dependency here! AStatelessBean injects BStatelessBean and BStatelessBean injects AStatelessBean.

Add a @org.jboss.ejb3.annotation.IgnoreDependency (in addition to @EJB) to any one end of the injection. For example:


  | import org.jboss.ejb3.annotation.IgnoreDependency;
  | 
  | @Stateless
  | public class AStatelessSessionBean implements AStatelessSession
  | {
  |   // we have a circular dependency, so add @IgnoreDependency
  |    @EJB
  |     @IgnoreDependency
  |    private BStatelessSession bean;
  | 
  |    @TransactionAttribute(TransactionAttributeType.REQUIRED)
  |    public String sayHello( String name )
  |    {
  |       return bean.sayHello(name);
  |    }
  | 
  |    public String greetingPhrase()
  |    {
  |       return "Hello there";
  |    }
  | }
  | 
  | @Stateless
  | public class BStatelessSessionBean implements BStatelessSession
  | {
  |    @EJB
  |    //@EJB(mappedName="ifssimpletest/AStatelessSessionBean/local")
  |    private AStatelessSession bean;
  | 
  |    @TransactionAttribute(TransactionAttributeType.REQUIRED)
  |    public String sayHello( String name )
  |    {
  |       return bean.greetingPhrase() + ", " + name + "!\n";
  |    }
  | }
  | 

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4226454#4226454

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4226454



More information about the jboss-user mailing list