0

我正在尝试使用 maven 为 netbeans 构建一个插件,由于某种原因,Netbeans 无法识别xercesimpl.jar 与该插件一起打包的内容。这是我看到的堆栈跟踪。

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)

这是显示 xercesimpl.jar 确实与 nbm 文件一起打包的图像。

在此处输入图像描述

这是在构建过程中下载的所有 jar 的列表。

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

我不确定我错过了什么,感谢任何帮助。

4

1 回答 1

0

我的依赖不正确,所以一旦我修复它们,它就开始识别。对于希望将 Batik 包含在基于 maven 的 netbeans 模块中的任何人,我将包含以下依赖项。

    <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>
于 2013-09-02T23:27:14.237 回答