susmit shukla
susmit shukla

Reputation: 213

JSP compilation issue due to JSTL validation on adding a jsp to running embedded jetty instance

I have created a JSP test framework but running into this issue if I try to add jsp to running server. The project config is as follows:

  1. JSP is present under /webapps folder.
  2. I create a ServletHolder dispatching to this JSP and add the servlet to webcontext.
  3. I setup the embedded Jetty server with this webcontext and start the server
  4. jsp page is served fine.

Now I create another ServletHolder for a different JSP and add it to running server's webcontext. On accessing the page, I get following exception

java.lang.NullPointerException
at org.apache.taglibs.standard.tlv.JstlBaseTLV.validate(JstlBaseTLV.java:149)
at org.apache.taglibs.standard.tlv.JstlCoreTLV.validate(JstlCoreTLV.java:105)
at org.apache.jasper.compiler.TagLibraryInfoImpl.validate(TagLibraryInfoImpl.java:949)
at org.apache.jasper.compiler.Validator.validateXmlView(Validator.java:1921)
at org.apache.jasper.compiler.Validator.validate(Validator.java:1888)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:223)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
at org.apache.jasper.servlet.JspServletWrapper.loadTagFile(JspServletWrapper.java:280)
at org.apache.jasper.compiler.TagFileProcessor.loadTagFile(TagFileProcessor.java:660)
at org.apache.jasper.compiler.TagFileProcessor.access$000(TagFileProcessor.java:91)
at  org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:719)

org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:634)

Strange thing is, if I stop the webcontext and add the servlet and start webcontext again, things run fine.

I tried to debug this and found that for the second jsp/tag call to 'JstlCoreTLV.getInitParameters()' is returning null, maybe jstl is reusing the validation object from previous cache and this property is reset to null in between.

Has anyone come across this issue? would it be a bug in JSTL library?

Upvotes: 1

Views: 1785

Answers (1)

susmit shukla
susmit shukla

Reputation: 213

Here is a workaround I used to fix this issue - Reinitialized the default JSP servlet to invalidate its taglib cache

    ServletHolder jspServletHolder = webContext.getServletHandler()
                .getServlet("jsp");
Servlet jspServlet = jspServletHolder.getServlet();
ServletConfig jspServletConfig = jspServlet.getServletConfig();
jspServlet.destroy();
jspServlet.init(jspServletConfig);

Upvotes: 1

Related Questions