Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 282
Diego Magalhães Avatar asked Dec 30 '25 15:12

Diego Magalhães


1 Answers

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.

like image 60
diega Avatar answered Jan 04 '26 12:01

diega



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!