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:blmulholl...@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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



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

Reply via email to