Bug 51088 - ArrayIndexOutOfBoundsException from org.apache.el.parser.JJTELParserState
ArrayIndexOutOfBoundsException from org.apache.el.parser.JJTELParserState
Status: RESOLVED WONTFIX
Product: Tomcat 6
Classification: Unclassified
Component: Jasper
6.0.32
All All
: P2 normal (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2011-04-20 05:42 UTC by Michael Heinen
Modified: 2011-07-02 12:13 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Heinen 2011-04-20 05:42:42 UTC
I found the following ArrayIndexOutOfBoundsException in my logfile.
It occurred directly after login into my webApp without any further user interaction. Unfortunately it is not reproducible at all.

I am not sure whether Jasper is the right component. However the class  JJTELParserState is in the jasper-el.jar.

Environment:
Tomcat 6.0.32 
Facelets 1.1.14
Myfaces 1.2.9

SCHWERWIEGEND: Error Rendering View[/facelets/myview.xhtml]
java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.remove(ArrayList.java:390)
	at org.apache.el.parser.JJTELParserState.closeNodeScope(JJTELParserState.java:108)
	at org.apache.el.parser.ELParser.CompositeExpression(ELParser.java:74)
	at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:115)
	at org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:172)
	at org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:216)
	at org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:68)
	at com.sun.facelets.el.ELText$ELTextVariable.apply(ELText.java:161)
	at com.sun.facelets.compiler.AttributeInstruction.apply(AttributeInstruction.java:60)
	at com.sun.facelets.compiler.UIInstructionHandler.apply(UIInstructionHandler.java:95)
	at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
	at com.sun.facelets.tag.jstl.core.IfHandler.apply(IfHandler.java:54)
	at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
	at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:360)
	at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:190)
	at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
	at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:360)
	at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:190)
	at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
	at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:360)
	at org.apache.myfaces.custom.aliasbean.AliasBeansScopeTagHandler.applyNextHandler(AliasBeansScopeTagHandler.java:52)
	at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:190)
	at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
	at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:124)
	at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
	at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:39)
	at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248)
	at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:294)
	at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:273)
	at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:140)
	at com.sun.facelets.tag.ui.IncludeHandler.apply(IncludeHandler.java:66)
	at com.sun.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:64)
	at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:136)
	at com.sun.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:337)
	at com.sun.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:307)
	at com.sun.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:68)
	at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
	at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:360)
	at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:190)
	at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
	at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:360)
	at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:190)
	at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
	at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:124)
	at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
	at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:39)
	at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248)
	at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:294)
	at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:273)
	at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:140)
	at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:116)
	at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
	at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:39)
	at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
	at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:596)
	at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:651)
	at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
	at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
	at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
	at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
	at org.apache.myfaces.custom.ppr.PPRLifecycleWrapper.render(PPRLifecycleWrapper.java:84)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:187)
	at com.foo..client.web.servlets.FacesServletWrapper.service(FacesServletWrapper.java:125)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
	at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
	at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
	at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:392)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.foo..client.web.filters.LoginFilter.doFilter(LoginFilter.java:219)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.foo..client.web.filters.CacheFilter.doFilter(CacheFilter.java:110)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.foo..client.web.filters.EncodingFilter.doFilter(EncodingFilter.java:54)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.foo..client.web.filters.TimerFilter.doFilter(TimerFilter.java:80)
	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:470)
	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.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
	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:662)
Comment 1 Mark Thomas 2011-05-05 09:13:32 UTC
Without the ability to reproduce the error, this issue is likely to be eventually resolved as WONTFIX. Any further information (such as the expression that was being parsed) would be very helpful.

The code where this error occurs is in auto-generated code from JJTree/JavaCC. Tomcat is using the latest version. I don't see any way that this could be a concurrency issue since none of the objects involved are shared (they are all created in the current thread).

The bug may be in Tomcat's parser definition (e.g. not handling invalid correctly), JJTree, JavaCC or Tomcat's (less likely in my view) use of the resulting code.
Comment 2 Michael Heinen 2011-05-12 08:11:48 UTC
Mark, I can't provide more information unfortunately. I don't know which expression caused the error and I did not see it anymore in any app log.

I'll update this ticket as soon as I see it again
Comment 3 Konstantin Kolinko 2011-05-13 22:46:16 UTC
> Unfortunately it is not reproducible at all.

a) Some rarely executed if-branch in [/facelets/myview.xhtml]?

Rare things are not that rare. I do not see any other reports of such an issue with JJTELParserState.

b) Concurrency? As Mark noted in Comment 1 this is unlikely.

ExpressionBuilder.java:115 is creating a new ELParser for a String and parsing it. That parsing should be thread safe.

>                n = (new ELParser(new StringReader(expr)))
>                        .CompositeExpression();

c) Unexpected JVM Error? E.g. OutOfMemoryError.

The ELParser.java:74 is inside a finally{} block, so if this happened during exception processing the original error might be lost. I think the following cascade of errors is possible, where original error is masked by two others:

1. Exception at ELParser.java:74 (jjtree.closeNodeScope(jjtn000, true);) is possible only if jjtc000 is true.
2. I think that before it at ELParser.java:60 (jjtree.clearNodeScope(jjtn000);) call failed with a RuntimeException e.g. for the same wrong index reasons as 1. and failed to set jjtc000 to false.
3. The 2. is inside a catch(Throwable) block and it might be triggered by an OutOfMemoryError,  (or by another RuntimeException at the lower layer, because the same catch(Throwable)+finally handling is everywhere in that generated code).

I think c) is feasible.
Comment 4 Michael Heinen 2011-05-16 09:32:16 UTC
a) can be excluded (no rarely executed if-branch)
c) could be possible indeed (although an OOM did not occur, but maybe another RuntimeException)
Comment 5 Mark Thomas 2011-06-29 13:57:47 UTC
I think Konstantin is along the right lines here.

The more I look at the generated code, the more there is I don't like (like the exception handling) but I like the idea of writing it myself from scratch even less.

Since this issue can't be reproduced, the best we can do is include the expression that triggered the issue in the exception message. I have made this change to 7.0.x and will propose the same change for 6.0.x.
Comment 6 Mark Thomas 2011-07-02 12:13:08 UTC
The improved exception handling as been added to 6.0.x and will be included in 6.0.33 onwards.

There isn't a resolution for "not enough information to figure out where the problem is", so I'm resolving this as WONTFIX. If more information emerges from the improved error handling, this issue can always be re-opened.