42Lines/wicket-cdi

Injected stateless EJB proxy not serializable

Closed this issue · 4 comments

lsuk commented

Under Glassfish the proxies for injected stateless EJBs are not serializable and are apparently not required to be so by the ejb/cdi specs.
Creating issue after discussion on Wicket users - wicket-cdi NotSerializableException for injected SLSB proxy

A possible solution was proposed in SEAMWICKET-41 to wire a serializable proxy between the injected ejb and the field.

what about using wicketstuff-javaee module to inject EJBs in addition to wicket-cdi?

https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/javaee-inject-parent

you will have to use the annotation provided by wicketstuff-javaee (@ejb?) instead of the standard @Inject to mark EJBs, but other then that i think it should work fine....

lsuk commented

Yes that's what I've been using so far and it works great for EJB injection. I liked the idea of keeping things simple with just one module for EJB+CDI but apart from that I suppose there's no real reason not to use them together.

im thinking thats the best approach going forward. what i like about wicket-cdi is that we allow cdi to perform the injection, instead of having to do what other wicket-ioc modules do - which is walk every field and figure out if it needs to be injected and if it does create a proxy that somehow looks up the dependency from the container.

After talking to Igor on Jira I wanted to address my issues here to his excellent solution.
I was injecting a Stateless Session bean in my wicket page from glassfish and continually getting the serialization exception. Igor suggested that I create a CDI Bean like a SessionScoped bean and inject my EJB into that bean. After doing that my Serialization Exception went away. So I now have this model. Wicket Page Injects a CDI Bean which injects zero or more EJB Objects. In my EJBObjects I have the SessionContext Resource and javamail Session Resource, I have a Resource java.util.Properties defining the user,password and url to the ldap server, which is configured via the Glassfish admin. This pattern is simple and works well with Wicket using Wicket-CDI. Thanks