Looks like a classloader issue.  My guess is that you have the shiro 
jars in the war files, rather than at the same level as the ehcache 
jar?  In order for this to work, both applications would need to load 
the shiro classes from the same classloader.  This probably means 
putting the shiro jars at the server level, the same way as you have 
done ehcache.  (org.apache.shiro.session.Session loading in application 
A != org.apache.shiro.session.Session loaded in application B)

Hope that helps,
Jared

On Fri 06 Jul 2012 07:36:03 AM CDT, Pawel_Piatkowski wrote:
> Hi Jared,
>
> Thank you for your advice.
> I've tried something like this:
>
> /public class EhCacheManagerFactory implements Factory<CacheManager> {
>
>       public CacheManager getInstance() {
>               return CacheManager.create();
>       }
> }/
>
> which should work similar to your solution but when I try to get session
> with conrete id [*sessionIdFromParam*]:
>
> /Subject currentUser = new
> Subject.Builder().sessionId(*sessionIdFromParam*).buildSubject();/
>
> passed by GET parameter I get the following exception:
>
> /java.lang.ClassCastException: org.apache.shiro.session.mgt.SimpleSession
> cannot be cast to org.apache.shiro.session.Session
>
> org.apache.shiro.session.mgt.eis.CachingSessionDAO.getCachedSession(CachingSessionDAO.java:217)
>
> org.apache.shiro.session.mgt.eis.CachingSessionDAO.getCachedSession(CachingSessionDAO.java:202)
>
> org.apache.shiro.session.mgt.eis.CachingSessionDAO.readSession(CachingSessionDAO.java:259)
>
> org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSessionFromDataSource(DefaultSessionManager.java:236)
>
> org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSession(DefaultSessionManager.java:222)
>
> org.apache.shiro.session.mgt.AbstractValidatingSessionManager.doGetSession(AbstractValidatingSessionManager.java:118)
>
> org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupSession(AbstractNativeSessionManager.java:105)
>
> org.apache.shiro.session.mgt.AbstractNativeSessionManager.getSession(AbstractNativeSessionManager.java:97)
>
> org.apache.shiro.mgt.SessionsSecurityManager.getSession(SessionsSecurityManager.java:125)
>
> org.apache.shiro.mgt.DefaultSecurityManager.resolveContextSession(DefaultSecurityManager.java:456)
>
> org.apache.shiro.mgt.DefaultSecurityManager.resolveSession(DefaultSecurityManager.java:442)
>
> org.apache.shiro.mgt.DefaultSecurityManager.createSubject(DefaultSecurityManager.java:338)
>       org.apache.shiro.subject.Subject$Builder.buildSubject(Subject.java:846)
>       pl.compugroup.servlet.SessionServlet.doGet(SessionServlet.java:57)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>
> org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
>
> org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
>
> org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
>
> org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
>
> org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:380)
>
> org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
>
> org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)/
>
> It happens only when I try to retrieve session created in application A from
> application B so it looks that something works here.
>
> I've got such shiro.ini configuration:
>
> /ehCacheManager = pl.compugroup.shiro.EhCacheManagerFactory
> cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
> cacheManager.cacheManager = $ehCacheManager
> cacheManager.cacheManagerConfigFile = classpath:ehcache.xml
> securityManager.cacheManager = $cacheManager
>
> sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager
>
> sessionDAO = org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO
> sessionManager.sessionDAO = $sessionDAO
> securityManager.sessionManager = $sessionManager/
>
> -----
> -----------------------
> Paweł Piątkowski
> http://pl.linkedin.com/in/ppiatkowski
> --
> View this message in context: 
> http://shiro-user.582556.n2.nabble.com/Shiro-and-multiple-wars-within-the-same-Servlet-Container-tp5560737p7577572.html
> Sent from the Shiro User mailing list archive at Nabble.com.


Reply via email to