Manikandan Thiagarajan
asked on
Please solve my error in ehcache
Aug 24, 2012 11:02:03 AM org.apache.catalina.core.S tandardWra pperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastExcepti on: net.sf.ehcache.Element cannot be cast to javax.servlet.http.HttpSes sion
at com.sm.GlobalCacheDataStor e2.getChil dSessionOb j(GlobalCa cheDataSto re2.java:8 4)
at org.apache.jsp.moreCourseI nfo2_jsp._ jspService (moreCours eInfo2_jsp .java:105)
at org.apache.jasper.runtime. HttpJspBas e.service( HttpJspBas e.java:70)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 717)
at org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:3 77)
at org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:313)
at org.apache.jasper.servlet. JspServlet .service(J spServlet. java:260)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 717)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:290 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:2 06)
at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:233)
at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:191)
at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:127 )
at org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:102 )
at org.apache.catalina.core.S tandardEng ineValve.i nvoke(Stan dardEngine Valve.java :109)
at org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:298)
at org.apache.coyote.http11.H ttp11Proce ssor.proce ss(Http11P rocessor.j ava:852)
at org.apache.coyote.http11.H ttp11Proto col$Http11 Connection Handler.pr ocess(Http 11Protocol .java:588)
at org.apache.tomcat.util.net .JIoEndpoi nt$Worker. run(JIoEnd point.java :489)
at java.lang.Thread.run(Threa d.java:662 )
this is my code
public static HttpSession getChildSessionObj(String sessID)
{
widgetCache = cacheManager.getEhcache( "widgets" );
Element element = widgetCache.get( sessID );
if( element != null )
{
// Get the value out of the element and cast it to a Widget
return (HttpSession) element.getValue();
}
return null;
}
i am calling here
HttpSession curSess;
if(curSessId!=null)
{
GlobalCacheDataStore2.setC hildSessio nIdForPare ntSessionI d(parentSe ssionId, curSessId);
curSess = GlobalCacheDataStore2.getC hildSessio nObj(curSe ssId);
curSess.setMaxInactiveInte rval(val);
that time it provides class cast exception for httpsession in ehcache
please help me
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastExcepti
at com.sm.GlobalCacheDataStor
at org.apache.jsp.moreCourseI
at org.apache.jasper.runtime.
at javax.servlet.http.HttpSer
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.coyote.http11.H
at org.apache.coyote.http11.H
at org.apache.tomcat.util.net
at java.lang.Thread.run(Threa
this is my code
public static HttpSession getChildSessionObj(String sessID)
{
widgetCache = cacheManager.getEhcache( "widgets" );
Element element = widgetCache.get( sessID );
if( element != null )
{
// Get the value out of the element and cast it to a Widget
return (HttpSession) element.getValue();
}
return null;
}
i am calling here
HttpSession curSess;
if(curSessId!=null)
{
GlobalCacheDataStore2.setC
curSess = GlobalCacheDataStore2.getC
curSess.setMaxInactiveInte
that time it provides class cast exception for httpsession in ehcache
please help me
ASKER
that is example program so it contains that statement.
my program only returns httpsession at that time it would provide class cast exception
my program only returns httpsession at that time it would provide class cast exception
Sorry - i don't understand that. A ClassCastException is pretty simple really - you're trying to cast the object to a type that is foreign to it, so it will fail.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
?
... but you're not doing that. You're casting it to an HttpSession. Why?