-
1. Re: Producer Method and java.io.NotSerializableException
alesj Apr 12, 2012 7:31 AM (in response to s.hostettler)The problem is in how Weld serializes proxies.
As what you end-up with in HttpSession is not just your bean instance,
but Weld proxy instance, wrapping your bean.
I'll see if I can re-produce this.
-
2. Re: Producer Method and java.io.NotSerializableException
s.hostettler Apr 12, 2012 7:35 AM (in response to alesj)Thanks for looking at this. Tell me if you want me to build a minimum app to reproduce the problem.
-
3. Re: Producer Method and java.io.NotSerializableException
jharting Apr 12, 2012 7:43 AM (in response to s.hostettler)I think that the real problem here is that even though your logger field is transient, the Logger instance is still a dependent instance of the ManageStudentRegistration bean and therefore stored in the CreationalContext. Once the CreationalContext is being serialized you get the exception.
-
4. Re: Producer Method and java.io.NotSerializableException
alesj Apr 12, 2012 8:10 AM (in response to s.hostettler)Thanks for looking at this. Tell me if you want me to build a minimum app to reproduce the problem.
Better then minimum app is an Arquillian test for our tests-arquillian/ in Weld core project:
* https://github.com/weld/core/tree/master/tests-arquillian
If you can provide that, it would be perfect. ;-)
-
5. Re: Producer Method and java.io.NotSerializableException
s.hostettler Apr 12, 2012 10:31 AM (in response to jharting)Hi Jozef,
Thaks for the response, I am not sure that I understand how to solve the problem though. Do you suggest to add the @ApplicationScoped annotation to the producer?
-
6. Re: Producer Method and java.io.NotSerializableException
s.hostettler Apr 12, 2012 10:32 AM (in response to alesj)No problem Justin but as I do not know Arquillia, I will need some time to prepare the test. I will come back as soon as possible.
Thanks again for the help
-
7. Re: Producer Method and java.io.NotSerializableException
jharting Apr 12, 2012 10:39 AM (in response to s.hostettler)No, that way you would no longer be able to inject InjectionPoint into your producer. This is more of a Weld problem but you should be able to workaround provided you use a serializable Logger. What version of SLF4j are you using? I *think* all SLF4jLogger implementations were made serializable since certain version. Try updating SLF4j.
-
8. Re: Producer Method and java.io.NotSerializableException
alesj Apr 12, 2012 10:45 AM (in response to jharting)This is more of a Weld problem
Jozef, can you have a look at this then. ;-)
-
9. Re: Producer Method and java.io.NotSerializableException
s.hostettler Apr 12, 2012 1:06 PM (in response to jharting)Yes but Weld-servlet ships with an older version. Therefore, I must rethink the dependencies and fallback to servlet-core.
-
10. Re: Producer Method and java.io.NotSerializableException
s.hostettler Apr 15, 2012 6:44 AM (in response to alesj)Ok guys I finally manage to prepare an Arquillian test that demonstrates the bug. First, it only happens on Tomcat. Well I should say it happens with the weld-servlet and using
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
Now the problem is that the exeption occurs in the servlet on shutdown and I therefore cannot add a Junit Assert to detect it. I only see the problem in the console. Arquillian has probably a mode to detect that kind of
container exception but I did not manage to find something useful.
Can you point me to some resource to solve that problem? After that, I'll do the pull request.
Thanks again guys
-
11. Re: Producer Method and java.io.NotSerializableException
alesj Apr 15, 2012 6:50 AM (in response to s.hostettler)First, it only happens on Tomcat.
But not in JBossAS7?
-
12. Re: Producer Method and java.io.NotSerializableException
s.hostettler Apr 16, 2012 3:38 AM (in response to alesj)Pfiou It took me a while to test under JBossAS7.
So to sum up.
WAR on Tomcat : BUG
WAR on JBOSS AS7: No Bug (or I least I do not see anything in the console). I'm not sure that the serialization is forced when JBossAS7 is stopped.
Can you confirm?
-
13. Re: Producer Method and java.io.NotSerializableException
jharting Apr 16, 2012 3:52 AM (in response to s.hostettler)Yes, the difference probably is that Tomcat tries to serialize existing session on shutdown while JBoss AS 7 does not. Nevertheless, the problem would emerge on AS7 the moment it would try to passivate the session (either to save memory or for replication).
Can you verify that upgrading SLF4J fixes the problem?
-
14. Re: Producer Method and java.io.NotSerializableException
jharting Apr 16, 2012 3:54 AM (in response to jharting)FYI, this is the tracking issue: https://issues.jboss.org/browse/WELD-1076