In theory, yes...

The proxies returned by Weld 1.0.1.SP3 (the version used in Glassfish 3.0.1) 
are serializable, but after serializing and deserializing the proxy, the method 
handler is broken and you get a null pointer exception when invoking any method 
of the proxy. i verified this in a simple test case, independent of Wicket. 
This looks like the problem fixed in https://jira.jboss.org/browse/JASSIST-97, 
though I'm not fully sure that this is exactly the same issue.

Anyway, I patched my Glassfish version with the most recent release of 
Javassist containing the bugfix. With this fix, I already get a 
NotSerializableException from Wicket when the current page is about to be moved 
to the page store:

   protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h 
[class=com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate] <----- 
field that is not serializable

It seems that the stateless session bean implementation is wrapped in at least 
two proxies, one generated by Glassfish (for getting the session bean into the 
CDI context, equivalent to @EJB injection) and another one, generated by Weld 
using Javassist, filling the @Inject injection point in my Wicket component. 
The outer proxy is ok with the newer Javassist version, but the inner proxy 
simply is not serializable because of EJBLocalObjectInvocationHandlerDelegate.

Using @EJB instead of @Inject, I just get the inner proxy, with the same 
problem caused by EJBLocalObjectInvocationHandlerDelegate.

So my impression is that Glassfish simply breaks the contract of my 
serializable session bean interface. On the other hand, I wouldn't be surprised 
if there was a paragraph somewhere in the Java EE specs stating that EJBs shall 
not be serialized by the application (i.e. Wicket) because the container takes 
care of passivation anyway...

Has anybody tried Wicket+CDI+EJB on other app servers? (There aren't so many 
supporting Java EE 6....)

Regards,
Harald


________________________________________
Von: Igor Vaynberg [igor.vaynb...@gmail.com]
Gesendet: Donnerstag, 8. Juli 2010 17:54
An: users@wicket.apache.org
Betreff: Re: AW: Serialization of injected EJBs

im not sure if this is in a CDI spec or not, but afaik Weld will
return serializable proxies when you manually inject objects. so that
should work out of the box.

-igor


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to