Yet another JAXB compatability issue
Hello Metro community,
I'm running into what seems as some compatibility issues while migrating a
legacy application to a new platform - Java SE 7, Java EE 6, JBoss AS 7.1.1.
JBoss AS 7.1.1 provides CXF 2.4.6. Using Maven and cxf-codegen-plugin:2.4.6
code gets generated from wsdl file.
Unfortunately tests which reference generated code fail with:
foo.Bar$JaxbAccessorF_aField cannot be cast to
Does anyone know what could be the problem here and how to fix it?
Please correct me if wrong, but it seems to me this is caused by some
compatibility issue, more specifically JAXB versions, one version used to
generate code and other at (test) runtime.
I'm using Java SE 7 to run tests (and maven 3.0.4). If I'm not mistaken,
Java SE 7 update 5 embeds JAXB 2.2.4, and JAXB 2.2 is part of Java EE 6
provided APIs and JBoss 7.1.1 provides appropriate implementation.
I guess internal part in
com.sun.xml.internal.bind.v2.runtime.reflect.Accessor suggests that
something is using Java SE internal/embedded JAXB, while something else is
using non-internal variant or different incompatible version.
Not sure who is using what but I assume cxf-codegen-plugin:2.4.6 is using
non-internal JAXB 2.2.
I've tried to configure endorsing jaxb-impl, jaxb-api and jaxb-xjc in both
maven-compiler-plugin, and maven-surefire-plugin (use
maven-dependency-plugin to copy these libs in target/endorsed, and then in
compiler and tests configure this as endorsed directory) but I'm still
getting same error.
Then I found this post
even after configuring maven to endorse only jaxb-api, same
ClassCastException gets thrown.
Any constructive ideas are welcome. Thanks in advance!