java - Error when converting to PDF using xsl -


i facing strange problem when converting xml pdf using xsl (java code creates xml , applies xsl @ runtime).

the code deployed on jboss server. when code executed, fails following error

    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)           @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)  10:50:49,069 error [stderr] (http--0.0.0.0-9080-3)           @ 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)           @ sun.misc.floatingdecimal.dtoa(floatingdecimal.java:532)  10:50:49,070 error [stderr] (http--0.0.0.0-9080-3)           @ sun.misc.floatingdecimal.<init>(floatingdecimal.java:459) 

below relevant java code

public string transformwocformtopdf(idfid xmlid,string folderid,string username)throws dfexception {      system.out.println("preparing...");  dateformat dateformat = new simpledateformat("dd-mm-yyyy");  date date= new date();  prop=readproperties();  idfsysobject pdfobject = (idfsysobject)session.newobject("jh_exported_doc");  system.out.println("object created");  bytearrayoutputstream pdfresult = new bytearrayoutputstream();  try  {     system.out.println("in try");     fopfactory fopfactory = fopfactory.newinstance();            fouseragent fouseragent = fopfactory.newfouseragent();           fop fop = fopfactory.newfop(mimeconstants.mime_pdf,fouseragent, pdfresult);     system.out.println("fop object created");      // xslt object docbase                  idfid objid = (idfid) session.getidbyqualification("dm_document object_name='"+ form_xslt_obj_name + "'");     system.out.println("object id created  "+objid.getid());     idfsysobject xsltobj = (idfsysobject) session.getobject(objid);             // xslt content stream     source xsltsrc = new streamsource(xsltobj.getcontent());     system.out.println("xsltsrc  --  "+xsltsrc.tostring());     // create new transformer style sheet      transformerfactory factory = transformerfactory.newinstance();     transformer transformer = factory.newtransformer(xsltsrc);     transformer.setparameter("versionparam", "1.0");      idfsysobject xmlobject = (idfsysobject) session.getobject(xmlid);         // xml content stream                  source xmlsrc = new streamsource(xmlobject.getcontent());        system.out.println("fetched xml source  "+xmlsrc.tostring());     // setup input xslt transformation            // resulting sax events (the generated fo) must piped through fop     result res = new saxresult(fop.getdefaulthandler());     system.out.println("res -- "+res.tostring());      // start xslt transformation , fop processing     transformer.transform(xmlsrc, res);           system.out.println("size of pdf"+pdfresult.size());     //idfsysobject pdfobject = (idfsysobject)session.newobject("dm_document");     system.out.println("object created");     pdfobject.setobjectname(form_pdf_obj_name+"_"+dateformat.format(date)+"_"+username);             pdfobject.setcontenttype("pdf");             pdfobject.setcontent(pdfresult);          system.out.println("setting content");     pdfobject.link(folderid);     pdfobject.save();            system.out.println("path "+pdfobject.getobjectid().tostring());  } catch (exception e) {     system.out.println("inside catch block");     e.printstacktrace(); } {     try {         pdfresult.close();     } catch (ioexception e) {         // todo auto-generated catch block         e.printstacktrace();     } } return pdfobject.getobjectid().getid();  } 

it seems error coming @ point println's before getting printed

transformer.transform(xmlsrc, res); 

below xml. though generated on fly, have copied logs , put here reference. attached xslt well.

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

the strange part whole thing works fine on 2 servers (vms) fails on 2 servers (vms) error mentioned above (each server separate vm jboss installed). vms windows , have identical jboss configuration.

i did google search , found couple of potential reasons problem. 1 reason recursive calls in xslt resulting in stackoverflow error. however, why transformation work in other 2 vms not make sense. there possibility there difference in test data (which not able catch) causing recursive behavior. have linked xsl here, in case xslt expert in forum notices drastically wrong xsl.

http://filedb.experts-exchange.com/incoming/2015/08_w32/927711/wocformxslt.xsl

second potential reason found there may not enough java memory allocated. jboss code deployed has following memory arguments

set user_mem_args=-xms1024m -xmx1024m -xx:permsize=256m -xx:maxpermsize=256m -xss256k -xx:+disableexplicitgc -xrs 

set java_opts=%user_mem_args% -djboss.server.base.dir=%jboss_base_dir% -duser.name=dmadmin

i have tried increasing -xss 256k 1024k , 2048k did not help

set user_mem_args=-xms1024m -xmx1024m -xx:permsize=256m -xx:maxpermsize=256m -xss1024k -xx:+disableexplicitgc -xrs 

set java_opts=%user_mem_args% -djboss.server.base.dir=%jboss_base_dir% -duser.name=dmadmin

i creating 2 page pdf should not need more momory this. moreover, vms code working, works default settings, -xss256k.

these vms clone of same vm, have identical java , jboss versions (and settings). not able make out problem. related environment or related xslt code?

any highly appreciated have hit wall.

thank you

the stacktrace shows stackoverflow error inside fop:

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 

this clear sign of bug inside fop.

here bug report reports same error , mentions patched version of fop eliminates error. can check 4 servers - if clone of same vm - if run same version of fop?


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -