You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com> on 2011/11/04 02:15:00 UTC

Why would this cause an error, session sharing and session classcast issues

Using wicket 1.4.13 (yea, I know I need to upgrade)
 
I am getting a classcastexception error on wicket session classes with
session sharing between webapps.  This feature is supported by our web
application server, IBM WebSphere
 
Most of the time this works fine but for some reason, we get the error.
 
Here is the setup.
 
WebApp1:
 
web.xml:
 
   <servlet-mapping>
   <servlet-name>WebApp1</servlet-name>
   <url-pattern>/WebApp1/*</url-pattern>
   </servlet-mapping>
 
WebApp2:
 
web.xml:
 
   <servlet-mapping>
   <servlet-name>WebApp2</servlet-name>
   <url-pattern>/WebApp2/*</url-pattern>
   </servlet-mapping>
 
 <servlet>
  <servlet-name>WebApp2</servlet-name>
 
<servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-cl
ass>
 </servlet>
...
 
When I look at the session attributes, I get a list like this:  There
are distinct instances of wicket sessions for the two applications.
 
wicket:WebApp1:session com.WebApp1Session@760e760e
<ma...@760e760e> 
wicket:WebApp2:session com.WebApp2Session@560e760e
<ma...@560e760e> 
 
But for some reason, if a user visits WebApp1 and then WebApp2,  a call
to:
 
Java code from WebApp1
 
(WebApp2Session) Session.get():
 
That code above will generate a classcastexception.
 
What do you think could be going on?  Why would it work most of the time
but why would I get the error some of the time.  How does Session.get()
work?
 
My only theory is that there is some kind of static class variable
within wicket that is shared between the two web apps that is the
causing some kind of issue.