Sunday, February 28, 2010

Picky Tomcat parsing of function taglib descriptor element 'function-signature'

pencil icon, that"s clickable to start editing the post

After spending way way to much time figuring out what kind of an error I had introduced into my webapp it turned out the Tomcat/Jasper does what seems to be as a very non-xml'ish parsing of the tld. Here's to those of you out there that stumble upon these error messages. The heart of my learning is that the element defining the function-signature should be on one line! This example is bad:

<function>
   <description>.....</description>
   <name>myTagLibFunction</name>
   <function-class>my.package.taglib.functionClass</function-class>
   <function-signature>my.package.returnValue[] 
myTagLibFunction(java.lang.String,java.util.Calendar)</function-signature>
   <example>.....</example>
</function>

and this one should be fine:

<function>
   <description>.....</description>
   <name>myTagLibFunction</name>
   <function-class>my.package.taglib.functionClass</function-class>
   <function-signature>my.package.returnValue[] myTagLibFunction(java.lang.String,java.util.Calendar)</function-signature>
   <example>.....</example>
</function>

It was my pretty formatting the ruined it for me. Here's first an error message that at least make sense (contrary to the next one):

Exception: org.apache.jasper.JasperException: Invalid syntax for function signature in TLD. Tag Library: myChoosePrefix, Function: myTagLibFunction

and the complete stacktrace:

org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:164)
org.apache.jasper.compiler.Validator$ValidateVisitor.getMethod(Validator.java:1536)
org.apache.jasper.compiler.Validator$ValidateVisitor.processSignature(Validator.java:1523)
org.apache.jasper.compiler.Validator$ValidateVisitor.access$400(Validator.java:411)
org.apache.jasper.compiler.Validator$ValidateVisitor$1FVVisitor.visit(Validator.java:1499)
org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:129)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:200)
org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:242)
org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:56)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:200)
org.apache.jasper.compiler.Validator$ValidateVisitor.validateFunctions(Validator.java:1503)
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1139)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:819)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1512)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:515)
org.apache.jasper.compiler.Node$JspRoot.accept(Node.java:566)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Validator.validate(Validator.java:1737)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:165)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:240)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:258)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1174)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:901)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Thread.java:619)

The cryptic one had me doing all kinds of odd stuff for trying to isolate the problem. Unfortunately I've deleted the local logfiles but it said something with substring indexoutofbounds -19

Currently I'm just happy to have found the it's Tomcat/Jasper that's picky (during compilation) but I haven't looked at neither specification nor code.

1 comments :

njoyes said...

Thanks, this post saved me a ton of time!