1 Reply Latest reply on Mar 18, 2014 7:25 PM by R V

    Arquillian: PersistenceContext is not injected when running multi-module Maven project

    R V Newbie

      Hi there,

       

      I'm running a JPA application with Arquillian using the Embedded GlassFish application server and Hibernate as the ORM layer.

      It's all fine if I run it in a single Maven project. However I got the below exception when some dependencies (like Hibernate) is coming from an other Maven module.

       

      Has anyone seen this before?

       

       

      [ERROR] An annotation processor threw an uncaught exception.
      [ERROR] Consult the following stack trace for details.
      [ERROR] java.lang.NoSuchFieldError: CANONICAL_MODEL_PREFIX_DEFAULT
      [ERROR] at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProperties.<clinit>(CanonicalModelProperties.java:37)
      [ERROR] at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:338)
      [ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
      [ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
      [ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
      [ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
      [ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
      [ERROR] at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
      [ERROR] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
      [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:439)
      [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:353)
      [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:342)
      [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:333)
      [ERROR] at com.sun.tools.javac.Main.compile(Main.java:94)
      [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      [ERROR] at java.lang.reflect.Method.invoke(Method.java:601)
      [ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:554)
      [ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:161)
      [ERROR] at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:605)
      [ERROR] at org.apache.maven.plugin.TestCompilerMojo.execute(TestCompilerMojo.java:161)
      [ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
      [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
      [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
      [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
      [ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
      [ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
      [ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
      [ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
      [ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
      [ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
      [ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
      [ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
      [ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
      [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      [ERROR] at java.lang.reflect.Method.invoke(Method.java:601)
      [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
      [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
      [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
      [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
      
        • 1. Re: Arquillian: PersistenceContext is not injected when running multi-module Maven project
          R V Newbie

          I had the org.glassfish.jersey.media Maven dependency in my pom.xml which had EclipseLink dependencies packaged in it.

           

          Adding exclusions to EclipseLink persistence resolved the conflict:

           

          <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
            <version>${jersey.version}</version>
            <scope>provided</scope>
            <exclusions>
                    <exclusion>
                        <groupId>org.eclipse.persistence</groupId>
                        <artifactId>*</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>