Hello,
we use JIRA Software 7.3.5 with Adaptavist Script Runner for JIRA 4.3.16.
I downloaded Apache POI 3.16 and put the following files into atlassian-jira/WEB-INF/lib:
I tried this code in the Script Console in the admin section
import java.io.File import java.io.FileInputStream import java.io.FileOutputStream import org.apache.poi.xwpf.usermodel.* File inputFile = new File("C:\\Program Files\\Atlassian\\Application Data\\JIRA\\scripts\\files\\input.docx"); FileInputStream fis = new FileInputStream(inputFile.getAbsolutePath()); FileOutputStream fos = new FileOutputStream("C:\\Program Files\\Atlassian\\Application Data\\JIRA\\scripts\\files\\output.docx"); XWPFDocument document = new XWPFDocument(fis) document.write(fos)
and got the following error:
javax.xml.stream.FactoryConfigurationError: Provider for class javax.xml.stream.XMLEventFactory cannot be created at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:41) at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161) at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141) at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:97) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:324) at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37) at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:116) at testApachePOI.run(testApachePOI.groovy:11) Caused by: java.lang.RuntimeException: Provider for class javax.xml.stream.XMLEventFactory cannot be created ... 8 more Caused by: java.util.ServiceConfigurationError: javax.xml.stream.XMLEventFactory: Provider com.ctc.wstx.stax.WstxEventFactory not found ... 8 more
I tried then the same with the docx4j library:
import java.io.File import org.docx4j.Docx4J import org.docx4j.openpackaging.packages.WordprocessingMLPackage WordprocessingMLPackage wordMLPackage = Docx4J.load(new File("C:\\Program Files\\Atlassian\\Application Data\\JIRA\\scripts\\files\\input.docx")) Docx4J.save(wordMLPackage, new File("C:\\Program Files\\Atlassian\\Application Data\\JIRA\\scripts\\files\\output.docx"))
and got this error:
javax.xml.stream.FactoryConfigurationError: Provider for class javax.xml.stream.XMLInputFactory cannot be created at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:728) at org.docx4j.openpackaging.io3.Load3.get(Load3.java:134) at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:462) at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:379) at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:270) at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:250) at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:168) at org.docx4j.Docx4J.load(Docx4J.java:236) at org.docx4j.Docx4J$load.call(Unknown Source) at testDocx.run(testDocx.groovy:5) Caused by: java.lang.RuntimeException: Provider for class javax.xml.stream.XMLInputFactory cannot be created ... 10 more Caused by: java.util.ServiceConfigurationError: javax.xml.stream.XMLInputFactory: Provider com.ctc.wstx.stax.WstxInputFactory not found ... 10 more
My goal is to open a word document (docx) during a workflow transition in order to manipulate some fields and to save the new document.
I did some searching on the internet and i found out, that apache poi needs prior java 6 one of these libs to work: xml-apis.jar, stax-apis.jar or xercesImpl.jar.
In my lib folder the files are all there:
According to the systems information tab in the admin section, our jira is using java 1.8.0_102. The FAQ section from Apache POI (https://poi.apache.org/faq.html#faq-N101E6 No. 18) suggests to disable the above mentioned libs, if you use java 6+. But this solution is not possible, because some plugins need these dependencies.
I hope someone can help me to sort this out.
Thank you in advance
I have created a post-function to test the codes above and it worked fine.
In both cases the new docx file will be created.
My main problem ist solved now, but i am curious why the codes wont run in the Script Console in the admin section. I hope someone can answer this question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.