Problem with docx4j in jira plugin Edited

I have this error in jira : 

java.lang.NoClassDefFoundError: Could not initialize class org.docx4j.openpackaging.parts.DocPropsCorePart

and in my console log i have this error :  

[INFO] [talledLocalContainer] 2017-12-07 11:26:39,714 http-bio-2990-exec-14 WARN admin 686x504x1 1fzlz83 127.0.0.1 /secure/docxManager.jspa [docx4j.openpackaging.parts.JaxbXmlPartXPathAware] .. and mark not supported

[INFO] [talledLocalContainer] 2017-12-07 11:26:39,715 http-bio-2990-exec-14 ERROR admin 686x504x1 1fzlz83 127.0.0.1 /secure/docxManager.jspa [docx4j.openpackaging.packages.WordprocessingMLPackage] com.ctc.wstx.stax.WstxInputFactory cannot be cast to javax.xml.stream.XMLInputFactory

[INFO] [talledLocalContainer] javax.xml.bind.JAXBException: com.ctc.wstx.stax.WstxInputFactory cannot be cast to javax.xml.stream.XMLInputFactory

[INFO] [talledLocalContainer] - with linked exception:

[INFO] [talledLocalContainer] [java.lang.ClassCastException: com.ctc.wstx.stax.WstxInputFactory cannot be cast to javax.xml.stream.XMLInputFactory]

 

My class docx4j : 

public class DocxManager extends JiraWebActionSupport {

private static Logger log = LoggerFactory.getLogger(ReleasePlugin.class);
private ActiveObjects ao;
private IssueManager issueManager;

public DocxManager(ActiveObjects ao) {
try {
this.ao = ao;
this.issueManager = ComponentManager.getInstance().getIssueManager();
} catch (Exception e) {
e.printStackTrace();
log.error("Erreur getProjectNames:" + e.getMessage());
}
}

public String doExecute(){
try {
String xhtml =
"<table><tr><th colspan=\"3\" style=\"border:1px solid #ddd;padding:8px;padding-top:12px;padding-bottom:12px;text-align:left;background-color:#dec934;text-align:center;\">IDENTITÉ DU DOCUMENT</th></tr><tr><td style=\"border:1px solid #ddd;padding:8px;\"><strong>Type de document</strong></td><td style=\"border: 1px solid #ddd;padding:8px;\">Note de publication -- version progicielle ...</td></tr><tr><td style=\"border: 1px solid #ddd; padding: 8px;\"><strong>État</strong></td><td style=\"border: 1px solid #ddd;padding:8px;\">Final - V1.0</td></tr><tr><td style=\"border: 1px solid #ddd;padding:8px;\"><strong>Progiciel</strong></td><td style=\"border:1px solid #ddd;padding:8px;\">TEST</td></tr><tr><td style=\"border:1px solid #ddd;padding:8px;\"><strong>Version progicielle</strong></td><td style=\"border:1px solid #ddd;padding:8px;\">2017 ...</td></tr><tr><td><strong> Date de version </strong></td><td>08/11/2017</td></tr></table>";
// To docx, with content controls
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
log.error("test1");
XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage);
// XHTMLImporter.setDivHandler(new DivToSdt());
log.error("test2");

wordMLPackage.getMainDocumentPart().getContent().addAll(
XHTMLImporter.convert(xhtml, null));
wordMLPackage.save(new File("./OUT_from_XHTML.docx"));
log.error("test3");

System.out.println(XmlUtils.marshaltoString(wordMLPackage
.getMainDocumentPart().getJaxbElement(), true, true));

// wordMLPackage.save(new java.io.File(System.getProperty("user.dir")
// + "/OUT_from_XHTML.docx"));

// Back to XHTML

HTMLSettings htmlSettings = Docx4J.createHTMLSettings();
htmlSettings.setWmlPackage(wordMLPackage);


// output to an OutputStream.
OutputStream os = new ByteArrayOutputStream();

// If you want XHTML output
Docx4jProperties.setProperty("docx4j.Convert.Out.HTML.OutputMethodXML", true);
Docx4J.toHTML(htmlSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);

System.out.println(((ByteArrayOutputStream) os).toString());


} catch (Exception e) {
e.printStackTrace();
}
return null;
}

}

 

 pom.xml :

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>jira-version-plugin</name>
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-ImportXHTML</artifactId>
<version>3.3.6</version>
</dependency>
<dependency>
<groupId>com.atlassian.activeobjects</groupId>
<artifactId>activeobjects-plugin</artifactId>
<version>0.23.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<!--<dependency>-->
<!--<groupId>javax.servlet</ groupId>-->
<!--<artifactId>servlet-api</ artifactId>-->
<!--<version>2.4</ version>-->
<!--<scope>fourni</ scope>-->
<!--</ dependency>-->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2-atlassian-1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>3.3.6</version>
<exclusions>
<exclusion>
<groupId>javax.xml.stream</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--<dependency>-->
<!--<groupId>javax.xml.stream</groupId>-->
<!--<artifactId>stax-api</artifactId>-->
<!--<version>1.0-2</version>-->
<!--</dependency>-->

<!--<dependency>-->
<!--<groupId>javax.xml.bind</groupId>-->
<!--<artifactId>jaxb-api</artifactId>-->
<!--<version>2.2.4</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.sun.xml.bind</groupId>-->
<!--<artifactId>jaxb-impl</artifactId>-->
<!--<version>2.2.11</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.sun.xml.bind</groupId>-->
<!--<artifactId>jaxb-core</artifactId>-->
<!--<version>2.2.11</version>-->
<!--</dependency>-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jira.version>6.4.6</jira.version>
<amps.version>5.0.13</amps.version>
<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
<testkit.version>5.2.26</testkit.version>
</properties>
</project>

 

I need to resolve this error before 2 days, guys i believe in you.

Thanks you in advance.

0 answers

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Jul 25, 2018 in Marketplace Apps

Jira Cloud and Bitbucket Cloud Integration with Microsoft Teams

One of the newest products in the Microsoft family - Microsoft Teams,  is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...

717 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you