Java 使用xsl转换为PDF时出错
在使用xsl(java代码创建xml并在运行时应用xsl)将xml转换为pdf时,我面临一个奇怪的问题 代码部署在Jboss服务器上。当代码被执行时,它会失败,并出现以下错误Java 使用xsl转换为PDF时出错,java,xml,xslt,Java,Xml,Xslt,在使用xsl(java代码创建xml并在运行时应用xsl)将xml转换为pdf时,我面临一个奇怪的问题 代码部署在Jboss服务器上。当代码被执行时,它会失败,并出现以下错误 10:50:49,068 ERROR [stderr] (http--0.0.0.0-9080-3) Caused by: java.lang.reflect.InvocationTargetException 10:50:49,068 ERROR [stderr] (http--0.0.0.0-9080-3)
10:50:49,068 ERROR [stderr] (http--0.0.0.0-9080-3) Caused by: java.lang.reflect.InvocationTargetException
10:50:49,068 ERROR [stderr] (http--0.0.0.0-9080-3) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:50:49,069 ERROR [stderr] (http--0.0.0.0-9080-3) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
....
10:50:49,070 ERROR [stderr] (http--0.0.0.0-9080-3) Caused by: java.lang.StackOverflowError
10:50:49,070 ERROR [stderr] (http--0.0.0.0-9080-3) at sun.misc.FloatingDecimal.dtoa(FloatingDecimal.java:532)
10:50:49,070 ERROR [stderr] (http--0.0.0.0-9080-3) at sun.misc.FloatingDecimal.<init>(FloatingDecimal.java:459)
在打印之前,似乎错误就出现在这一点上
transformer.transform(xmlSrc, res);
下面是xml。尽管这是动态生成的,但我还是从日志中复制了它,并将其放在这里以供参考。随附的还有xslt
<WOC_Form>
<Evaluators>
<Evaluators>
<department>Clinical Research</department>
<evaluator_name>DISPNAME hod_clinicalres_user1</evaluator_name>
<status>Accepted</status>
<vested_interest>no</vested_interest>
<doi_approver>N/A</doi_approver>
</Evaluators>
<Evaluators>
<department>Allied Health Administration</department>
<evaluator_name>DISPNAME hod_aha_user1</evaluator_name>
<status>Accepted</status>
<vested_interest>no</vested_interest>
<doi_approver>N/A</doi_approver>
</Evaluators>
</Evaluators>
<Attachments>
<Attachments>
<object_name>WOC_18-06-2015_hod_fammed_user1.pdf</object_name>
<owner_name>DISPNAME woc_req_user1</owner_name>
<r_creation_date>7/24/2015 11:58:09 AM</r_creation_date>
</Attachments>
<Attachments>
<object_name>xCP 2.1 Sample Application - ICM 2.1.0.pdf</object_name>
<owner_name>DISPNAME woc_buyer_user1</owner_name>
<r_creation_date>7/24/2015 12:03:30 PM</r_creation_date>
</Attachments>
</Attachments>
<requesting_department>Allied Health Administration</requesting_department>
<institutions>
<institutions-value index="0">JH</institutions-value>
<institutions-value index="1">JC</institutions-value>
<institutions-value index="2">JR</institutions-value>
</institutions>
<vendoe_for_woc>erferewr</vendoe_for_woc>
<dh_ch_requesting_dept>DISPNAME hod_aha_user1</dh_ch_requesting_dept>
<total_waiver_of_competition>4433</total_waiver_of_competition>
<specialist_dept/>
<specialist_name/>
<is_approved_by_specialist>0</is_approved_by_specialist>
<description_of_goods_servic>dsfdsf</description_of_goods_servic>
<background>sdf</background>
<req_of_goods_or_services>sdfds</req_of_goods_or_services>
<proposals_from_vendors>sfdsf</proposals_from_vendors>
<negotiations_and_bafo>sdfsd</negotiations_and_bafo>
<calculation_of_contract_sum>ret</calculation_of_contract_sum>
<contract_period>ewte</contract_period>
<reason_request1>0</reason_request1>
<reason_request2>0</reason_request2>
<reason_request3>0</reason_request3>
<reason_request4>0</reason_request4>
<reason_request5>0</reason_request5>
<reason_request6>1</reason_request6>
<reason_request7>0</reason_request7>
<reason_request8>0</reason_request8>
<dh_ch_requesting_dept>DISPNAME hod_aha_user1</dh_ch_requesting_dept>
<dh_ch_approval_time>7/24/2015 12:00:50 PM</dh_ch_approval_time>
<specialist_name/>
<specialist_approval_time>nulldate</specialist_approval_time>
<mmd_manager_name>DISPNAME woc_mmd_mgr_user1</mmd_manager_name>
<mmd_mgr_approval_time>7/24/2015 12:07:09 PM</mmd_mgr_approval_time>
<finance_controller_name/>
<finance_controller_approval>nulldate</finance_controller_approval>
设置JAVA\u OPTS=%USER\u MEM\u ARGS%-Djboss.server.base.dir=%JBOSS\u base\u dir%-Duser.name=dmadmin
我曾尝试将-Xss从256k增加到1024k和2048k,但没有效果
set USER_MEM_ARGS=-Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m -Xss1024k -XX:+DisableExplicitGC -Xrs
设置JAVA\u OPTS=%USER\u MEM\u ARGS%-Djboss.server.base.dir=%JBOSS\u base\u dir%-Duser.name=dmadmin
我只是创建了一个2页的pdf,所以它不需要比这个更多的记忆。此外,对于代码工作的虚拟机,它使用默认设置,即-Xss256k
这些虚拟机是同一虚拟机的克隆,因此具有完全相同的Java和Jboss版本(和设置)。我弄不清是什么问题。它可能与环境有关,还是与xslt代码有关
任何帮助都将不胜感激,因为我真的遇到了麻烦
谢谢stacktrace显示FOP内的stackoverflow错误:
org.apache.fop.fo.flow.table.TableColumn.toString calling
org.apache.fop.fo.properties.PercentLength.toString(PercentLength.java:121) calling
org.apache.fop.datatypes.LengthBase.toString calling TableColumn toString
这是FOP中存在bug的明显迹象
下面是一个报告相同错误的示例,其中提到了消除错误的FOP修补版本。你能检查你的四台服务器吗?即使它们都是同一个VM的克隆,如果它们真的运行同一版本的FOP吗?可以在你使用的XSLT引擎中找到完整的stacktrace。。。沙兰?还是撒克逊人?非常感谢。我可以从哪里下载修补过的jar?bug报告有一个指向存在问题的.java文件的链接,但是,我找不到jar。我使用最新版本的FOP(1.1和2.0)进行了测试,它们都生成了一个没有错误的输出PDF,因此我建议使用最新版本。如果当前使用的版本非常旧,但中的代码似乎与您的非常相似,则可能需要调整代码。(披露:我是一名FOP开发人员,尽管现在不是很活跃)
set USER_MEM_ARGS=-Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m -Xss1024k -XX:+DisableExplicitGC -Xrs
org.apache.fop.fo.flow.table.TableColumn.toString calling
org.apache.fop.fo.properties.PercentLength.toString(PercentLength.java:121) calling
org.apache.fop.datatypes.LengthBase.toString calling TableColumn toString