[JBoss Seam] - Re: Help injecting the SessionContext
by bfo81
Stop, forget what I said. I just had a look at UnsafeObjectFieldAccessorImpl.java and its set-method:
public void set(Object obj, Object value)
| throws IllegalArgumentException, IllegalAccessException
| {
| ensureObj(obj);
| if (isFinal) {
| throw new IllegalAccessException("Field is final");
| }
| if (value != null) {
| if (!field.getType().isAssignableFrom(value.getClass())) {
| throw new IllegalArgumentException();
| }
| }
| unsafe.putObject(obj, fieldOffset, value);
| }
As you can see, the IllegalArgumentException (that is the root cause auf your exception) is thrown, if the class of a field (namely sessionContext here) doesn't fit the class of the object that should be injected.
Or, to put in a nutshell:
Whatever Seam tries to inject into private SessionContext sessionContext; is not compatible to class SessionContext! Try it like this:
@In(required=false)
| private Object sessionContext;
|
| ...
|
| log.info("The class of the injected thing is: " + sessionContext.getClass());
Then you will see what's injected and you can start solving the issue.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962378#3962378
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962378
18 years, 5 months
[JBoss Seam] - Re: Help injecting the SessionContext
by bfo81
First: You don't need to write value="sessionContext" since the name of the annotated variable is the same, namely sessionContext. You only need to explicitely set the value when the variable's name ist different from the seam component name.
Ok, now to your problem: The last Exception says that reflection cannot set the property. Maybe there's any security restriction in the Java Virtual Machine (I must confess, I'm not that sure why it's possible to access a private field without accessors at all, maybe someone familiar with that could say something about that). I'd try to implement a getter and setter (getSessionContext(), setSessionContext(...), don't forget to put them in the local interface if this is an EJB) in order to see if the exception still occurs then.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962377#3962377
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962377
18 years, 5 months