Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-6429

Cannot use EclipseLink as JPA provider and MOXy as JAX-RS provider

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Minor
    • None
    • 10.0.0.Final
    • None
    • Hide

      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.

      Show
      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.

    Description

      When using EclipseLink-2.6.0 as JPA provider (set up in modules/system/layers/base/org/eclipse/persistence/main), then MOXy cannot be used as JSON provider for JAX-RS.

      Note that the eclipselink-2.6.0.jar file contains MOXy, which might be a possible cause of this problem.

      As it currently is, MOXy CANNOT be used as JAX-RS JSON provider when using EclipseLink as JPA provider. You can use MOXy when you create everything yourself, but Resteasy cannot create the MOXy Marshaller/Unmarshaller.

      Attachments

        Activity

          People

            jgreene@redhat.com Jason Greene
            fwunderlich Florian Wunderlich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: