我应该在apache fop的类路径中包含哪些jar

时间:2012-12-03 20:01:15

标签: java websphere-7 apache-fop

我收到ClassNotFoundException Apache-FOP我已将fop.jar包含在websphere 7.0的WEB-INF lib目录中。我将xmlgraphics-commons-1.4.jar添加到我的lib中,然后抛出验证错误。

Caused by: java.lang.VerifyError: JVMVRFY012 stack shape inconsistent; class=org/apache/fop/fo/ElementMappingRegistry, method=findFOMaker(Ljava/lang/String;Ljava/lang/String;Lorg/xml/sax/Locator;)Lorg/apache/fop/fo/ElementMapping$Maker;, pc=127

Caused by: java.lang.NoClassDefFoundError: org.apache.xmlgraphics.image.loader.ImageContext
    at java.lang.ClassLoader.defineClassImpl(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:274)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:69)
    at com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:768)
    at com.ibm.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:687)
    at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:510)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:618)
    at cat.gis.portal.servicehistory.controllers.EquipmentServiceHistoryDetailsViewController.generatePDF(EquipmentServiceHistoryDetailsViewController.java:281)
    at cat.gis.portal.servicehistory.controllers.EquipmentServiceHistoryDetailsViewController.workOrderDetailsView(EquipmentServiceHistoryDetailsViewController.java:205)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:362)
    at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.doHandle(AnnotationMethodHandlerAdapter.java:349)
    at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.handleResource(AnnotationMethodHandlerAdapter.java:296)
    at org.springframework.web.portlet.DispatcherPortlet.doResourceService(DispatcherPortlet.java:825)
    ... 119 more
Caused by: java.lang.ClassNotFoundException: org.apache.xmlgraphics.image.loader.ImageContext
    at java.net.URLClassLoader.findClass(URLClassLoader.java:421)
    at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:191)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:652)
    at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:111)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:618)
    at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
    at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
    at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:540)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:618)
    at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:508)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:618)
    at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:508)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:618)
    ... 137 more

更新

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output encoding="iso-8859-1" />
<xsl:template match ="services">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <fo:layout-master-set>
            <fo:simple-page-master master-name="service">
                <fo:region-body></fo:region-body>
            </fo:simple-page-master>
        </fo:layout-master-set>

        <fo:page-sequence master-reference="service">
            <fo:flow flow-name="xsl-region-body">
                <fo:block>
                    <fo:table>
                        <fo:table-body>
                            <fo:table-row>
                                <fo:table-cell border="solid 1px black" 
                                text-align="center" font-weight="bold">
                                    <fo:block>Service Id</fo:block>
                                </fo:table-cell>
                                <fo:table-cell border="solid 1px black" 
                                text-align="center" font-weight="bold">
                                    <fo:block>Open Date</fo:block>
                                </fo:table-cell>
                                <fo:table-cell border="solid 1px black" 
                                text-align="center" font-weight="bold">
                                    <fo:block>Close Date</fo:block>
                                </fo:table-cell>                                    
                                <fo:table-cell border="solid 1px black" 
                                text-align="center" font-weight="bold">
                                    <fo:block>Order Status</fo:block>
                                </fo:table-cell>                                    
                                <fo:table-cell border="solid 1px black" 
                                text-align="center" font-weight="bold">
                                    <fo:block>Description</fo:block>
                                </fo:table-cell>
                                <fo:table-cell border="solid 1px black" 
                                text-align="center" font-weight="bold">
                                    <fo:block>Repair Cost</fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                            <xsl:for-each select="./service">
                                <fo:table-row>
                                    <fo:table-cell border="solid 1px bold" text-align="center">
                                        <fo:block><xsl:value-of select="serviceId" /></fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="solid 1px bold" text-align="center">
                                        <fo:block><xsl:value-of select="openDate" /></fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="solid 1px bold" text-align="center">
                                        <fo:block><xsl:value-of select="closeDate" /></fo:block>
                                    </fo:table-cell>                                
                                    <fo:table-cell border="solid 1px bold" text-align="center">
                                        <fo:block><xsl:value-of select="orderStatus" /></fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="solid 1px bold" text-align="center">
                                        <fo:block><xsl:value-of select="description" /></fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="solid 1px bold" text-align="center">
                                        <fo:block><xsl:value-of select="repairCost" /></fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </xsl:for-each>
                        </fo:table-body>
                    </fo:table>
                </fo:block>
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
</xsl:template>
</xsl:stylesheet>

2 个答案:

答案 0 :(得分:2)

请记住,jar文件主要只是一个带有清单的zip文件:使用您最喜欢的解压缩工具解压缩jar,查看 META-INF / MANIFEST.MF 文件,并检查类路径上的所有内容都存在。对我来说(FOP 1.0),类路径条目就是这个:

Class-Path:avalon-framework-4.2.0.jar batik-all-1.7.jar commons-io-1。  3.1.jar commons-logging-1.0.4.jar fop-hyph.jar serializer-2.7.0.jar s  ervlet-2.2.jar xalan-2.7.0.jar xercesImpl-2.7.1.jar xml-apis-1.3.04.j  ar xml-apis-ext-1.3.04.jar xmlgraphics-commons-1.4.jar

答案 1 :(得分:0)

...... 5年后......

我遇到了同样的问题并通过搜索包名称迭代所有抛出的NoClassDefFoundError来快速修复它,例如org.apache.xmlgraphics,并添加了从Maven Repository下载的所有遗失.jars

也许,您可以使用Maven插件来避免依赖地狱并引用所有丢失的.jars但我没有尝试过。

我从2017年4月开始使用 Apache FOP 2.2版。将以下.jars添加到WEB-INF/lib,您可以处理:

  • 的Avalon框架-4.2.0.jar
  • 蜡染桥-1.9.1.jar
  • 公地-IO-2.4.jar
  • 共享记录-1.2.jar
  • fop.jar
  • org.apache.batik.css-1.6.0.v201011041432.jar
  • org.apache.batik.svggen-1.6.0.v201011041432.jar
  • org.apache.batik.transcoder-1.6.0.v201011041432.jar
  • org.apache.batik.util-1.6.0.v201011041432.jar
  • xmlgraphics-公地2.2.jar