Question

I try to use a jar file containing a taglib. I get a "Content is not allowed in prolog" error (in french in the stacktrace below):

sept. 12, 2013 3:52:49 PM org.apache.catalina.startup.TldConfig tldScanWebXml
Avertissement: Failed to process TLD with path [taglib-welcom-uri] and URI [/WEB-INF/lib/welcom-2.6.13-SNAPSHOT.jar]
java.io.IOException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.
    at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:547)
    at org.apache.catalina.startup.TldConfig.tldScanWebXml(TldConfig.java:357)
    at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:271)
    at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:569)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1388)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:996)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
    at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)
    at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:544)
    ... 14 more

My jar file, called welcom.jar contains a welcom.tld file in META-INF. I added this to the web.xml of my tomcat:

<jsp-config>
    <taglib>
        <taglib-uri>taglib-welcom-uri</taglib-uri>
        <taglib-location>/WEB-INF/lib/welcom.jar</taglib-location>
    </taglib>
</jsp-config>

I can't see anything wrong with the tld file, which is used without any problem on other projects. It's encoded in ISO-8859-1 and that's what is indicated in the prolog of the file :

<?xml version="1.0" encoding="ISO-8859-1" ?>

Any idea?

Edit: The version of the taglibs is 1.2. For further information, here the header of the tld file:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
  PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
  "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
  <tlib-version>2.6</tlib-version>
  <jsp-version>1.2</jsp-version>
  <short-name>af</short-name>

  ...

</taglib>
Was it helpful?

Solution

Actually, the jsp-config part in the web.xml is not useful and is the cause of the problem. Everything works fine without it. I still don't get why the problem expresses itself by an XML parsing exception, because every XML here is well formed and should be parsed without any problem. The error itself is very misleading.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top