You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Harald Wellmann <Ha...@multi-m.de> on 2010/07/07 16:42:58 UTC

Serialization of injected EJBs

I'm using Wicket on Glassfish v3, injecting stateless session beans (using the no-interface view) into my Wicket components.

For a component member

	@Inject
	private Foo foo;

Glassfish generates a proxy which is not serializable, even though my class Foo is.

Now the problem is that Wicket cannot serialize the page containing the given component. I'm not sure whether or not it is legal by the EJB 3.1 spec to have the proxy being not serializable when the underlying class is. Just assuming for the moment this is not a bug in Glassfish, what would be the best way of dealing with this in Wicket?

Detaching the EJBs on serialization and re-injecting them on deserialization might work, but I'm not sure how to do this, and of course I would like that to happen behind the scenes, without having to provide event handlers in each and every component with injected EJBs.

By the way, I'm using a ComponentInstantiationListener from https://wamblee.org/viewvc/wicket-cdi/ to deal with CDI, but the same issue occurs with old style @EJB injection as well.

Any ideas?

Best regards,

Harald


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


Re: AW: Serialization of injected EJBs

Posted by Martin Grigorov <mc...@e-card.bg>.
On Wed, 2010-07-07 at 17:07 +0200, Harald Wellmann wrote:
> Is there any evidence that javaee-inject would solve the problem? The question is not how to inject the EJBs (this works fine with the wicket-cdi lib), but how to serialize the injected proxies.
Yes, javaee-inject uses wicket-ioc which provides the proxy generation
facilities.
This is what you need.
> 
> Regards,
> 
> Harald
> 
> -----Ursprüngliche Nachricht-----
> Von: Major Péter [mailto:majorpetya@sch.bme.hu] 
> Gesendet: Mittwoch, 7. Juli 2010 16:51
> An: users@wicket.apache.org
> Betreff: Re: Serialization of injected EJBs
> 
> Hi,
> 
> you could try to use:
> http://wicketstuff.org/confluence/display/STUFFWIKI/JavaEE+Inject
> 
> Regards,
> Peter
> 
> 2010-07-07 16:42 keltezéssel, Harald Wellmann írta:
> > I'm using Wicket on Glassfish v3, injecting stateless session beans (using the no-interface view) into my Wicket components.
> > 
> > For a component member
> > 
> > 	@Inject
> > 	private Foo foo;
> > 
> > Glassfish generates a proxy which is not serializable, even though my class Foo is.
> > 
> > Now the problem is that Wicket cannot serialize the page containing the given component. I'm not sure whether or not it is legal by the EJB 3.1 spec to have the proxy being not serializable when the underlying class is. Just assuming for the moment this is not a bug in Glassfish, what would be the best way of dealing with this in Wicket?
> > 
> > Detaching the EJBs on serialization and re-injecting them on deserialization might work, but I'm not sure how to do this, and of course I would like that to happen behind the scenes, without having to provide event handlers in each and every component with injected EJBs.
> > 
> > By the way, I'm using a ComponentInstantiationListener from https://wamblee.org/viewvc/wicket-cdi/ to deal with CDI, but the same issue occurs with old style @EJB injection as well.
> > 
> > Any ideas?
> > 
> > Best regards,
> > 
> > Harald
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 



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


AW: AW: Serialization of injected EJBs

Posted by Harald Wellmann <Ha...@multi-m.de>.
Thanks for pointing this out, however, I think it's a related but different issue. I did not notice any classloader problems in my case, and anyway, we deploy our entire application (web pages, EJBs and entity classes) in a single WAR.

Regards,

Harald

-----Ursprüngliche Nachricht-----
Von: kbs [mailto:kbs_kulbhushan@yahoo.com] 
Gesendet: Freitag, 9. Juli 2010 09:17
An: users@wicket.apache.org
Betreff: Re: AW: Serialization of injected EJBs


I am not sure if this is related but AFAIR we faced a similar problem with
GlassFish V2.1 and determined the root cause of this to
https://issues.apache.org/jira/browse/WICKET-2416

The exception stack trace may be different in V3 so I am not sure if it is
same issue.

Regards,
Kulbhushan

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


Re: AW: Serialization of injected EJBs

Posted by kbs <kb...@yahoo.com>.
I am not sure if this is related but AFAIR we faced a similar problem with
GlassFish V2.1 and determined the root cause of this to
https://issues.apache.org/jira/browse/WICKET-2416

The exception stack trace may be different in V3 so I am not sure if it is
same issue.

Regards,
Kulbhushan
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Serialization-of-injected-EJBs-tp2281001p2283172.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: AW: Serialization of injected EJBs

Posted by Igor Vaynberg <ig...@gmail.com>.
in wicket i would only stick to field injection

-igor

On Sat, Jul 10, 2010 at 4:33 AM, Harald Wellmann
<Ha...@multi-m.de> wrote:
> Ok, just wanted to make sure before duplicating any work.
>
> Anyway, using wicket-ioc and looking at wicket-guice, I implemented a small lib (two classes, actually) performing CDI injection on Wicket components, wrapping the reference returned from the CDI BeanManager in a proxy that is serializable and re-injects all injection points using the BeanManager on deserialization.
>
> This was indeed just a few hours' work ;-)
>
> BUT I currently only handle the most frequent case
>
>    @Inject
>    private Foo foo;
>
> Only field injection, no method, constructor or parameter injection, no qualifiers or stereotypes. Getting all that right, including test cases, would easily take a week or two, and the hardest part would not be the implementation itself but understanding all the details of the CDI spec and fighting with problems in the app server. (And I still think this serialization issue is really a bug in Glassfish.)
>
> At any rate, I'd be happy to share my code - would it make sense to create a small subproject wicket-cdi, either in wicket or in wicketstuff? I think this topic is of suffciently general interest, or at least will be, when more projects move to Java EE 6.
>
> Regards,
> Harald
>
>
> ________________________________________
> Von: Igor Vaynberg [igor.vaynberg@gmail.com]
> Gesendet: Freitag, 9. Juli 2010 20:03
> An: users@wicket.apache.org
> Betreff: Re: AW: Serialization of injected EJBs
>
> no, the module is for seam 2.1 which does not use weld.
>
> -igor
>
> On Fri, Jul 9, 2010 at 10:55 AM, Harald Wellmann
> <Ha...@multi-m.de> wrote:
>> And Seam uses CDI/Weld, right? So your module might solve my problems... Is it public?
>>
>> Regards,
>> Harald
>> ________________________________________
>> Von: Igor Vaynberg [igor.vaynberg@gmail.com]
>> Gesendet: Freitag, 9. Juli 2010 18:06
>> An: users@wicket.apache.org
>> Betreff: Re: AW: Serialization of injected EJBs
>>
>> well, i recently wrote a wicket-ioc module for seam and it took me a
>> couple of hours :)
>>
>> -igor
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


AW: AW: Serialization of injected EJBs

Posted by Harald Wellmann <Ha...@multi-m.de>.
Ok, just wanted to make sure before duplicating any work.

Anyway, using wicket-ioc and looking at wicket-guice, I implemented a small lib (two classes, actually) performing CDI injection on Wicket components, wrapping the reference returned from the CDI BeanManager in a proxy that is serializable and re-injects all injection points using the BeanManager on deserialization.

This was indeed just a few hours' work ;-)

BUT I currently only handle the most frequent case

    @Inject
    private Foo foo;

Only field injection, no method, constructor or parameter injection, no qualifiers or stereotypes. Getting all that right, including test cases, would easily take a week or two, and the hardest part would not be the implementation itself but understanding all the details of the CDI spec and fighting with problems in the app server. (And I still think this serialization issue is really a bug in Glassfish.)

At any rate, I'd be happy to share my code - would it make sense to create a small subproject wicket-cdi, either in wicket or in wicketstuff? I think this topic is of suffciently general interest, or at least will be, when more projects move to Java EE 6.

Regards,
Harald


________________________________________
Von: Igor Vaynberg [igor.vaynberg@gmail.com]
Gesendet: Freitag, 9. Juli 2010 20:03
An: users@wicket.apache.org
Betreff: Re: AW: Serialization of injected EJBs

no, the module is for seam 2.1 which does not use weld.

-igor

On Fri, Jul 9, 2010 at 10:55 AM, Harald Wellmann
<Ha...@multi-m.de> wrote:
> And Seam uses CDI/Weld, right? So your module might solve my problems... Is it public?
>
> Regards,
> Harald
> ________________________________________
> Von: Igor Vaynberg [igor.vaynberg@gmail.com]
> Gesendet: Freitag, 9. Juli 2010 18:06
> An: users@wicket.apache.org
> Betreff: Re: AW: Serialization of injected EJBs
>
> well, i recently wrote a wicket-ioc module for seam and it took me a
> couple of hours :)
>
> -igor

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


Re: AW: Serialization of injected EJBs

Posted by James Carman <ja...@carmanconsulting.com>.
The references that are injected are supposed to be serializable per the
spec I believe.  There is the concept of a 'client proxy" or something like
that in the spec that is supposed to be serializable.  Anyway, you are
welcome to use anything that is useful to you.  I haven't worked on it in a
while.

On Jul 10, 2010 7:43 AM, "Harald Wellmann" <Ha...@multi-m.de>
wrote:

Thanks, I'd seen that before.

This code handles CDI injection in Wicket components (which was not the
problem as such) and the conversation scope (which I haven't used so far)
but as far as I can see it does not address any serialization issues with
the injected references.

Regards,
Harald
________________________________________
Von: jcarman@carmanconsulting.com [jcarman@carmanconsulting.com] im Auftrag
von James Carman [james@carmanconsulting.com]
Gesendet: Samstag, 10. Juli 2010 12:35
An: users@wicket.apache.org; korbinian.bachl@whiskyworld.de

Betreff: Re: Serialization of injected EJBs

Here's some work I did. See if it works for you:

http://svn.carmanconsulting.com/public/wicket-cdi...

---------------------------------------------------------------------
To unsubscribe, e-mail: users-...

AW: Serialization of injected EJBs

Posted by Harald Wellmann <Ha...@multi-m.de>.
Thanks, I'd seen that before.

This code handles CDI injection in Wicket components (which was not the problem as such) and the conversation scope (which I haven't used so far) but as far as I can see it does not address any serialization issues with the injected references.

Regards,
Harald
________________________________________
Von: jcarman@carmanconsulting.com [jcarman@carmanconsulting.com] im Auftrag von James Carman [james@carmanconsulting.com]
Gesendet: Samstag, 10. Juli 2010 12:35
An: users@wicket.apache.org; korbinian.bachl@whiskyworld.de
Betreff: Re: Serialization of injected EJBs

Here's some work I did.  See if it works for you:

http://svn.carmanconsulting.com/public/wicket-cdi/trunk/



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


Re: Serialization of injected EJBs

Posted by James Carman <ja...@carmanconsulting.com>.
Here's some work I did.  See if it works for you:

http://svn.carmanconsulting.com/public/wicket-cdi/trunk/


On Sat, Jul 10, 2010 at 4:09 AM, Korbinian Bachl - privat
<ko...@whiskyworld.de> wrote:
> Hi Igor,
>
> as I might hit the problem in next weeks (GF 3.0.1 + EJB + Wicket) i just
> wanted to ask if your code is public and if not if its possible to scheme
> out the actions you did so far?
>
> Best,
>
> Korbinian
>
>
> Am 09.07.10 20:03, schrieb Igor Vaynberg:
>>
>> no, the module is for seam 2.1 which does not use weld.
>>
>> -igor
>>
>> On Fri, Jul 9, 2010 at 10:55 AM, Harald Wellmann
>> <Ha...@multi-m.de>  wrote:
>>>
>>> And Seam uses CDI/Weld, right? So your module might solve my problems...
>>> Is it public?
>>>
>>> Regards,
>>> Harald
>>> ________________________________________
>>> Von: Igor Vaynberg [igor.vaynberg@gmail.com]
>>> Gesendet: Freitag, 9. Juli 2010 18:06
>>> An: users@wicket.apache.org
>>> Betreff: Re: AW: Serialization of injected EJBs
>>>
>>> well, i recently wrote a wicket-ioc module for seam and it took me a
>>> couple of hours :)
>>>
>>> -igor
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Serialization of injected EJBs

Posted by Korbinian Bachl - privat <ko...@whiskyworld.de>.
Hi Igor,

as I might hit the problem in next weeks (GF 3.0.1 + EJB + Wicket) i 
just wanted to ask if your code is public and if not if its possible to 
scheme out the actions you did so far?

Best,

Korbinian


Am 09.07.10 20:03, schrieb Igor Vaynberg:
> no, the module is for seam 2.1 which does not use weld.
>
> -igor
>
> On Fri, Jul 9, 2010 at 10:55 AM, Harald Wellmann
> <Ha...@multi-m.de>  wrote:
>> And Seam uses CDI/Weld, right? So your module might solve my problems... Is it public?
>>
>> Regards,
>> Harald
>> ________________________________________
>> Von: Igor Vaynberg [igor.vaynberg@gmail.com]
>> Gesendet: Freitag, 9. Juli 2010 18:06
>> An: users@wicket.apache.org
>> Betreff: Re: AW: Serialization of injected EJBs
>>
>> well, i recently wrote a wicket-ioc module for seam and it took me a
>> couple of hours :)
>>
>> -igor
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


Re: AW: Serialization of injected EJBs

Posted by Igor Vaynberg <ig...@gmail.com>.
no, the module is for seam 2.1 which does not use weld.

-igor

On Fri, Jul 9, 2010 at 10:55 AM, Harald Wellmann
<Ha...@multi-m.de> wrote:
> And Seam uses CDI/Weld, right? So your module might solve my problems... Is it public?
>
> Regards,
> Harald
> ________________________________________
> Von: Igor Vaynberg [igor.vaynberg@gmail.com]
> Gesendet: Freitag, 9. Juli 2010 18:06
> An: users@wicket.apache.org
> Betreff: Re: AW: Serialization of injected EJBs
>
> well, i recently wrote a wicket-ioc module for seam and it took me a
> couple of hours :)
>
> -igor
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


AW: AW: Serialization of injected EJBs

Posted by Harald Wellmann <Ha...@multi-m.de>.
And Seam uses CDI/Weld, right? So your module might solve my problems... Is it public?

Regards,
Harald
________________________________________
Von: Igor Vaynberg [igor.vaynberg@gmail.com]
Gesendet: Freitag, 9. Juli 2010 18:06
An: users@wicket.apache.org
Betreff: Re: AW: Serialization of injected EJBs

well, i recently wrote a wicket-ioc module for seam and it took me a
couple of hours :)

-igor


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


Re: AW: Serialization of injected EJBs

Posted by Igor Vaynberg <ig...@gmail.com>.
well, i recently wrote a wicket-ioc module for seam and it took me a
couple of hours :)

-igor

On Fri, Jul 9, 2010 at 12:52 AM, Harald Wellmann
<Ha...@multi-m.de> wrote:
> Ok, I see what you mean and I think that would work. Only I'm not so sure about the "couple of hours" (have you looked at CDI BeanManager...?) and with that approach, I would end up having 3 proxies between my Wicket component and my EJB.
>
> Anyway, this is probably faster to implement than waiting for a solution from Glassfish...
>
> Best regards,
> Harald
>
>
> -----Ursprüngliche Nachricht-----
> Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Gesendet: Donnerstag, 8. Juli 2010 21:45
> An: users@wicket.apache.org
> Betreff: Re: AW: Serialization of injected EJBs
>
> hrm, if thats the case you can always use wicket-ioc module to build
> the proxy yourself just like we do for spring and guice, it should
> only be a couple of hours effort.
>
> -igor
>
> On Thu, Jul 8, 2010 at 10:34 AM, Harald Wellmann
> <Ha...@multi-m.de> wrote:
>> 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.vaynberg@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


AW: AW: Serialization of injected EJBs

Posted by Harald Wellmann <Ha...@multi-m.de>.
Ok, I see what you mean and I think that would work. Only I'm not so sure about the "couple of hours" (have you looked at CDI BeanManager...?) and with that approach, I would end up having 3 proxies between my Wicket component and my EJB.

Anyway, this is probably faster to implement than waiting for a solution from Glassfish...

Best regards,
Harald


-----Ursprüngliche Nachricht-----
Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Gesendet: Donnerstag, 8. Juli 2010 21:45
An: users@wicket.apache.org
Betreff: Re: AW: Serialization of injected EJBs

hrm, if thats the case you can always use wicket-ioc module to build
the proxy yourself just like we do for spring and guice, it should
only be a couple of hours effort.

-igor

On Thu, Jul 8, 2010 at 10:34 AM, Harald Wellmann
<Ha...@multi-m.de> wrote:
> 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.vaynberg@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


Re: AW: Serialization of injected EJBs

Posted by Igor Vaynberg <ig...@gmail.com>.
hrm, if thats the case you can always use wicket-ioc module to build
the proxy yourself just like we do for spring and guice, it should
only be a couple of hours effort.

-igor

On Thu, Jul 8, 2010 at 10:34 AM, Harald Wellmann
<Ha...@multi-m.de> wrote:
> 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.vaynberg@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


AW: AW: Serialization of injected EJBs

Posted by Harald Wellmann <Ha...@multi-m.de>.
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.vaynberg@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AW: Serialization of injected EJBs

Posted by Igor Vaynberg <ig...@gmail.com>.
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

On Thu, Jul 8, 2010 at 1:41 AM, Harald Wellmann
<Ha...@multi-m.de> wrote:
> Yes, @EJB is still available, and it is still required in some cases. But the general approach to injection has changed with CDI. See http://seamframework.org/Community/InjectingWithEJBOrInject for a discussion.
>
> My original question is about how to use Wicket with CDI (injecting EJBs and other beans), and your suggestion is not to use CDI, which does not really solve the problem...
>
> By the way, the nice thing about @Inject is that you no longer have to use JNDI lookups or bean names in @EJB annotations.
>
> And the specific problem is NOT that @Inject does not not work for EJBs, but the injected proxies fail to serialize properly.
>
> If I understand the javaee-inject implementation correctly, it takes care not to serialize proxies but replaces them by references on serialization, looking up the same reference again on deserialization.
>
> I suppose my problem would be solved if the CDI InjectionTarget were using this approach, but this is a CDI implementation detail and out of my control.
>
> Anybody else out there using Wicket+CDI+EJB? Have you come across similar problems?
>
> Best regards,
>
> Harald
>
> -----Ursprüngliche Nachricht-----
> Von: Major Péter [mailto:majorpetya@sch.bme.hu]
> Gesendet: Mittwoch, 7. Juli 2010 19:43
> An: users@wicket.apache.org
> Betreff: Re: AW: Serialization of injected EJBs
>
> Nope, it does not support CDI. AFAIK @EJB is not deprecated or
> old-style, and it's still available in Java EE 6. The thread was about
> injecting EJB's and JavaEE Inject does exactly that.
> You can always use lookups for your beans/CDI stuff...
>
> Regards,
> Peter
>
> 2010-07-07 19:34 keltezéssel, Harald Wellmann írta:
>> Does javaee-inject support CDI at all? I cannot find any @Inject annotations in the examples you mentioned, they all seem to be in Java EE 5 style, not Java EE 6.
>>
>> Regards,
>>
>> Harald
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


AW: AW: Serialization of injected EJBs

Posted by Harald Wellmann <Ha...@multi-m.de>.
Yes, @EJB is still available, and it is still required in some cases. But the general approach to injection has changed with CDI. See http://seamframework.org/Community/InjectingWithEJBOrInject for a discussion.

My original question is about how to use Wicket with CDI (injecting EJBs and other beans), and your suggestion is not to use CDI, which does not really solve the problem...

By the way, the nice thing about @Inject is that you no longer have to use JNDI lookups or bean names in @EJB annotations.

And the specific problem is NOT that @Inject does not not work for EJBs, but the injected proxies fail to serialize properly.

If I understand the javaee-inject implementation correctly, it takes care not to serialize proxies but replaces them by references on serialization, looking up the same reference again on deserialization.

I suppose my problem would be solved if the CDI InjectionTarget were using this approach, but this is a CDI implementation detail and out of my control.

Anybody else out there using Wicket+CDI+EJB? Have you come across similar problems?

Best regards,

Harald

-----Ursprüngliche Nachricht-----
Von: Major Péter [mailto:majorpetya@sch.bme.hu] 
Gesendet: Mittwoch, 7. Juli 2010 19:43
An: users@wicket.apache.org
Betreff: Re: AW: Serialization of injected EJBs

Nope, it does not support CDI. AFAIK @EJB is not deprecated or
old-style, and it's still available in Java EE 6. The thread was about
injecting EJB's and JavaEE Inject does exactly that.
You can always use lookups for your beans/CDI stuff...

Regards,
Peter

2010-07-07 19:34 keltezéssel, Harald Wellmann írta:
> Does javaee-inject support CDI at all? I cannot find any @Inject annotations in the examples you mentioned, they all seem to be in Java EE 5 style, not Java EE 6.
> 
> Regards,
> 
> Harald

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


Re: AW: Serialization of injected EJBs

Posted by Major Péter <ma...@sch.bme.hu>.
Nope, it does not support CDI. AFAIK @EJB is not deprecated or
old-style, and it's still available in Java EE 6. The thread was about
injecting EJB's and JavaEE Inject does exactly that.
You can always use lookups for your beans/CDI stuff...

Regards,
Peter

2010-07-07 19:34 keltezéssel, Harald Wellmann írta:
> Does javaee-inject support CDI at all? I cannot find any @Inject annotations in the examples you mentioned, they all seem to be in Java EE 5 style, not Java EE 6.
> 
> Regards,
> 
> Harald
> ________________________________________
> Von: Major Péter [majorpetya@sch.bme.hu]
> Gesendet: Mittwoch, 7. Juli 2010 18:37
> An: users@wicket.apache.org
> Betreff: Re: Serialization of injected EJBs
> 
> I'm using the lib in production with GlassFish v3 and for developing
> with GlassFish 3.0.1, and haven't seen this exception so far for my
> EJB's. Something is weird with your EJB... Could you check the
> javaee-inject-examples (1.4.10-SNAPSHOT) project with the same container?
> 
> Thanks,
> Peter

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


AW: Serialization of injected EJBs

Posted by Harald Wellmann <Ha...@multi-m.de>.
Does javaee-inject support CDI at all? I cannot find any @Inject annotations in the examples you mentioned, they all seem to be in Java EE 5 style, not Java EE 6.

Regards,

Harald
________________________________________
Von: Major Péter [majorpetya@sch.bme.hu]
Gesendet: Mittwoch, 7. Juli 2010 18:37
An: users@wicket.apache.org
Betreff: Re: Serialization of injected EJBs

I'm using the lib in production with GlassFish v3 and for developing
with GlassFish 3.0.1, and haven't seen this exception so far for my
EJB's. Something is weird with your EJB... Could you check the
javaee-inject-examples (1.4.10-SNAPSHOT) project with the same container?

Thanks,
Peter

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


Re: Serialization of injected EJBs

Posted by Major Péter <ma...@sch.bme.hu>.
I'm using the lib in production with GlassFish v3 and for developing
with GlassFish 3.0.1, and haven't seen this exception so far for my
EJB's. Something is weird with your EJB... Could you check the
javaee-inject-examples (1.4.10-SNAPSHOT) project with the same container?

Thanks,
Peter

2010-07-07 18:12 keltezéssel, Harald Wellmann írta:
> Hmmm, has anybody tried this on Glassfish? The exception I currently get is:
> 
> org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException: Unable to serialize class: com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate
> 
> protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h [class=com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate] <----- field that is not serializable
> 
> So it seems it's not the proxy itself that cannot be serialized but some delegate generated by Glassfish which is not serializable (even though my implementation class is).
> 
> Regards,
> 
> Harald

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


AW: AW: Serialization of injected EJBs

Posted by Harald Wellmann <Ha...@multi-m.de>.
Hmmm, has anybody tried this on Glassfish? The exception I currently get is:

org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException: Unable to serialize class: com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate

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

So it seems it's not the proxy itself that cannot be serialized but some delegate generated by Glassfish which is not serializable (even though my implementation class is).

Regards,

Harald



-----Ursprüngliche Nachricht-----
Von: Major Péter [mailto:majorpetya@sch.bme.hu] 
Gesendet: Mittwoch, 7. Juli 2010 17:12
An: users@wicket.apache.org
Betreff: Re: AW: Serialization of injected EJBs

JavaEE Inject generates a serializable proxy, so the injected references
could be stored into session without problem.

Peter

2010-07-07 17:07 keltezéssel, Harald Wellmann írta:
> Is there any evidence that javaee-inject would solve the problem? The question is not how to inject the EJBs (this works fine with the wicket-cdi lib), but how to serialize the injected proxies.
> 
> Regards,
> 
> Harald
> 
> -----Ursprüngliche Nachricht-----
> Von: Major Péter [mailto:majorpetya@sch.bme.hu] 
> Gesendet: Mittwoch, 7. Juli 2010 16:51
> An: users@wicket.apache.org
> Betreff: Re: Serialization of injected EJBs
> 
> Hi,
> 
> you could try to use:
> http://wicketstuff.org/confluence/display/STUFFWIKI/JavaEE+Inject
> 
> Regards,
> Peter
> 
> 2010-07-07 16:42 keltezéssel, Harald Wellmann írta:
>> I'm using Wicket on Glassfish v3, injecting stateless session beans (using the no-interface view) into my Wicket components.
>>
>> For a component member
>>
>> 	@Inject
>> 	private Foo foo;
>>
>> Glassfish generates a proxy which is not serializable, even though my class Foo is.
>>
>> Now the problem is that Wicket cannot serialize the page containing the given component. I'm not sure whether or not it is legal by the EJB 3.1 spec to have the proxy being not serializable when the underlying class is. Just assuming for the moment this is not a bug in Glassfish, what would be the best way of dealing with this in Wicket?
>>
>> Detaching the EJBs on serialization and re-injecting them on deserialization might work, but I'm not sure how to do this, and of course I would like that to happen behind the scenes, without having to provide event handlers in each and every component with injected EJBs.
>>
>> By the way, I'm using a ComponentInstantiationListener from https://wamblee.org/viewvc/wicket-cdi/ to deal with CDI, but the same issue occurs with old style @EJB injection as well.
>>
>> Any ideas?
>>
>> Best regards,
>>
>> Harald

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


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


Re: AW: Serialization of injected EJBs

Posted by Major Péter <ma...@sch.bme.hu>.
JavaEE Inject generates a serializable proxy, so the injected references
could be stored into session without problem.

Peter

2010-07-07 17:07 keltezéssel, Harald Wellmann írta:
> Is there any evidence that javaee-inject would solve the problem? The question is not how to inject the EJBs (this works fine with the wicket-cdi lib), but how to serialize the injected proxies.
> 
> Regards,
> 
> Harald
> 
> -----Ursprüngliche Nachricht-----
> Von: Major Péter [mailto:majorpetya@sch.bme.hu] 
> Gesendet: Mittwoch, 7. Juli 2010 16:51
> An: users@wicket.apache.org
> Betreff: Re: Serialization of injected EJBs
> 
> Hi,
> 
> you could try to use:
> http://wicketstuff.org/confluence/display/STUFFWIKI/JavaEE+Inject
> 
> Regards,
> Peter
> 
> 2010-07-07 16:42 keltezéssel, Harald Wellmann írta:
>> I'm using Wicket on Glassfish v3, injecting stateless session beans (using the no-interface view) into my Wicket components.
>>
>> For a component member
>>
>> 	@Inject
>> 	private Foo foo;
>>
>> Glassfish generates a proxy which is not serializable, even though my class Foo is.
>>
>> Now the problem is that Wicket cannot serialize the page containing the given component. I'm not sure whether or not it is legal by the EJB 3.1 spec to have the proxy being not serializable when the underlying class is. Just assuming for the moment this is not a bug in Glassfish, what would be the best way of dealing with this in Wicket?
>>
>> Detaching the EJBs on serialization and re-injecting them on deserialization might work, but I'm not sure how to do this, and of course I would like that to happen behind the scenes, without having to provide event handlers in each and every component with injected EJBs.
>>
>> By the way, I'm using a ComponentInstantiationListener from https://wamblee.org/viewvc/wicket-cdi/ to deal with CDI, but the same issue occurs with old style @EJB injection as well.
>>
>> Any ideas?
>>
>> Best regards,
>>
>> Harald

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


AW: Serialization of injected EJBs

Posted by Harald Wellmann <Ha...@multi-m.de>.
Is there any evidence that javaee-inject would solve the problem? The question is not how to inject the EJBs (this works fine with the wicket-cdi lib), but how to serialize the injected proxies.

Regards,

Harald

-----Ursprüngliche Nachricht-----
Von: Major Péter [mailto:majorpetya@sch.bme.hu] 
Gesendet: Mittwoch, 7. Juli 2010 16:51
An: users@wicket.apache.org
Betreff: Re: Serialization of injected EJBs

Hi,

you could try to use:
http://wicketstuff.org/confluence/display/STUFFWIKI/JavaEE+Inject

Regards,
Peter

2010-07-07 16:42 keltezéssel, Harald Wellmann írta:
> I'm using Wicket on Glassfish v3, injecting stateless session beans (using the no-interface view) into my Wicket components.
> 
> For a component member
> 
> 	@Inject
> 	private Foo foo;
> 
> Glassfish generates a proxy which is not serializable, even though my class Foo is.
> 
> Now the problem is that Wicket cannot serialize the page containing the given component. I'm not sure whether or not it is legal by the EJB 3.1 spec to have the proxy being not serializable when the underlying class is. Just assuming for the moment this is not a bug in Glassfish, what would be the best way of dealing with this in Wicket?
> 
> Detaching the EJBs on serialization and re-injecting them on deserialization might work, but I'm not sure how to do this, and of course I would like that to happen behind the scenes, without having to provide event handlers in each and every component with injected EJBs.
> 
> By the way, I'm using a ComponentInstantiationListener from https://wamblee.org/viewvc/wicket-cdi/ to deal with CDI, but the same issue occurs with old style @EJB injection as well.
> 
> Any ideas?
> 
> Best regards,
> 
> Harald

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


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


Re: Serialization of injected EJBs

Posted by Major Péter <ma...@sch.bme.hu>.
Hi,

you could try to use:
http://wicketstuff.org/confluence/display/STUFFWIKI/JavaEE+Inject

Regards,
Peter

2010-07-07 16:42 keltezéssel, Harald Wellmann írta:
> I'm using Wicket on Glassfish v3, injecting stateless session beans (using the no-interface view) into my Wicket components.
> 
> For a component member
> 
> 	@Inject
> 	private Foo foo;
> 
> Glassfish generates a proxy which is not serializable, even though my class Foo is.
> 
> Now the problem is that Wicket cannot serialize the page containing the given component. I'm not sure whether or not it is legal by the EJB 3.1 spec to have the proxy being not serializable when the underlying class is. Just assuming for the moment this is not a bug in Glassfish, what would be the best way of dealing with this in Wicket?
> 
> Detaching the EJBs on serialization and re-injecting them on deserialization might work, but I'm not sure how to do this, and of course I would like that to happen behind the scenes, without having to provide event handlers in each and every component with injected EJBs.
> 
> By the way, I'm using a ComponentInstantiationListener from https://wamblee.org/viewvc/wicket-cdi/ to deal with CDI, but the same issue occurs with old style @EJB injection as well.
> 
> Any ideas?
> 
> Best regards,
> 
> Harald

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