[
https://jira.jboss.org/jira/browse/WELD-239?page=com.atlassian.jira.plugi...
]
Pete Muir commented on WELD-239:
--------------------------------
Ah, probably because you use Instance, not direct injection :-)
AbstractProducerBean.checkReturnValue seems to check against the
wrong injection point
--------------------------------------------------------------------------------------
Key: WELD-239
URL:
https://jira.jboss.org/jira/browse/WELD-239
Project: Weld
Issue Type: Bug
Components: Producers (Methods, Fields and Disposers)
Affects Versions: 1.0.0.CR1
Environment: Weld 1.0.0.CR1, embedded Jetty
Reporter: Huy Le
Fix For: 1.0.0.CR2
Attachments: numberguess.zip
I was running a modified version of the numberguess example (attached to this issue) and
got the following exception which doesn't seem quite right:
javax.enterprise.inject.IllegalProductException: Producers cannot produce
non-serializable instances for injection into non-transient fields of passivating beans
Producer:
org.jboss.weld.bean-web-module-ProducerMethod-org.jboss.weld.examples.numberguess.FacesContextManager.getFacesContext()
Injection Point: field org.jboss.weld.examples.numberguess.Game.maxNumber
at
org.jboss.weld.bean.AbstractProducerBean.checkReturnValue(AbstractProducerBean.java:201)
at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:287)
at org.jboss.weld.context.AbstractMapContext.get(AbstractMapContext.java:104)
at
org.jboss.weld.bean.proxy.ClientProxyMethodHandler.getProxiedInstance(ClientProxyMethodHandler.java:139)
at
org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:97)
at
javax.faces.context.FacesContext_$$_javassist_7.getELContext(FacesContext_$$_javassist_7.java)
at org.jboss.weld.examples.numberguess.Generator.getMaxNumber(Generator.java:38)
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:597)
at
org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:111)
at
org.jboss.weld.examples.numberguess.Generator_$$_javassist_6.getMaxNumber(Generator_$$_javassist_6.java)
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:597)
at
org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:227)
at
org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:148)
at org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:117)
at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:286)
at org.jboss.weld.context.DependentContext.get(DependentContext.java:62)
at org.jboss.weld.BeanManagerImpl.getReference(BeanManagerImpl.java:899)
at org.jboss.weld.BeanManagerImpl.getReference(BeanManagerImpl.java:945)
at org.jboss.weld.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:967)
at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:78)
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:683)
at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:695)
at org.jboss.weld.bean.ManagedBean$1$1.proceed(ManagedBean.java:195)
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:51)
at org.jboss.weld.bean.ManagedBean$1.inject(ManagedBean.java:189)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:115)
at org.jboss.weld.context.AbstractMapContext.get(AbstractMapContext.java:104)
at
org.jboss.weld.bean.proxy.ClientProxyMethodHandler.getProxiedInstance(ClientProxyMethodHandler.java:139)
at
org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:97)
at
org.jboss.weld.examples.numberguess.Game_$$_javassist_5.getNumber(Game_$$_javassist_5.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Not sure if my analysis is correct, but it seems that:
1. FieldInjectionPoint for maxNumber is set as the current injection point in
BeanManagerImpl
2. Producer method for maxNumber is invoked
3. The getELContext method is invoked on the FacesContext proxy
4. The getProxiedInstance method is invoked on ClientProxyMethodHandler which causes
the producer method for FacesContext to be invoked
5. The checkReturnValue on AbstractProducerBean is invoked, but it is checking the
FacesContext return value against the injection point for maxNumber (since this is still
the current injection point) an an IllegalProductException is thrown since maxNumber must
be serializable (but not FacesContext)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira