Re: [solved] Getting Exception rarerly with my website askkuber.com

Splash Forums PrettyFaces Users [solved] Getting Exception rarerly with my website askkuber.com Re: [solved] Getting Exception rarerly with my website askkuber.com

#19925

geert3
Participant

I’m digging my teeth in this because it’s happening in production now and then and it’s really making me nervous.

I cannot reproduce it in a simple setup (still working on it) but in our full project i can more or less force it to happen. First I let the application throw a “normal” exception. Like this one:

com.ocpsoft.pretty.PrettyException: PrettyFaces: Exception occurred while processing mapping<account_details:#{klMemoBean.selectedKlMemo}>

for query parameter named<id> Cannot convert XXXXXX of type class java.lang.String to class cob.extsecurity.data.BookkeepingKlMemo

at

com.ocpsoft.pretty.beans.ParameterInjector.injectQueryParams(ParameterInjector.java:

97)

at

com.ocpsoft.pretty.beans.ParameterInjector.injectParameters(ParameterInjector.java:

50)

at

com.ocpsoft.pretty.PrettyContext.injectParameters(PrettyContext.java:

127)

at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:55)

at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:

235)

at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:

206)

at cob.extsecurity.ExtSecurityFilter.doFilter(ExtSecurityFilter.java:

121)

at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:

235)

at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:

206)

at

org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:

233)

at

org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:

191)

at

org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:

558)

at

org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:

127)

at

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:

102)

at

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:

109)

at

org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:

421)

at

org.apache.catalina.connector.RemoteIpValve.invoke(RemoteIpValve.java:

610)

at

org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:

298)

at

org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:

852)

at org.apache.coyote.http11.Http11Protocol

$Http11ConnectionHandler.process(Http11Protocol.java:588)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:

489)

at java.lang.Thread.run(Thread.java:619)

Caused by: java.lang.IllegalArgumentException: Cannot convert XXXXXXX

of type class java.lang.String to class

cob.extsecurity.data.BookkeepingKlMemo

at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:378)

at

org.apache.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:

46)

at com.ocpsoft.pretty.util.FacesElUtils.setValue(FacesElUtils.java:

53)

at

com.ocpsoft.pretty.beans.ParameterInjector.injectQueryParams(ParameterInjector.java:

91)

… 21 more

After causing this exception a few time (sometimes 1 time, sometimes 40+ times), every subsequent request will cause the pretty filter to throw NullPointerExceptions (also with PF 3.0.1 / JSF1.2). Closing the browser won’t help, only restarting tomcat will help.

java.lang.NullPointerException

at com.ocpsoft.pretty.PrettyContext.newInstance(PrettyContext.java:

112)

at

com.ocpsoft.pretty.PrettyContext.getCurrentInstance(PrettyContext.java:

96)

at

com.ocpsoft.pretty.PrettyContext.getCurrentInstance(PrettyContext.java:

77)

at

com.ocpsoft.pretty.beans.ParameterInjector.injectParameters(ParameterInjector.java:

39)

at

com.ocpsoft.pretty.PrettyContext.injectParameters(PrettyContext.java:

127)

at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:55)

at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:

235)

at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:

206)

at cob.extsecurity.ExtSecurityFilter.doFilter(ExtSecurityFilter.java:

121)

at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:

235)

at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:

206)

at

org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:

233)

at

org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:

191)

at

org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:

558)

at

org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:

127)

at

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:

102)

at

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:

109)

at

org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:

421)

at

org.apache.catalina.connector.RemoteIpValve.invoke(RemoteIpValve.java:

610)

at

org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:

298)

at

org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:

852)

at org.apache.coyote.http11.Http11Protocol

$Http11ConnectionHandler.process(Http11Protocol.java:588)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:

489)

at java.lang.Thread.run(Thread.java:619)

Now i managed to “predict” when this is going to happen.

I have a filter (cob.extsecurity.ExtSecurityFilter) which will invoke doFilter which will lead into the PrettyFaces Filter.

This filter looks like this:

public void doFilter(ServletRequest request, ServletResponse response,

FilterChain chain) throws IOException, ServletException {

FacesContext fc = FacesContext.getCurrentInstance();

HttpServletRequest fcreq = null;

if (fc != null)

fcreq = (HttpServletRequest)fc.getExternalContext().getRequest();

if (fcreq == null || fcreq == req)

log.info(“All will be fine”);

else

log.error(“It will go wrong now”);

log.info(“req=”+req+”; sess=”+req.getSession()+” fc=”+fc+”;

fcreq=”+fcreq);

chain.doFilter(req, resp);

}

Normally, the Request parameter of doFilter is the same as the Request returned by FacesContext.getExternalContext().getRequest():

2010-07-07 09:20:58,239 INFO [127.0.0.1 gcoelmon]

cob.extsecurity.ExtSecurityFilter:108 – All will be fine

2010-07-07 09:20:58,244 INFO [127.0.0.1 gcoelmon]

cob.extsecurity.ExtSecurityFilter:111 –

req=org.apache.catalina.connector.RequestFacade@74b10b;

sess=org.apache.catalina.session.StandardSessionFacade@1dbb12b

fc=com.sun.faces.context.FacesContextImpl@11ce4fe;

fcreq=org.apache.catalina.connector.RequestFacade@74b10b

Notice how here req and fcreq are both the same Request object @74b10b – this will always lead to a good situation.

All of a sudden they start to differ, which is also when PrettyFaces will start to throw NPEs.

2010-07-07 09:20:58,455 ERROR [127.0.0.1 gcoelmon]

cob.extsecurity.ExtSecurityFilter:110 – It will go wrong now

2010-07-07 09:20:58,456 INFO [127.0.0.1 gcoelmon]

cob.extsecurity.ExtSecurityFilter:111 –

req=org.apache.catalina.connector.RequestFacade@141e00a;

sess=org.apache.catalina.session.StandardSessionFacade@1dbb12b

fc=com.sun.faces.context.FacesContextImpl@11ce4fe;

fcreq=org.apache.catalina.connector.RequestFacade@74b10b

Notice how in this logging, req is a new object @141e00a, whereas fcreq still contains the “old” request object @74b10b. This situation always lead to a NPE as described.

I hope this helps in identifying the problem, it’s becoming a big issue and we may need to remove prettyfaces from our project.

Thanks

Geert