Howto inject EJBs into POJO componets?
amin59 Nov 5, 2005 3:25 AMHi,
I'm using a layerd architecture and have POJO componets as action listeners and EJBs for logic. They look like this :
@Name("listAgents")
@Interceptor(SeamInterceptor.class)
@Scope(value = CONVERSATION)
@Conversational(ifNotBegunOutcome = "main")
@Intercept(value = InterceptionType.ALWAYS)
public class ListAgentsAction {
private static final Logger log = Logger.getLogger(ListAgentsAction.class);
...
And
@Name("agentFacadeBean")
@Stateless
@Interceptor(SeamInterceptor.class)
@Intercept(InterceptionType.ALWAYS)
public class AgentFacadeBean implements AgentFacade {
...
Both of them, are viewed as "Seam Componets" but when I wana inject EJBs inside my POJOs, it fails throwing this exception:
java.lang.IllegalArgumentException: could not inject: agentFacadeBean to: listAgents at org.jboss.seam.Component.setFieldValue(Unknown Source) at org.jboss.seam.Component.injectFields(Unknown Source) at org.jboss.seam.Component.inject(Unknown Source) at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.seam.util.Reflections.invoke(Unknown Source) at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Unknown Source) at org.jboss.seam.interceptors.SeamInvocationContext.proceed(Unknown Source) at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ...
I tried to inject my EJB inside POJO action component with below code:
@In(required = true, create = true) private AgentFacadeBean agentFacadeBean;
I also tried to inject via @EJB annotation but then, I get a null object.
Thanks for your help.