jbossejb-3.0seam

EJB into SEAM Component (Different projects and same JBoss)


I have the following setup:

JBoss 4.2.3
under that I have:

 
--> Project A  (Which is not SEAM 2.1.2GA based)
    EJBs:
       * beanA (JNDI = beanA/remote)
       * beanB (JNDI = beanB/remote)

--> Project B  (SEAM based)
    EJBs / Components:
       * ComponentX
       * ComponentY

On component X I have the current piece of code:

@Scope(ScopeType.CONVERSATION)
@Name("ComponentX")
public class ComponentX implements java.io.Serializable { 
...
@EJB
beanAInterface beanA;
....
public foo(){
    beanA.bar();  // <--------- beanA is null, even with mapped name and etc., only works
                  //            if I direct lookup with Context().lookup("beanA/remote")
}

Any ideas on how to solve this?


Solution

  • Your ComponentX class is not an EJB, so you cannot use the @EJB annotation to inject them. You have a few options. Convert your ComponentX to EJB adding @Stateless or @Statefull and an interface @Local or @Remote, in this way the AS will notice ComponentX is an EJB and will know what to do with the desired injection. The other option is let the ComponentX as simply a component and use InitialContext#lookup for obtaining the reference to "beanA/remote" by hand.