Issue
I've created with Axis2 XMLBeans (Version 1.6.2) a client to connect some CRM Dynamics webservices. The client works perfectly fine when I launch it as a standalone project, but when I integrate it into the maven structure of the project and I try to consume the service, I get the following error:
ERROR [http-bio-8080-exec-13][render_portlet_jsp:154] java.lang.ClassFormatError: Incompatible magic value 4022320623 in class file schemaorg_apache_xmlbeans/system/sC40263DCBC25A143E59FC252DB52E714/TypeSystemHolder at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2889) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1170) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556) at org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(XmlBeans.java:769) at com.microsoft.schemas.crm._2007.webservices.RetrieveDocument.(RetrieveDocument.java:19) at com.microsoft.schemas.crm._2007.webservices.RetrieveDocument$Factory.newInstance(RetrieveDocument.java:147)
I've created the Axis code who's giving the error via Maven with the following plugin:
<plugins>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.6.2</version>
<executions>
<execution>
<goals>
<goal>wsdl2code</goal>
</goals>
<configuration>
<packageName>myPackage</packageName>
<wsdlFile>src/main/resources/CrmService.wsdl</wsdlFile>
<databindingName>xmlbeans</databindingName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Any idea what is happening? The error indicates normally that the class is corrupted, but I've generated several times (and with different versions of Axis2) and the result is the same...
Solution
Just find the solution. In order to include the generated classes into the jar, I've added this lines:
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>target/generated-sources/axis2/wsdl2code/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>target/generated-sources/axis2/wsdl2code/src</directory>
<filtering>true</filtering>
</resource>
</resources>
After changing the filtering of the resources directory to false, the problem disappears.
Answered By - gandrold
Answer Checked By - Katrina (JavaFixing Volunteer)