You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Entropy <bl...@gmail.com> on 2013/06/03 15:00:35 UTC

Injecting proxy services in page.

We are doing the "annotation based approach" described in this link
(https://cwiki.apache.org/WICKET/spring.html).  At least, we think we are.

We get:
[6/3/13 8:26:00:907 EDT] 00000023 SystemOut     O ERROR [WebContainer : 0]
(RequestCycle.java:1521) - Could not deserialize object using
`org.apache.wicket.util.io.IObjectStreamFactory$DefaultObjectStreamFactory`
object factory
java.lang.RuntimeException: Could not deserialize object using
`org.apache.wicket.util.io.IObjectStreamFactory$DefaultObjectStreamFactory`
object factory
	at org.apache.wicket.util.lang.Objects.byteArrayToObject(Objects.java:435)
	at
org.apache.wicket.protocol.http.pagestore.AbstractPageStore.deserializePage(AbstractPageStore.java:234)
	at
org.apache.wicket.protocol.http.pagestore.DiskPageStore.getPage(DiskPageStore.java:735)
	at
org.apache.wicket.protocol.http.SecondLevelCacheSessionStore$SecondLevelCachePageMap.get(SecondLevelCacheSessionStore.java:310)
	at org.apache.wicket.Session.getPage(Session.java:779)
	at
org.apache.wicket.request.AbstractRequestCycleProcessor.resolveRenderedPage(AbstractRequestCycleProcessor.java:458)
	at
org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:144)
	at org.apache.wicket.RequestCycle.step(RequestCycle.java:1310)
	at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
	at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
	at
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
	at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
	at
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
[trimmed for brevity]
Caused by: 
*java.io.InvalidClassException: gov.usdoj.afms.umc.services.LogTransService;
could not resolve class [gov.usdoj.afms.umc.services.LogTransService] when
deserializing proxy*	at
org.apache.wicket.proxy.LazyInitProxyFactory$ProxyReplacement.readResolve(LazyInitProxyFactory.java:236)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[trimmed for brevity]
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:365)
	at org.apache.wicket.util.lang.Objects.byteArrayToObject(Objects.java:413)
	... 39 more

I thought this might be because that particular service is in the parent
page object and annotated there as well, but I moved it to the child class
and saw no change in behavior.  It is a hibernate service and is annotated
in the page like so:

	@SpringBean(name="LogTransService")
	private LogTransService userTransService;	

The exception happens when I go to the page, do a few things (which involve
submitting and redisplaying the page), and then hit the browser back button. 
This, as I understand it, causes wicket to deserialize the page from memory. 
But shouldn't it see the @SpringBean and re-inject a new service?

Out app object does this:
	    addComponentInstantiationListener(new SpringComponentInjector(this,
ctx, true));

Ideas?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Injecting-proxy-services-in-page-tp4659209.html
Sent from the Users forum 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: Injecting proxy services in page.

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Hi,

I don't use Spring, so I can't help you specifically. However, there is 
a chapter about integration with Spring in the free wicket guide here:
https://code.google.com/p/wicket-guide/
(chapter 17.2)

On 03/06/2013 9:00 AM, Entropy wrote:
> We are doing the "annotation based approach" described in this link
> (https://cwiki.apache.org/WICKET/spring.html).  At least, we think we are.
>
> We get:
> [6/3/13 8:26:00:907 EDT] 00000023 SystemOut     O ERROR [WebContainer : 0]
> (RequestCycle.java:1521) - Could not deserialize object using
> `org.apache.wicket.util.io.IObjectStreamFactory$DefaultObjectStreamFactory`
> object factory
> java.lang.RuntimeException: Could not deserialize object using
> `org.apache.wicket.util.io.IObjectStreamFactory$DefaultObjectStreamFactory`
> object factory
> 	at org.apache.wicket.util.lang.Objects.byteArrayToObject(Objects.java:435)
> 	at
> org.apache.wicket.protocol.http.pagestore.AbstractPageStore.deserializePage(AbstractPageStore.java:234)
> 	at
> org.apache.wicket.protocol.http.pagestore.DiskPageStore.getPage(DiskPageStore.java:735)
> 	at
> org.apache.wicket.protocol.http.SecondLevelCacheSessionStore$SecondLevelCachePageMap.get(SecondLevelCacheSessionStore.java:310)
> 	at org.apache.wicket.Session.getPage(Session.java:779)
> 	at
> org.apache.wicket.request.AbstractRequestCycleProcessor.resolveRenderedPage(AbstractRequestCycleProcessor.java:458)
> 	at
> org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:144)
> 	at org.apache.wicket.RequestCycle.step(RequestCycle.java:1310)
> 	at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
> 	at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
> 	at
> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
> 	at
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
> 	at
> com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
> [trimmed for brevity]
> Caused by:
> *java.io.InvalidClassException: gov.usdoj.afms.umc.services.LogTransService;
> could not resolve class [gov.usdoj.afms.umc.services.LogTransService] when
> deserializing proxy*	at
> org.apache.wicket.proxy.LazyInitProxyFactory$ProxyReplacement.readResolve(LazyInitProxyFactory.java:236)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [trimmed for brevity]
> 	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:365)
> 	at org.apache.wicket.util.lang.Objects.byteArrayToObject(Objects.java:413)
> 	... 39 more
>
> I thought this might be because that particular service is in the parent
> page object and annotated there as well, but I moved it to the child class
> and saw no change in behavior.  It is a hibernate service and is annotated
> in the page like so:
>
> 	@SpringBean(name="LogTransService")
> 	private LogTransService userTransService;	
>
> The exception happens when I go to the page, do a few things (which involve
> submitting and redisplaying the page), and then hit the browser back button.
> This, as I understand it, causes wicket to deserialize the page from memory.
> But shouldn't it see the @SpringBean and re-inject a new service?
>
> Out app object does this:
> 	    addComponentInstantiationListener(new SpringComponentInjector(this,
> ctx, true));
>
> Ideas?
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Injecting-proxy-services-in-page-tp4659209.html
> Sent from the Users forum 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
>


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


Re: Injecting proxy services in page.

Posted by "martin.dilger" <ma...@googlemail.com>.
To be honest, I dont understand exactly what the Problem is.
If you work with Spring-Beans, they are normally safe to serialize, as its
only the proxy. 
We´ve done this all the time (even with older wicket versions) without any
problems.
It looks like you have some Classpath-Issue here. The Service-Class you
mentioned, is that an Interface or do you work with the concrete
Implementation. I got similar Issues when working with
Implementation-Classes and CGLib.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Injecting-proxy-services-in-page-tp4659209p4659580.html
Sent from the Users forum 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: Injecting proxy services in page.

Posted by eugenebalt <eu...@yahoo.com>.
We've heard that there is a fix for this available in Wicket 1.5.

However, we are stuck with Wicket 1.4.7 and cannot upgrade, for various
reasons. (We're also already using the AnnotationConfigWebApplicationContext
referred to in the previous post.)

Are there any other workarounds for this problem? Is it OK to make the
problem classes "implement Serializable" just to move past this issue (even
if they are injected with the @SpringBean, and are service classes), or
should we try other workarounds?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Injecting-proxy-services-in-page-tp4659209p4659563.html
Sent from the Users forum 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: Injecting proxy services in page.

Posted by harmoniaa <ed...@nitorcreations.com>.
If you are already using XmlWebApplicationContext (extends
AbstractRefreshableWebApplicationContext like
AnnotationConfigWebApplicationContext) that is probably not the issue, but
you can set the context class in your web.xml like this:

<servlet>
...
    <init-param>
        <param-name>contextClass</param-name>
        <param-value>
           
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
        </param-value>
    </init-param>
</servlet>




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Injecting-proxy-services-in-page-tp4659209p4659252.html
Sent from the Users forum 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: Injecting proxy services in page.

Posted by Entropy <bl...@gmail.com>.
At the risk of turning this into a Spring discussion on a Wicket forum, how
does one control that?  I would like to try your suggestion, but am not sure
what knob to twist.

We just implement ApplicationContextAware, and point to our spring config
file in web.xml.  I don't set anywhere asking for a particular KIND of
appcontext to be used.  When it hands it to me, it is
XmlWebApplicationContext.  



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Injecting-proxy-services-in-page-tp4659209p4659245.html
Sent from the Users forum 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: Injecting proxy services in page.

Posted by Edvard Fonsell <ed...@nitorcreations.com>.
Hi,

I'm not sure if this is the issue here but I've seen similar problems 
when I used AnnotationConfigApplicationContext as a Spring context, but 
got it working by using AnnotationConfig*Web*ApplicationContext.

br, Edvard

On 03.06.2013 17:19, Paul Bors wrote:
> I find it easier to configure Spring via the XML rather than code.
>
> Hence I have my applicationContext.xml inside my war's WEB-INF/classes/ with
> all the bean definitions and then configure Wicket via the context specific
> configuration from inside my web.xml:
>
>      <!--
>          There are three means to configure Wickets configuration mode and
> they
>          are tested in the order given.
>
>          1) A system property: -Dwicket.configuration
>          2) servlet specific <init-param>
>          3) context specific <context-param>
>
>          The value might be either "development" (reloading when templates
> change) or
>          "deployment". If no configuration is found, "development" is the
> default. -->
>
>      <context-param>
>          <param-name>contextConfigLocation</param-name>
>          <param-value>classpath:applicationContext.xml</param-value>
>      </context-param>
>
>      <filter>
>          <filter-name>persistence</filter-name>
>
> <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFil
> ter</filter-class>
>          <init-param>
>              <param-name>entityManagerFactoryBeanName</param-name>
>              <param-value>entityManagerFactory</param-value>
>          </init-param>
>          <init-param>
>              <param-name>singleSession</param-name>
>              <param-value>true</param-value>
>          </init-param>
>      </filter>
>
>      ...
>
>      <listener>
>
> <listener-class>org.springframework.web.context.ContextLoaderListener</liste
> ner-class>
>      </listener>
>
> Whenever I need to inject a service I use Wicket's @SpringBean.
>
> ~ Thank you,
>    Paul Bors
>
> -----Original Message-----
> From: Entropy [mailto:blmulholland@gmail.com]
> Sent: Monday, June 03, 2013 9:01 AM
> To: users@wicket.apache.org
> Subject: Injecting proxy services in page.
>
> We are doing the "annotation based approach" described in this link
> (https://cwiki.apache.org/WICKET/spring.html).  At least, we think we are.
>
> We get:
> [6/3/13 8:26:00:907 EDT] 00000023 SystemOut     O ERROR [WebContainer : 0]
> (RequestCycle.java:1521) - Could not deserialize object using
> `org.apache.wicket.util.io.IObjectStreamFactory$DefaultObjectStreamFactory`
> object factory
> java.lang.RuntimeException: Could not deserialize object using
> `org.apache.wicket.util.io.IObjectStreamFactory$DefaultObjectStreamFactory`
> object factory
> 	at
> org.apache.wicket.util.lang.Objects.byteArrayToObject(Objects.java:435)
> 	at
> org.apache.wicket.protocol.http.pagestore.AbstractPageStore.deserializePage(
> AbstractPageStore.java:234)
> 	at
> org.apache.wicket.protocol.http.pagestore.DiskPageStore.getPage(DiskPageStor
> e.java:735)
> 	at
> org.apache.wicket.protocol.http.SecondLevelCacheSessionStore$SecondLevelCach
> ePageMap.get(SecondLevelCacheSessionStore.java:310)
> 	at org.apache.wicket.Session.getPage(Session.java:779)
> 	at
> org.apache.wicket.request.AbstractRequestCycleProcessor.resolveRenderedPage(
> AbstractRequestCycleProcessor.java:458)
> 	at
> org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestC
> ycleProcessor.java:144)
> 	at org.apache.wicket.RequestCycle.step(RequestCycle.java:1310)
> 	at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
> 	at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
> 	at
> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
> 	at
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
> 	at
> com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstance
> Wrapper.java:188)
> [trimmed for brevity]
> Caused by:
> *java.io.InvalidClassException: gov.usdoj.afms.umc.services.LogTransService;
> could not resolve class [gov.usdoj.afms.umc.services.LogTransService] when
> deserializing proxy*	at
> org.apache.wicket.proxy.LazyInitProxyFactory$ProxyReplacement.readResolve(La
> zyInitProxyFactory.java:236)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [trimmed for brevity]
> 	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:365)
> 	at
> org.apache.wicket.util.lang.Objects.byteArrayToObject(Objects.java:413)
> 	... 39 more
>
> I thought this might be because that particular service is in the parent
> page object and annotated there as well, but I moved it to the child class
> and saw no change in behavior.  It is a hibernate service and is annotated
> in the page like so:
>
> 	@SpringBean(name="LogTransService")
> 	private LogTransService userTransService;	
>
> The exception happens when I go to the page, do a few things (which involve
> submitting and redisplaying the page), and then hit the browser back button.
>
> This, as I understand it, causes wicket to deserialize the page from memory.
>
> But shouldn't it see the @SpringBean and re-inject a new service?
>
> Out app object does this:
> 	    addComponentInstantiationListener(new
> SpringComponentInjector(this, ctx, true));
>
> Ideas?
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Injecting-proxy-services-in-page-
> tp4659209.html
> Sent from the Users forum 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
>
>
>
> ---------------------------------------------------------------------
> 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: Injecting proxy services in page.

Posted by Paul Bors <pa...@bors.ws>.
I find it easier to configure Spring via the XML rather than code.

Hence I have my applicationContext.xml inside my war's WEB-INF/classes/ with
all the bean definitions and then configure Wicket via the context specific
configuration from inside my web.xml:

    <!--
        There are three means to configure Wickets configuration mode and
they 
        are tested in the order given.
        
        1) A system property: -Dwicket.configuration 
        2) servlet specific <init-param> 
        3) context specific <context-param>
        
        The value might be either "development" (reloading when templates
change) or 
        "deployment". If no configuration is found, "development" is the
default. -->
        
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>

    <filter>
        <filter-name>persistence</filter-name>
 
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFil
ter</filter-class>
        <init-param>
            <param-name>entityManagerFactoryBeanName</param-name>
            <param-value>entityManagerFactory</param-value>
        </init-param>
        <init-param>
            <param-name>singleSession</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    ...

    <listener>
 
<listener-class>org.springframework.web.context.ContextLoaderListener</liste
ner-class>
    </listener>

Whenever I need to inject a service I use Wicket's @SpringBean.

~ Thank you,
  Paul Bors

-----Original Message-----
From: Entropy [mailto:blmulholland@gmail.com] 
Sent: Monday, June 03, 2013 9:01 AM
To: users@wicket.apache.org
Subject: Injecting proxy services in page.

We are doing the "annotation based approach" described in this link
(https://cwiki.apache.org/WICKET/spring.html).  At least, we think we are.

We get:
[6/3/13 8:26:00:907 EDT] 00000023 SystemOut     O ERROR [WebContainer : 0]
(RequestCycle.java:1521) - Could not deserialize object using
`org.apache.wicket.util.io.IObjectStreamFactory$DefaultObjectStreamFactory`
object factory
java.lang.RuntimeException: Could not deserialize object using
`org.apache.wicket.util.io.IObjectStreamFactory$DefaultObjectStreamFactory`
object factory
	at
org.apache.wicket.util.lang.Objects.byteArrayToObject(Objects.java:435)
	at
org.apache.wicket.protocol.http.pagestore.AbstractPageStore.deserializePage(
AbstractPageStore.java:234)
	at
org.apache.wicket.protocol.http.pagestore.DiskPageStore.getPage(DiskPageStor
e.java:735)
	at
org.apache.wicket.protocol.http.SecondLevelCacheSessionStore$SecondLevelCach
ePageMap.get(SecondLevelCacheSessionStore.java:310)
	at org.apache.wicket.Session.getPage(Session.java:779)
	at
org.apache.wicket.request.AbstractRequestCycleProcessor.resolveRenderedPage(
AbstractRequestCycleProcessor.java:458)
	at
org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestC
ycleProcessor.java:144)
	at org.apache.wicket.RequestCycle.step(RequestCycle.java:1310)
	at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
	at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
	at
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
	at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
	at
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstance
Wrapper.java:188)
[trimmed for brevity]
Caused by: 
*java.io.InvalidClassException: gov.usdoj.afms.umc.services.LogTransService;
could not resolve class [gov.usdoj.afms.umc.services.LogTransService] when
deserializing proxy*	at
org.apache.wicket.proxy.LazyInitProxyFactory$ProxyReplacement.readResolve(La
zyInitProxyFactory.java:236)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[trimmed for brevity]
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:365)
	at
org.apache.wicket.util.lang.Objects.byteArrayToObject(Objects.java:413)
	... 39 more

I thought this might be because that particular service is in the parent
page object and annotated there as well, but I moved it to the child class
and saw no change in behavior.  It is a hibernate service and is annotated
in the page like so:

	@SpringBean(name="LogTransService")
	private LogTransService userTransService;	

The exception happens when I go to the page, do a few things (which involve
submitting and redisplaying the page), and then hit the browser back button.

This, as I understand it, causes wicket to deserialize the page from memory.

But shouldn't it see the @SpringBean and re-inject a new service?

Out app object does this:
	    addComponentInstantiationListener(new
SpringComponentInjector(this, ctx, true));

Ideas?



--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Injecting-proxy-services-in-page-
tp4659209.html
Sent from the Users forum 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



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