-
1. Re: @Service / @Management bean injection
swd847 Sep 20, 2007 12:41 AM (in response to rhomber)Have you tried @In(create=true) or annoting the EJB with @AutoCreate ?
-
2. Re: @Service / @Management bean injection
rhomber Sep 20, 2007 9:12 PM (in response to rhomber)Yeah, I just tried it then. I didn't try it before because the service is initialized when it's deployed. It didn't help, I am still getting the same error..
10:39:34,308 ERROR [ExceptionFilter] uncaught exception
javax.servlet.ServletException: In attribute requires non-null value: authenticator.gajService
Granted EJB3 and Seam are not the same thing, but because Seam operates within the EJB container, surely there is a way of operating with an EJB3 service? I really don't want to have to do a JNDI lookup :( That would suck.
Hope someone can help,
David -
3. Re: @Service / @Management bean injection
rhomber Sep 20, 2007 11:34 PM (in response to rhomber)Perhaps I should rephrase my question. Assuming I implemented a service following the tutorial: http://docs.jboss.com/ejb3/app-server/tutorial/service/service.html - How would I inject that service into my Seam component? Would I need to inject it by a remote or local interface, or by the management interface?
I currently have the following:
Management Interface:@Management public interface GAJServiceMBean extends ServiceMBean { .... }
Local Interface:@Local public interface GAJServiceLocal { .... }
Remote Interface:@Remote public interface GAJServiceRemote { .... }
Implementation:@Service(objectName = "utiba:service=GAJ") public class GAJService extends ServiceMBeanSupport implements GAJServiceMBean, GAJServiceLocal, GAJServiceRemote, Serializable { // Serial Version protected static final long serialVersionUID = 10234234234L; ...... }
I have tried some of the following injection combinations:@In GAJServiceMBean gajService; @EJB GAJServiceMBean gajService; @EJB GAJServiceLocal gajService; @EJB GAJServiceRemote gajService;
The first results in the not-null condition, the rest result in the object remaining null.
Cheers,
David -
4. Re: @Service / @Management bean injection
norman.richards Sep 21, 2007 3:11 AM (in response to rhomber)@Service creates an MBean, not an EJB. We don't provide a way to lookup MBeans (though perhpaps we should?) so you should implement the JNDI lookups yourself - using @Factory or maybe @Unwrap.
-
5. Re: @Service / @Management bean injection
rhomber Sep 21, 2007 4:23 AM (in response to rhomber)Hey,
I found a feature request that suggests there is a way of doing it: http://jira.jboss.org/jira/browse/JBSEAM-1498
I am not stuck with the fact that I cannot inject a stateless bean either. Perhaps my understanding of how Seam works is wrong.
I have a stateless bean:@Name("utibaServiceGajMediator") @Stateless @Scope(ScopeType.APPLICATION) @AutoCreate public class GAJServiceMediatorBean implements GAJServiceMediator { public int nextTransID() throws Exception { return 1234; } }
Implementing interface:@Local public interface GAJServiceMediator { public int nextTransID() throws Exception; }
And then used by this class:@Name("utibaTester") @AutoCreate public class UtibaTest { @In GAJServiceMediator gajServiceMediator; @In MyBean myBean; public void takeMagicFlight() { try { myBean.setText("TransID = " + gajServiceMediator.nextTransID()); } catch (Exception e) { myBean.setText("Failed"); } } }
Then elsewhere I have a commandLink:<h:commandButton type="submit" value="Fly Away" action="#{utibaTester.takeMagicFlight}"/>
And get the following error message:Caused by: javax.faces.el.EvaluationException: /ajax.xhtml @22,102 action="#{utibaTester.takeMagicFlight}": org.jboss.seam.RequiredException: In attribute requires non-null value: utibaTester.gajServiceMediator at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63) ... 43 more Caused by: org.jboss.seam.RequiredException: In attribute requires non-null value: utibaTester.gajServiceMediator
Well that is the useful portion anyway. As far as I can tell I have followed the documentation, perhaps my understanding of how all this should work together is wrong? Should I be able to have one stateless bean injected as a resource to another bean?
Any help would be appreciated.
Cheers,
David -
6. Re: @Service / @Management bean injection
michael.c.small Sep 21, 2007 10:03 AM (in response to rhomber)Have you tried @Resource for your injection. Since @Service classes are stored in JNDI, I don't see why the @Resource wouldn't work.
-
7. Re: @Service / @Management bean injection
norman.richards Sep 21, 2007 12:43 PM (in response to rhomber)We've had several requests for this, so I've scheduled that for 2.0.1.
-
8. Re: @Service / @Management bean injection
matt.drees Sep 21, 2007 1:52 PM (in response to rhomber)"rhomber" wrote:
@Name("utibaServiceGajMediator") ... public class GAJServiceMediatorBean implements GAJServiceMediator { }
And then used by this class:... @In GAJServiceMediator gajServiceMediator;
...
org.jboss.seam.RequiredException: In attribute requires non-null value: utibaTester.gajServiceMediator
Your names don't match; gajServiceMediator != utibaServiceGajMediator -
9. Re: @Service / @Management bean injection
rhomber Sep 23, 2007 8:47 PM (in response to rhomber)Hey All,
Thanks so much for helping. I didn't know that the instance variable had to be the same name as the @Name, I thought it was injected based on the class. Thanks for clarifying this, I feel a bit silly :). It all works fine now, and I was able to inject the service via another means that seems a little less tacky than the JNDI lookup (@Resource). However, I would love a Seam built-in to handle it as is suggested above. I simply used the method described in: http://jira.jboss.org/jira/browse/JBSEAM-1498 as a work around and it worked fine.
Cheers and thank you,
David