December 18th, 2013

Just a quick post about this error I was receiving today as the error is very unhelpful and it took me a while to figure out what was wrong.

I was trying to define a taglib in my web.xml as follows


<jsp-config>
    <taglib>
        <taglib-uri>http://http://www.scarba05.co.uk/mytaglib</taglib-uri>
        <taglib-location>/WEB-INF/mytaglib.tld</taglib-location>
    </taglib>
  </jsp-config> 

On starting tomcat I got this very unhelpful stack


20131218 14:26:54.794 [localhost-startStop-1] WARN org.apache.catalina.startup.TldConfig – Failed to process TLD with path [http://http://www.scarba05.co.uk/mytaglib] and URI [/WEB-INF/mytaglib.tld]
java.net.MalformedURLException: null
at java.net.URL.(URL.java:601) ~[na:1.6.0_43]
at java.net.URL.(URL.java:464) ~[na:1.6.0_43]
at java.net.URL.(URL.java:413) ~[na:1.6.0_43]
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:648) ~[na:1.6.0_43]
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186) ~[na:1.6.0_43]
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:772) ~[na:1.6.0_43]
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) ~[na:1.6.0_43]
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) ~[na:1.6.0_43]
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) ~[na:1.6.0_43]
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) ~[na:1.6.0_43]
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537) ~[tomcat-coyote.jar:7.0.47]
at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:544) [catalina.jar:7.0.47]
at org.apache.catalina.startup.TldConfig.tldScanWebXml(TldConfig.java:357) [catalina.jar:7.0.47]
at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:271) [catalina.jar:7.0.47]
at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:569) [catalina.jar:7.0.47]
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) [catalina.jar:7.0.47]
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) [catalina.jar:7.0.47]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322) [catalina.jar:7.0.47]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.47]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) [catalina.jar:7.0.47]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) [catalina.jar:7.0.47]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) [catalina.jar:7.0.47]
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:983) [catalina.jar:7.0.47]
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1660) [catalina.jar:7.0.47]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) [na:1.6.0_43]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_43]
at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_43]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [na:1.6.0_43]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [na:1.6.0_43]
at java.lang.Thread.run(Thread.java:662) [na:1.6.0_43]

You’ll probably notice the path and URI labelled wrong in the log – this is a red herring. What’s actually the problem is that Tomcat can’t find your tld file. So double check you have the name and location of the tld file correct in your web.xml (case sensitive on *nix) and that the tld file is correctly included in your war. My problem was the my maven project pom.xml didn’t include tld files when it packaged up the war.

I raised a Tomcat bug to make the error message clearer https://issues.apache.org/bugzilla/show_bug.cgi?id=55905

Comments are closed.