Seam 2 invocation issue on conversation scoped component
guinotphil Mar 2, 2012 5:37 AMHello,
Still doing a migration of a Seam 2.2.2 application from AS 4 to AS 7.1 Final, I’m having an issue with some Seam conversation scoped components.
Let me explain. First here is my component class
package myapplication;
@Name(MyComponent.NAME)
@Scope(ScopeType.CONVERSATION)
public class MyComponent implements Serializable
{
private static final long serialVersionUID = -7739765902798043565L;
public static final String NAME = "myapplication.mycomponent";
public static MyComponent getInstance() {
return (MyComponent) Component.getInstance(NAME);
}
private Integer value = 0;
@Create
public void init()
value = 15;
}
Integer getValue() {
return value;
}
}
The issue is that on AS 7, I always get a 0 value on MyComponent.getInstance().getValue() while I should actually get the Integer 15 (which is the case on AS 4).
With breakpoints on the init() and getValue() methods, I see that with AS 4, on the init() method the current instance is myapplication.MyComponent (id=834)
And the strack is:
myapplication.MyComponent.init(MyComponent.java)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
myapplication.MyComponent_$$_javassist_seam_19.init(MyComponent_$$_javassist_seam_19.java)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
org.jboss.seam.Component.callComponentMethod(Component.java:2275)
org.jboss.seam.Component.callCreateMethod(Component.java:2198)
org.jboss.seam.Component.newInstance(Component.java:2158)
org.jboss.seam.Component.getInstance(Component.java:2024)
org.jboss.seam.Component.getInstance(Component.java:1986)
org.jboss.seam.Component.getInstance(Component.java:1980)
org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
org.jboss.seam.Namespace.get(Namespace.java:28)
…
And then, when I call getValue(), the current instance is still myapplication.MyComponent (id=834)
And the stack:
myapplication.MyComponent.getValue(MyComponent.java)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
myapplication.MyComponent_$$_javassist_seam_19.getValue(MyComponent_$$_javassist_seam_19.java)
myapplication.MyBusinessClass.someBusinessMethod()
…
On the other hand, here is what happens on AS 7.
My breakpoint on init() tells me that the current instance is myapplication.MyComponent (id=651)
And the stack is
myapplication.MyComponent.init(yComponent.java:70)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
myapplication.MyComponent_$$_javassist_seam_17.init(MyComponent_$$_javassist_seam_17.java)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
org.jboss.seam.Component.callComponentMethod(Component.java:2275)
org.jboss.seam.Component.callCreateMethod(Component.java:2198)
org.jboss.seam.Component.newInstance(Component.java:2158)
org.jboss.seam.Component.getInstance(Component.java:2024)
org.jboss.seam.Component.getInstance(Component.java:1986)
org.jboss.seam.Component.getInstance(Component.java:1980)
org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
org.jboss.seam.Namespace.get(Namespace.java:28)
...
Here, this works the same way as in AS 4.
Then, when I call my getValue() method, the current instance is: myapplication.MyComponent_$$_javassist_seam_17 (id=663)
And the stack:
myapplication.MyComponent.getValue(MyComponent.java)
myapplication.MyComponent_$$_javassist_seam_17.getValue(MyComponent_$$_javassist_seam_17.java)
myapplication.MyBusinessClass.someBusinessMethod()
...
It looks that the invocation does not work when calling a method of my component, and so, it refers to a different ‘value’ attribute. In AS 4 the javassist instance’s getValue method called the wrapped instance method, while it no longer do it on AS 7.
Is there something wrong with my component? Or is this a bug? I find it rather strange that the behavior is different for the @Create and other method of the component.
Thank you for your help