I've set up a SLSB as follows:
@Stateless
| @Name("simpleBean")
| public class SimpleBean implements Simple
| {
| public String getName()
| {
| return "simple";
| }
| }
|
The "simpleBean" bean can be accessed from a EL expression on a facelets page
without any trouble.
I have another SLSB like this:
@Stateless
| @Name("containerBean")
| public class ContainerBean implements Container
| {
| @In
| SimpleBean simpleBean;
|
| public String getName()
| {
| return simpleBean.getName();
| }
| }
However, when I try to access the getName method of "containerBean" I run into
the following error:
Caused by: org.jboss.seam.RequiredException: In attribute requires non-null
value: containerBean.simpleBean
| at org.jboss.seam.Component.getValueToInject(Component.java:1919)
|
If I change "simpleBean" into a JavaBean provided and annotate "containerBean"
with In(create=true) the injection works as expected, but if I create a similar
annotation without changing "simpleBean" to a JavaBean I get an error like this:
... 95 more
| Caused by: java.lang.IllegalArgumentException: Could not set field value by
reflection: ContainerBean.simpleBean on: com.somedomain.stateless.ContainerBean
with value: class org.javassist.tmp.java.lang.Object_$$_javassist_3
| at org.jboss.seam.util.Reflections.set(Reflections.java:77)
| at org.jboss.seam.Component.setFieldValue(Component.java:1555)
| ... 117 more
| Caused by: java.lang.IllegalArgumentException
| at
sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
|
The seam documentation makes it clear that SLSB's live in the stateless context
which is not included in the context search. Is this why my "simpleBean" can
not be found for injection into my "containerBean"? I'm not familiar with how
seam and the ejb3 container interact during instantiation of these SLSB objects
into pools - perhaps the beans are being created out of order? Perhaps I'm
trying to do something way beyond the intention of the EJB3 SLSB specification.
I'm pretty much resolved that what I'm trying to do here is not a great idea.
Is there a different way to dynamically assign a reference to a SLSB to a
different SLSB when a method is called? I would be very interested to hear
other peoples insight and wisdom on the subject. Thanks in advance and kind
regards.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4034807#4034807
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4034807
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user