jsf - How do I exclude servlet-filters from having to be serialized? -
i converted beans viewscoped
instead of requestscoped
. however, since had add serialized
beans, getting 2 java.io.notserializableexception
exceptions.
this web.xml
:
<filter> <filter-name>primefaces fileupload filter</filter-name> <filter-class>org.primefaces.webapp.filter.fileuploadfilter</filter-class> </filter> <filter> <filter-name>loginfilter</filter-name> <filter-class>com.company.rews.webclient.controller.loginfilter</filter-class> </filter> <servlet> <servlet-name>faces servlet</servlet-name> <servlet-class>com.company.rews.webclient.controller.myfacesservletwrapper</servlet-class> <load-on-startup>1</load-on-startup> </servlet>
the first place reports exception somewhere inside super.service(req, res)
:
public class myfacesservletwrapper extends myfacesservlet { @override public void service(servletrequest request, servletresponse response) throws ioexception, servletexception { httpservletrequest req = (httpservletrequest) request; httpservletresponse res = (httpservletresponse) response; req.setcharacterencoding("utf-8"); res.setcharacterencoding("utf-8"); try { super.service(req, res); } catch (servletexception e) { e.printstacktrace(); loginfilter.gotologin(e, req, res); } }
}
and here @ chain.dofilter(request, response)
:
public class loginfilter implements filter { private static final string system_error_uri = "/login.faces"; private static final string viewex_error_uri = "/login.faces"; @override public void dofilter( servletrequest req, servletresponse res, filterchain chain ) throws ioexception, servletexception { httpservletrequest request = (httpservletrequest) req; httpservletresponse response = (httpservletresponse) res; if ( isresourcerequest(request, response) ) { chain.dofilter(request, response); } else if ( !isloggedin(request, response) && isloginarea(request, response) ) { gotologin(null, request, response); } else if( !isuserconnectedtorews( request ) && isloginarea(request, response) ) { gotologin(null, request, response); } else { chain.dofilter(request, response); } }
here complete error report:
08.05.2013. 18:03:47 org.apache.myfaces.renderkit.serversidestatecacheimpl serializeview severe: exiting serializeview - not serialize state: org.apache.myfaces.context.servlet.servletexternalcontextimpl java.io.notserializableexception: org.apache.myfaces.context.servlet.servletexternalcontextimpl @ java.io.objectoutputstream.writeobject0(objectoutputstream.java:1164) @ java.io.objectoutputstream.defaultwritefields(objectoutputstream.java:1518) @ java.io.objectoutputstream.writeserialdata(objectoutputstream.java:1483) @ java.io.objectoutputstream.writeordinaryobject(objectoutputstream.java:1400) @ java.io.objectoutputstream.writeobject0(objectoutputstream.java:1158) @ java.io.objectoutputstream.writeobject(objectoutputstream.java:330) @ java.util.hashmap.writeobject(hashmap.java:1001) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ java.io.objectstreamclass.invokewriteobject(objectstreamclass.java:945) @ java.io.objectoutputstream.writeserialdata(objectoutputstream.java:1469) @ java.io.objectoutputstream.writeordinaryobject(objectoutputstream.java:1400) @ java.io.objectoutputstream.writeobject0(objectoutputstream.java:1158) @ java.io.objectoutputstream.writearray(objectoutputstream.java:1346) @ java.io.objectoutputstream.writeobject0(objectoutputstream.java:1154) @ java.io.objectoutputstream.writeobject(objectoutputstream.java:330) @ java.util.hashmap.writeobject(hashmap.java:1001) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ java.io.objectstreamclass.invokewriteobject(objectstreamclass.java:945) @ java.io.objectoutputstream.writeserialdata(objectoutputstream.java:1469) @ java.io.objectoutputstream.writeordinaryobject(objectoutputstream.java:1400) @ java.io.objectoutputstream.writeobject0(objectoutputstream.java:1158) @ java.io.objectoutputstream.writearray(objectoutputstream.java:1346) @ java.io.objectoutputstream.writeobject0(objectoutputstream.java:1154) @ java.io.objectoutputstream.writeobject(objectoutputstream.java:330) @ org.apache.myfaces.renderkit.serversidestatecacheimpl.serializeview(serversidestatecacheimpl.java:390) @ org.apache.myfaces.renderkit.serversidestatecacheimpl.saveserializedviewinservletsession(serversidestatecacheimpl.java:240) @ org.apache.myfaces.renderkit.serversidestatecacheimpl.saveserializedview(serversidestatecacheimpl.java:872) @ org.apache.myfaces.renderkit.html.htmlresponsestatemanager.savestate(htmlresponsestatemanager.java:144) @ org.apache.myfaces.application.statemanagerimpl.saveview(statemanagerimpl.java:195) @ org.apache.myfaces.view.facelets.faceletviewdeclarationlanguage.renderview(faceletviewdeclarationlanguage.java:1971) @ org.apache.myfaces.application.viewhandlerimpl.renderview(viewhandlerimpl.java:285) @ org.apache.myfaces.lifecycle.renderresponseexecutor.execute(renderresponseexecutor.java:115) @ org.apache.myfaces.lifecycle.lifecycleimpl.render(lifecycleimpl.java:241) @ javax.faces.webapp.facesservlet.service(facesservlet.java:199) @ org.apache.myfaces.webapp.myfacesservlet.service(myfacesservlet.java:112) @ com.mainconcept.rews.webclient.controller.myfacesservletwrapper.service(myfacesservletwrapper.java:30) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.primefaces.webapp.filter.fileuploadfilter.dofilter(fileuploadfilter.java:79) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:243) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ com.company.rews.webclient.controller.loginfilter.dofilter(loginfilter.java:54) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:243) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:225) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:169) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:168) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:98) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:927) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:999) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:565) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:307) @ java.util.concurrent.threadpoolexecutor$worker.runtask(threadpoolexecutor.java:886) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:908) @ java.lang.thread.run(thread.java:662)
how exclude servlet-filters having serialized if that's problem here @ all?
just stop assigning facescontext
, externalcontext
, of artifacts instance variable. should always, obtain , assign them in thread local scope (i.e. inside method block).
see also:
- serialize facescontext or how properties-values after server restart
- java.lang.illegalstateexception @ com.sun.faces.context.facescontextimpl.assertnotreleased
- illegalstateexception when trying .getsessionmap() session scoped bean
- java threadlocal singleton - it?
please note has nothing servlet filters.
Comments
Post a Comment