1

我在 websphere 7.0 的 WEB-INF lib 目录ClassNotFoundExceptionApache-FOP包含 fop.jar。我将 xmlgraphics-commons-1.4.jar 添加到我的库中,然后它会引发验证错误。

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>
4

2 回答 2

2

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

类路径: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

于 2012-12-04T14:56:38.160 回答
0

……5年后……

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

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

从 Apr, 2017 开始使用 Apache FOP 2.2 版。将以下所有 .jar 添加到您的WEB-INF/lib,您可能能够处理:

  • avalon-framework-4.2.0.jar
  • 蜡染桥-1.9.1.jar
  • commons-io-2.4.jar
  • commons-logging-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-commons-2.2.jar
于 2018-03-15T16:07:18.927 回答