I am getting the below error on JBoss 8 server.
17:36:07,482 ERROR [io.undertow.request] (default task-22) UT005023: Exception handling request to /user/XMLPreviewer: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/sun/org/apache/xml/internal/serialize/XMLSerializer
I have got the following dependencies in my pom:
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxp-api</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
<dependency>
<groupId>javax.xml.parsers</groupId>
<artifactId>jaxp-api</artifactId>
<version>1.4.5</version>
</dependency>
You are asking for trouble including any of those jars in your application.
The APIs and implementation provided by those jars exist in the JDK (as far back as Java 5) and you will find life far simpler if you make use of those instead of adding additional (possibly obsolete) versions to your application.
Furthermore, Java EE may specify further extensions to the standard (JDK provided) XML APIs (JAXB 2.2 for example) and therefore provide this extended implementation to your application transparently.
Therefore, rather than the set of dependencies you have above, if you add the following instead:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
The <scope>provided</scope>
element is important because this jar does not need to be deployed with your application. The classes it contains are provided by your Java EE 7 server implementation.
If you add this dependency then you can also discard other dependencies such as the servlet-api, jsp-api, ejb-api, etc as these are all included in the javaee-api dependency.