fop-1.1を使用してPDFファイルを表示したいとします。 jarとxmlgraphics-commons-1.5.jar(JRE 1.6に基づいています)。しかし、私は以下のように例外があります。NoSuchMethodError with Fop library
EXCEPTION]
java.lang.NoSuchMethodError: org.apache.xmlgraphics.xmp.Metadata.mergeInto(Lorg/apache/xmlgraphics/xmp/Metadata;)V
at org.apache.fop.render.pdf.PDFRenderingUtil.renderXMPMetadata(PDFRenderingUtil.java:356)
at org.apache.fop.render.pdf.PDFDocumentHandler.handleExtensionObject(PDFDocumentHandler.java:290)
at org.apache.fop.render.intermediate.util.IFDocumentHandlerProxy.handleExtensionObject(IFDocumentHandlerProxy.java:197)
at org.apache.fop.render.intermediate.IFRenderer.startPageSequence(IFRenderer.java:519)
at org.apache.fop.area.RenderPagesModel.startPageSequence(RenderPagesModel.java:97)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:104)
at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:267)
at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:128)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:347)
at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:181)
at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.endElement(ToXMLSAXHandler.java:261)
at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.endElement(ToXMLSAXHandler.java:555)
at letter_EN_Salaried.template$dot$0()
at letter_EN_Salaried.applyTemplates()
at letter_EN_Salaried.transform()
at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:637)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:758)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:356)
at com.demo.EmployeeProof.doOnNodeReady(EmployeeProof.java:150)
とJavaクラス:150がログに参照してください
HttpServletResponse response = request.getServletResponse(true);
String strXSLPath = Property.strXSLPath;
IJCOClientService clientService = (IJCOClientService) request
.getService(IJCOClientService.KEY);
poolEntry = clientService.getJCOClientPoolEntry("SAP_R3_PAYSTUB",
request);
this.tFactory = TransformerFactory.newInstance();
this.fopFactory = FopFactory.newInstance();
ByteArrayOutputStream out = new ByteArrayOutputStream();
FOUserAgent userAgent = fopFactory.newFOUserAgent();
userAgent.getRendererOptions().put(
"encryption-params",
new PDFEncryptionParams(null, "password", true, false,
false, false));
Fop fop = fopFactory.newFop(org.apache.xmlgraphics.util.MimeConstants.MIME_PDF, userAgent, out);
Source xsltSrc = null;
xsltSrc = new StreamSource(strXSLPath
+ "demo.xsl");
Transformer transformer = this.tFactory.newTransformer(xsltSrc);
Source src = new StreamSource(createXML(poolEntry, request));
transformer.transform(src, res);
response.setContentType("application/pdf");
response.setContentLength(out.size());
response.getOutputStream().write(out.toByteArray());
response.getOutputStream().flush();
ラインは
transformer.transform(src, res);
とクラスパスです:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src.api"/>
<classpathentry kind="src" path="src.core"/>
<classpathentry kind="var" path="LIB_HOME/prtapi.jar"/>
<classpathentry kind="var" path="LIB_HOME/prttest.jar"/>
<classpathentry kind="var" path="LIB_HOME/com.sap.portal.runtime.application.soap_api.jar"/>
<classpathentry kind="var" path="LIB_HOME/activation.jar"/>
<classpathentry kind="var" path="LIB_HOME/com.sap.security.api.jar"/>
<classpathentry kind="var" path="LIB_HOME/jaxm-api.jar"/>
<classpathentry kind="var" path="LIB_HOME/mail.jar"/>
<classpathentry kind="var" path="LIB_HOME/saaj-api.jar"/>
<classpathentry kind="var" path="LIB_HOME/sapxmltoolkit.jar"/>
<classpathentry kind="lib" path="xxx/com.sap.portal.runtime.application.jcoclient_api.jar"/>
<classpathentry kind="lib" path="xxx/com.sap.portal.runtime.application.jcoclient_core.jar"/>
<classpathentry kind="lib" path="xxx/prtapi.jar"/>
<classpathentry kind="lib" path="xxx/prtcoreservice.jar"/>
<classpathentry kind="lib" path="xxx/prtportalservice.jar"/>
<classpathentry kind="lib" path="xxx/sapjco.jar"/>
<classpathentry kind="lib" path="xxx/tc_sec_api.jar"/>
<classpathentry kind="lib" path="xxx/urlgeneratorapi.jar"/>
<classpathentry kind="lib" path="dist/External_Lib/SP18_libs/clientinfo.jar"/>
<classpathentry kind="lib" path="dist/External_Lib/SP18_libs/connectorimpl.jar"/>
<classpathentry kind="lib" path="dist/External_Lib/SP18_libs/jcoclientapi.jar"/>
<classpathentry kind="lib" path="dist/External_Lib/SP18_libs/landscapeapi.jar"/>
<classpathentry kind="lib" path="dist/External_Lib/SP18_libs/remote_client.jar"/>
<classpathentry kind="lib" path="dist/External_Lib/SP18_libs/umapi.jar"/>
<classpathentry kind="lib" path="dist/External_Lib/SP18_libs/usermanagementapi.jar"/>
<classpathentry kind="lib" path="dist/External_Lib/SP18_libs/wcmapi.jar"/>
<classpathentry kind="lib" path="dist/External_Lib/SP18_libs/wcmutil.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/SAP JVM 6 (61_REL i486 opt)"/>
<classpathentry kind="lib" path="xxx/fop-1.1.jar"/>
<classpathentry kind="lib" path="xxxcommons-io-1.3.1.jar"/>
<classpathentry kind="lib" path="xxxxmlgraphics-commons-1.5.jar"/>
<classpathentry kind="output" path="classes.api"/>
</classpath>
インターネットで調べると、特にfop-1.1.jを追加しますarはlink
に基づいていますが、問題はまだ発生します。私に助言してください。
それはとてもちょうどFOP 1.1を追加するバージョンの不一致のように見えるが、おそらく十分ではありません/ oを - あなたは削除する必要がFOPの新しいまたは古いバージョンであってもよいです。しかし、私はちょうどあなたがあなたの問題について何かを知るために十分な情報を提供していないと推測しています。 – Gimby
@Gimby:クラスパスファイルが含まれています。私を見て助けてください –