Netbeans doesn't recognize xercesimpl

一曲冷凌霜 提交于 2019-12-14 03:19:52

问题


I am trying to build a plugin for netbeans using maven and for some reason Netbeans doesn't recognize xercesimpl.jar packaged with the plugin. Here is the stacktrace I see.

java.io.IOException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
    at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:353)
    at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:276)
    at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:207)
    at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createSVGDocument(SAXSVGDocumentFactory.java:105)
[catch] at org.netbeans.modules.plantumlnb.SVGImagePreviewPanel.createSVGDocument(SVGImagePreviewPanel.java:59)
    at org.netbeans.modules.plantumlnb.SVGImagePreviewPanel.renderSVGFile(SVGImagePreviewPanel.java:48)
    at org.netbeans.modules.plantumlnb.RenderImageThread$1.run(RenderImageThread.java:56)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Here is the image showing that the xercesimpl.jar is indeed packaged with the nbm file.

Here is a list of all the jars that were downloaded during build process.

NBM Plugin generates manifest
Adding on module's Class-Path:
    net.sourceforge.plantuml:plantuml:jar:7959
    batik:batik-swing:jar:1.6-1
    batik:batik-bridge:jar:1.6-1
    batik:batik-gvt:jar:1.6-1
    batik:batik-awt-util:jar:1.6-1
    batik:batik-script:jar:1.6-1
    rhino:js:jar:1.5R4.1
    batik:batik-svg-dom:jar:1.6-1
    batik:batik-dom:jar:1.6-1
    batik:batik-xml:jar:1.6-1
    xerces:xercesImpl:jar:2.5.0
    batik:batik-parser:jar:1.6-1
    batik:batik-css:jar:1.6-1
    batik:batik-rasterizer:jar:1.6-1
    batik:batik-transcoder:jar:1.6-1
    fop:fop:jar:0.20.5
    batik:batik-1.5-fop:jar:0.20-5
    xml-apis:xml-apis:jar:1.0.b2
    xalan:xalan:jar:2.4.1
    avalon-framework:avalon-framework:jar:4.0
    batik:batik-util:jar:1.6-1
    batik:batik-gui-util:jar:1.6-1
    batik:batik-ext:jar:1.6-1
    xml-apis:xmlParserAPIs:jar:2.0.2
    org.axsl.org.w3c.dom.svg:svg-dom-java:jar:1.1
    org.axsl.org.w3c.dom.smil:smil-boston-dom-java:jar:2000-02-25
    org.w3c.css:sac:jar:1.3
    crimson:crimson:jar:1.1.3

I am not sure what I am missing, any help is appreciated.


回答1:


My dependencies weren't right, so once I fixed them, it started recognizing. For anybody looking to include Batik in their maven based netbeans module I am including the dependencies below.

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-swing</artifactId>
        <version>1.6-1</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-script</artifactId>
        <version>1.6-1</version>
        <!-- exclude xerces as Netbeans includes it -->
        <exclusions>
            <exclusion>
                <groupId>xerces</groupId>
                <artifactId>xercesImpl</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- include xerces in test scope as unittests need it -->
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.5.0</version>
        <type>jar</type>
        <scope>test</scope>
    </dependency>


来源:https://stackoverflow.com/questions/18551025/netbeans-doesnt-recognize-xercesimpl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!