Bug 54440 - TagPluginManager.init() throws NPE when used in Ant <jasper> task
Summary: TagPluginManager.init() throws NPE when used in Ant <jasper> task
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 7.0.35
Hardware: Macintosh All
: P2 normal with 1 vote (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
: 54472 (view as bug list)
Depends on:
Reported: 2013-01-17 03:29 UTC by Sean Owen
Modified: 2013-01-23 09:07 UTC (History)
1 user (show)

Patch for this issue (1.06 KB, patch)
2013-01-17 08:43 UTC, Sheldon Shao
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Owen 2013-01-17 03:29:19 UTC
In 7.0.35, I see the following NPE when compiling JSPX files via the <jasper> Ant task:

   [jasper] java.lang.NullPointerException
   [jasper] 	at org.apache.jasper.compiler.TagPluginManager.init(TagPluginManager.java:83)
   [jasper] 	at org.apache.jasper.compiler.TagPluginManager.apply(TagPluginManager.java:57)
   [jasper] 	at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:240)
   [jasper] 	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
   [jasper] 	at org.apache.jasper.JspC.processFile(JspC.java:1179)
   [jasper] 	at org.apache.jasper.JspC.execute(JspC.java:1329)
   [jasper] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
   [jasper] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
   [jasper] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   [jasper] 	at java.lang.reflect.Method.invoke(Method.java:601)
   [jasper] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
   [jasper] 	at org.apache.tools.ant.Task.perform(Task.java:348)
   [jasper] 	at org.apache.tools.ant.Target.execute(Target.java:390)
   [jasper] 	at org.apache.tools.ant.Target.performTasks(Target.java:411)
   [jasper] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
   [jasper] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
   [jasper] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
   [jasper] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
   [jasper] 	at org.apache.tools.ant.Main.runBuild(Main.java:809)
   [jasper] 	at org.apache.tools.ant.Main.startAnt(Main.java:217)
   [jasper] 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
   [jasper] 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

This didn't happen in 7.0.34.

Given the line and change from 7.0.34 (http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java?r1=1402119&r2=1431228&diff_format=h) I assume that in...

    urls = ctxt.getClassLoader().getResources(
84	 	                     META_INF_JASPER_TAG_PLUGINS_XML);

the ClassLoader is null, since ctxt was used here before and evidently not null.

Fall back to Thread.currentThread().getContextClassLoader() in this case?

My Ant snippet:

    <import file="${tomcat.home}/bin/catalina-tasks.xml"/>
    <jasper validateXml="false"
Comment 1 Sheldon Shao 2013-01-17 08:43:38 UTC
Created attachment 29860 [details]
Patch for this issue

The root cause is that there is no ClassLoader was set in JspCServletContext.
JspC holds the ClassLoader, but doesn't pass it to JspCServletContext.

Could you try this patch ?
Comment 2 Sean Owen 2013-01-17 10:29:18 UTC
Thank you, yes this patch appears to work. The <jasper> task succeeds, JSPX are compiled and then compile themselves, the app works. Looks good to me.
Comment 3 Mark Thomas 2013-01-17 13:21:55 UTC
Thanks all for the report, the patch and testing. That patch has been applied to trunk and will be included in 7.0.36 onwards.
Comment 4 Mark Thomas 2013-01-23 09:07:47 UTC
*** Bug 54472 has been marked as a duplicate of this bug. ***