Configure EclipseLink as the JPA provider as usual (in modules/system/layers/base/org/eclipse/persistence/main).
Create Bean:
@Singleton
@Startup
public class Example
{
@PostConstruct
public void postConstruct()
{
final MOXyJsonProvider provider = new MOXyJsonProvider();
provider.isWriteable(MOXyJsonProvider.class,
MOXyJsonProvider.class, new Annotation[0],
MediaType.APPLICATION_JSON_TYPE);
}
}
Doesn't matter whatsoever which actual Class you pass to isWriteable, except it must be one that can be serialized by MOXy.
Default configuration in module.xml: won't find javax/ws/rs/core/MediaType
Add <resource-root path="javax.ws.rs-api-2.0.1.jar"/> to module.xml: loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/ws/rs/core/MediaType"
Don't supply javax.ws.rs:javax.ws.rs-api and org.eclipse.persistence:org.eclipse.persistence.moxy in your EAR's lib: no change: loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/ws/rs/core/MediaType"
<exclude path="org/eclipse/persistence/jaxb/*"/> and <exclude path="org/eclipse/persistence/internal/jaxb/*"/> in module.xml: java.lang.ClassNotFoundException: org.eclipse.persistence.jaxb.javamodel.JavaModel from [Module "org.eclipse.persistence:main" from local module loader @5579bb86 (finder: local module finder @5204062d (roots: /opt/wildfly/modules,/opt/wildfly/modules/system/layers/base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
... 59 more
I guess the last one would be the correct configuration: tell WildFly to ignore the MOXy stuff in eclipselink.jar, since it's only used as JPA provider, and instead supply javax.ws.rs:javax.ws.rs-api and org.eclipse.persistence:org.eclipse.persistence.moxy in your EAR's lib/.
This should work, but for some reason WildFly tries to load classes using the org.eclipse.persistence:main loader instead of the application loader.