开发者

Inject EJBs into a Seam Component

guys. I have a Seam project running on Tomcat 6.0.20 (webapp.war) and an EJB project running on JBoss 4.2.3 (ejbapp.ear).

I can access my EJBs in my Seam components using JNDI lookup [initialContext.lookup(...)]. I'd like to have them injected in my Seam components instead.

My Seam components ARE NOT EJBs, so I can't use @EJB annotation. I'd like to have something like this in my Tomcat (Web) app.

@Name("customerAction")
public class CustomerAction {

    @In // even with (autoCreate=true) or the EJB name if necessary
    private CustomerEJB customerEJB;

    ...
}

And this in the JBoss (EJB) app.

@Stateless(name="customerEJB")
public class CustomerEJBImpl implements CustomerEJB {
    ...
}

@Remote
public interface CustomerEJB {
    ...
}

In my components.xml I have the jndiPattern=ejbapp/@jndiPattern/remote specified just like I currently use to lookup the EJBs (ex: ejbapp/CustomerEJB/remote)开发者_如何学JAVA.

I'm probably missing something in my configuration to make this work. PS: I'd like NOT HAVE to annotate my EJBs as @Name (Seam) components.

Any suggestions? Thanks in advance.


Thanks for your reply, but it didn't work.

When I declared the EJBs in components.xml, it did inject the object in my Action (Seam component), but as a POJO. I mean, the EntityManager and other EJB injections I had in the injected object didn't work.

I also tried to define the EJB as a Seam component, but, once they are in the webproject inside a JAR file, it didn't load automatically, and trying the scenario above, I got the same error.

Just an FYI, I also declared the Seam interceptor in ejb-jar.xml file. I have no idea why this is happening, BTW I thought it would be quite a simple thing for Seam to handle.

Anyway..., any other suggestions, guys?


Define your EJB as Seam components in your components.xml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜