1 2 Previous Next 20 Replies Latest reply on Oct 8, 2013 5:40 PM by Jonathan Fuerth

    Errai JPA Failing To Compile

    Charles Odili Apprentice

      Here is my first take on Errai's client-side JPA. I've added the errai-jpa-client dependency to my pom file, and added the module dependency to my .gwt.xml file. However, this makes the project to generate errors. I felt my code usage was wrong so I commented all @Inject EntityManager em; declarations and its use, but the errors are still there.  Here's how my GWT module file looks:

       

      <module rename-to="app">

          <inherits name="org.jboss.errai.common.ErraiCommon"/>   

          <inherits name="org.jboss.errai.bus.ErraiBus"/>   

          <inherits name="org.jboss.errai.ioc.Container"/>

          <inherits name="org.jboss.errai.jpa.JPA"/>       

          <inherits name="org.jboss.errai.enterprise.CDI"/>

          <inherits name="org.jboss.errai.databinding.DataBinding" />   

      </module>

       

      And here is the error: http://ur1.ca/ecvdy

       

      Guess am missing something again, any hints?

        • 1. Re: Errai JPA Failing To Compile
          Jonathan Fuerth Master

          Hi Charles,

           

          It looks like your app is set up properly for ErraiJPA. The code generator is definitely getting started.

           

          It appears this error is the one we need to look into:

           

          1. [INFO] Caused by: java.lang.ClassCastException: org.jboss.errai.codegen.meta.impl.gwt.GWTTypeVariable cannot be cast to org.jboss.errai.codegen.meta.MetaClass

           

          This indicates some sort of bug in our JPA code generator. However, I also notice from your log output that you're using Errai 2.1.0.Final. This is quite old now, and we have fixed several bug related to the handling of generics in our MetaClass API since then. Can you try again with Errai 3.0.0.20130604-M1 (first milestone of Errai 3.0; we released it last week).

           

          You will find a few compile errors after you change from 2.1.0 to 3.0 M1, but most of them can be resolved simply by doing an "organize imports" in Eclipse.

           

          -Jonathan

          • 2. Re: Errai JPA Failing To Compile
            Charles Odili Apprentice

            The project is based on the kitchen sink archetype. I am actually using the archetype from http://goo.gl/FS3Pz, and this is because the 2.3.2.Final version from http://goo.gl/LF0M4 fails with the following error:

             

            [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project standalone-pom: The desired archetype does not exist (org.jboss.errai.archetypes:jboss-errai-kitchensink-archetype:2.3.2.Final) -> [Help 1]

             

            Where is the 3.0 M1 archetype, how can I make the change in my kitchenSink pom.xml file since there's no version specified for the errai dependencies, but I noticed this :

             

            <properties>

                 ...

                 <version.org.jboss.bom>1.0.5.CR2</version.org.jboss.bom>

                 ...

            </properties>

             

            and then this :

             

            <dependencyManagement>

                                <dependencies>

                 ...

                

                 <dependency>

                        <groupId>org.jboss.bom</groupId>

                        <artifactId>jboss-javaee-6.0-with-errai</artifactId>

                        <version>${version.org.jboss.bom}</version>

                        <type>pom</type>

                        <scope>import</scope>

                 </dependency>

                 ...

              </dependencies>

            </dependencyManagement>

            • 3. Re: Errai JPA Failing To Compile
              Jonathan Fuerth Master

              Hi Charles,

               

              Aha, the way the Kitchen Sink pom is set up by the archetype, it's impossible for you or us to change the version of Errai you're building against. We need to send a pull request to the jdf-boms project, then wait for them to publish a new release.

               

              May I suggest you start with a different project? The Kitchen Sink is our only demo app that suffers from this "you can't change the Errai version" problem. Here are some good starting points:

               

              https://github.com/errai/errai/tree/2.4/errai-demos/errai-jpa-demo-basic -- this "Basic CRUD demo" is a pure client-side Errai app that showcases our JPA features.

               

              https://github.com/errai/errai/tree/2.4/errai-demos/errai-jpa-demo-todo-list -- a more advanced demo that shows multi-page navigation, client-side JPA, automatic data synchronization, bean validation, and more. This demo has server-side code as well, and must be deployed to JBoss AS 7 or EAP 6. You also need to set up a data source for it (see the README).

               

              Hope that helps.

              -Jonathan

              • 4. Re: Errai JPA Failing To Compile
                Charles Odili Apprentice

                I made a new project with the 2.3.2.Final CDI archetype, then added errai-jpa and errai-databinding to the pom and gwt file. It compiled, but failed to deploy to my local JBoss AS server, displaying the errors shown here : http://ur1.ca/eecb8

                • 5. Re: Errai JPA Failing To Compile
                  Jonathan Fuerth Master

                  Hi Charles,

                   

                  I believe that error happens when you build the app with the jetty profile and then deploy to AS7. All of our archetype projects default to jetty because that's what Dev Mode uses. You need to activate the jboss7 profile explicitly when you build a .war, like this:

                   

                      mvn clean package -Pjboss7

                   

                  Note the "clean": this is important when switching profiles, because it cleans up some files under WEB-INF that would have been left behind from a build with a different profile.

                   

                  -Jonathan

                  • 6. Re: Errai JPA Failing To Compile
                    Charles Odili Apprentice

                    I have upgraded and made a new project using 2.3.2.Final, and this error still comes up. Note that I am not using any Errai-JPA code yet, I've only added the <inherits name="org.jboss.errai.jpa.JPA"/> to my gt.xml file ??

                     

                    Remove: name=ErraiClientPersistenceUnit

                    [INFO]    Scanning for additional dependencies: jar:file:/home/dilim/.m2/repository/org/jboss/errai/errai-jpa-client/2.3.2.Final/errai-jpa-client-2.3.2.Final.jar!/org/jboss/errai/jpa/client/local/ErraiEntityManagerProvider.java

                    [INFO]       Computing all possible rebind results for 'org.jboss.errai.jpa.client.local.ErraiEntityManager'

                    [INFO]          Rebinding org.jboss.errai.jpa.client.local.ErraiEntityManager

                    [INFO]             Invoking generator org.jboss.errai.jpa.rebind.ErraiEntityManagerGenerator

                    [INFO]                [ERROR] Generator 'org.jboss.errai.jpa.rebind.ErraiEntityManagerGenerator' threw an exception while rebinding 'org.jboss.errai.jpa.client.local.ErraiEntityManager'

                    [INFO] java.lang.RuntimeException: error generating method call for: addAttribute([org.jboss.errai.codegen.SnapshotMaker$2@38611c02])

                    [INFO]           at org.jboss.errai.codegen.builder.callstack.MethodCall.handleCall(MethodCall.java:121)

                    [INFO]           at org.jboss.errai.codegen.builder.callstack.AbstractCallElement.nextOrReturn(AbstractCallElement.java:46)

                    [INFO]           at org.jboss.errai.codegen.builder.callstack.LoadVariable.handleCall(LoadVariable.java:122)

                    [INFO]           at org.jboss.errai.codegen.builder.impl.AbstractStatementBuilder.generate(AbstractStatementBuilder.java:61)

                    [INFO]           at org.jboss.errai.codegen.BlockStatement.generate(BlockStatement.java:81)

                    [INFO]           at org.jboss.errai.codegen.meta.impl.build.BuildMetaMethod.toJavaString(BuildMetaMethod.java:344)

                    [INFO]           at org.jboss.errai.codegen.meta.impl.build.BuildMetaClass.membersToString(BuildMetaClass.java:768)

                    [INFO]           at org.jboss.errai.codegen.meta.impl.build.BuildMetaClass.toJavaString(BuildMetaClass.java:664)

                    [INFO]           at org.jboss.errai.codegen.meta.impl.build.BuildMetaClass.toJavaString(BuildMetaClass.java:564)

                    [INFO]           at org.jboss.errai.codegen.builder.impl.ClassBuilder.toJavaString(ClassBuilder.java:495)

                    [INFO]           at org.jboss.errai.jpa.rebind.ErraiEntityManagerGenerator.generateEntityManagerClass(ErraiEntityManagerGenerator.java:181)

                    [INFO]           at org.jboss.errai.jpa.rebind.ErraiEntityManagerGenerator.generate(ErraiEntityManagerGenerator.java:120)

                    [INFO]           at com.google.gwt.core.ext.GeneratorExtWrapper.generate(GeneratorExtWrapper.java:48)

                    [INFO]           at com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(GeneratorExtWrapper.java:60)

                    [INFO]           at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:647)

                    [INFO]           at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)

                    [INFO]           at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:78)

                    [INFO]           at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:268)

                    [INFO]           at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:257)

                    [INFO]           at com.google.gwt.dev.DistillerRebindPermutationOracle.getAllPossibleRebindAnswers(DistillerRebindPermutationOracle.java:91)

                    [INFO]           at com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.doFindAdditionalTypesUsingRebinds(WebModeCompilerFrontEnd.java:96)

                    [INFO]           at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.process(AbstractCompiler.java:254)

                    [INFO]           at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)

                    [INFO]           at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.compile(AbstractCompiler.java:173)

                    [INFO]           at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.compile(AbstractCompiler.java:288)

                    [INFO]           at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.access$400(AbstractCompiler.java:139)

                    [INFO]           at com.google.gwt.dev.jdt.AbstractCompiler.compile(AbstractCompiler.java:588)

                    [INFO]           at com.google.gwt.dev.jdt.BasicWebModeCompiler.getCompilationUnitDeclarations(BasicWebModeCompiler.java:97)

                    [INFO]           at com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.getCompilationUnitDeclarations(WebModeCompilerFrontEnd.java:52)

                    [INFO]           at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:569)

                    [INFO]           at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:33)

                    [INFO]           at com.google.gwt.dev.Precompile.precompile(Precompile.java:284)

                    [INFO]           at com.google.gwt.dev.Precompile.precompile(Precompile.java:233)

                    [INFO]           at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)

                    [INFO]           at com.google.gwt.dev.Compiler.run(Compiler.java:232)

                    [INFO]           at com.google.gwt.dev.Compiler.run(Compiler.java:198)

                    [INFO]           at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)

                    [INFO]           at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)

                    [INFO]           at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)

                    [INFO]           at com.google.gwt.dev.Compiler.main(Compiler.java:177)

                    [INFO] Caused by: java.lang.ClassCastException: org.jboss.errai.codegen.meta.impl.gwt.GWTTypeVariable cannot be cast to org.jboss.errai.codegen.meta.MetaClass

                    [INFO]           at org.jboss.errai.codegen.meta.impl.AbstractMetaClass.getTypeParmsString(AbstractMetaClass.java:88)

                    [INFO]           at org.jboss.errai.codegen.meta.impl.AbstractMetaClass.getFullyQualifiedNameWithTypeParms(AbstractMetaClass.java:67)

                    [INFO]           at org.jboss.errai.codegen.meta.impl.AbstractMetaClass.toString(AbstractMetaClass.java:769)

                    [INFO]           at java.lang.String.valueOf(String.java:2854)

                    [INFO]           at java.lang.StringBuilder.append(StringBuilder.java:128)

                    [INFO]           at org.jboss.errai.codegen.SnapshotMaker$2.generate(SnapshotMaker.java:284)

                    [INFO]           at org.jboss.errai.codegen.util.GenUtil.generate(GenUtil.java:130)

                    [INFO]           at org.jboss.errai.codegen.util.GenUtil.generateCallParameters(GenUtil.java:76)

                    [INFO]           at org.jboss.errai.codegen.builder.callstack.MethodCall.handleCall(MethodCall.java:60)

                    [INFO]           ... 39 more

                    [INFO]    [ERROR] Errors in 'jar:file:/home/dilim/.m2/repository/org/jboss/errai/errai-jpa-client/2.3.2.Final/errai-jpa-client-2.3.2.Final.jar!/org/jboss/errai/jpa/client/local/ErraiEntityManagerProvider.java'

                    [INFO]       [ERROR] Line 24:  Failed to resolve 'org.jboss.errai.jpa.client.local.ErraiEntityManager' via deferred binding

                    [INFO]    [ERROR] Cannot proceed due to previous errors

                    [INFO] ------------------------------------------------------------------------

                    [INFO] BUILD FAILURE

                    [INFO] ------------------------------------------------------------------------

                    [INFO] Total time: 1:10.015s

                    [INFO] Finished at: Tue Jun 25 19:02:24 WAT 2013

                    [INFO] Final Memory: 21M/158M

                    • 7. Re: Errai JPA Failing To Compile
                      Jonathan Fuerth Master

                      Okay, that's definitely not what we were hoping for!

                       

                      I've tried to reproduce this problem on my machine by following the steps you described:

                       

                      1. Create new project from CDI archetype: mvn archetype:generate -DarchetypeGroupId=org.jboss.errai.archetypes -DarchetypeArtifactId=cdi-quickstart -DarchetypeVersion=2.3.2.Final
                      2. Add <inherits name="org.jboss.errai.jpa.JPA"/> to App.gwt.xml
                      3. Add
                            <dependency>
                              <groupId>org.jboss.errai</groupId>
                              <artifactId>errai-jpa-client</artifactId>
                              <version>${errai.version}</version>
                            </dependency>

                        to pom.xml. You didn't mention this step, but the build failed with the following error without this dependency in the pom:

                        [ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.4.0:compile (gwt-compile) on project cdi232: GWT Module org.jboss.errai.jpa.JPA not found in project sources or resources. -> [Help 1]
                      4. Build with: mvn clean package -Pjboss7

                       

                      There must be some other change you've made to your project which is causing the build failure. Can you try the above 4 steps exactly and let me know if it builds successfully?

                       

                      -Jonathan

                       

                      PS: you should also add errai-jpa-client at provided scope in the jboss7 profile. Otherwise, your war file will contain hibernate, which should not be deployed to AS7.

                      • 8. Re: Errai JPA Failing To Compile
                        Anton Hughes Master

                        Hi

                         

                        I'm also getting this error.

                         

                        I'm using 2.2.0.Final (currently unable to upgrade).

                         

                        I have simply added  <inherits name="org.jboss.errai.jpa.JPA"/> to the *.gwt.xml file and the dependency to the pom file. Then I could not build.

                         

                        Any ideas on how to fix this?

                        • 9. Re: Errai JPA Failing To Compile
                          Jonathan Fuerth Master

                          Hi Anton,

                           

                          You need to inherit the ErraiJPA GWT module if the ErraiJPA code generator is on your classpath at compile time:

                           

                              <inherits name="org.jboss.errai.jpa.JPA"/>

                           

                          -Jonathan

                          • 10. Re: Errai JPA Failing To Compile
                            Anton Hughes Master

                            Hi Jonathan

                             

                            I definitely had both that line in the in the *.gwt.xml file, and the correct dependency added in maven.

                             

                             

                            br

                            • 11. Re: Errai JPA Failing To Compile
                              Jonathan Fuerth Master

                              Okay, so you mean you're getting the same error as Charles reported in the original post, then:

                               

                              java.lang.ClassCastException: org.jboss.errai.codegen.meta.impl.gwt.GWTTypeVariable cannot be cast to org.jboss.errai.codegen.meta.MetaClass

                               

                              This must be related to the existence of a type variable on some part of an entity class. If you (either Charles or Anton) can narrow this down to the entity which causes the issue (or make one up) and post that here, I should be able to identify and fix the bug. Unfortunately, we don't currently have any releases planned on the 2.3.x line, so the fix will appear on 2.4.x and 3.x only.

                               

                              -Jonathan

                              • 12. Re: Errai JPA Failing To Compile
                                Saif Rehman Newbie

                                Hi Jon,

                                I am having the same problem while using ErraiJPA. I am using errai 2.3.2.Final. I had posted the new discussion for this https://community.jboss.org/thread/230757 and Erik guided me this discussion.

                                Can you please help with that? Can you please let me know how can I narrow down to a specific Entity?

                                 

                                Kind regards

                                • 13. Re: Errai JPA Failing To Compile
                                  Jonathan Fuerth Master

                                  Hi Saif,

                                   

                                  You could do this by changing all the field declarations in your class that use type variables to Object (or whatever the type variable's upper bound is) and then re(GWT)comple the app. The ErraiJPA error should go away. Then, one at a time, change the field declarations back to use the type variables they originally used. Do a full GWT compile each time you introduce a new type variable.

                                   

                                  Once you've determined the cause of the problem, it should be easy to create an @Entity class with one field which causes this error. Post the code for that class here.

                                   

                                  Cheers,

                                  Jonathan

                                  • 14. Re: Errai JPA Failing To Compile
                                    Saif Rehman Newbie

                                    Hi Jon,

                                    Thanks for th reply , I ll definitely try this and get back to you.

                                    1 2 Previous Next