1 Reply Latest reply on Mar 2, 2016 8:23 AM by francesco milesi

    Compilation problem when ApplicationScoped bean moved to module

    francesco milesi Newbie

      Hi everybody,

       

      We had a maven errai project with 1 module containing an ApplicationScoped bean named Keycloak, that was injected in other beans and everything used to work fine.

      Now we have exported the Keycloak bean and other classes to a separate gwt module, to share it with the current main module and gwt modules we are going to add in the near future.

      So at the moment we have 2 gwt modules (corresponding to  2 maven modules):

       

      1. com.vivaldi.varco.common.Common with the following gwt.xml, that is a maven module with the same parent of the main module com.vivaldi.varco.manager.Manager

      
      <module>
        <inherits name="org.jboss.errai.enterprise.All" />
        <inherits name="com.google.gwt.user.User"/>
      
      
        <inherits name="org.jboss.errai.validation.Validation" />
        <inherits name="org.hibernate.validator.HibernateValidator" />
        <inherits name="org.jboss.errai.jpa.JPA"/>
      
      
        <source path="keycloak"/>
        <source path="model"/>
        <source path="page"/>
        <source path="service"/>
        <source path="to"/>
        <source path="widget"/>
      </module>
      
      
      
      
      
      

       

      2. com.vivaldi.varco.manager.Manager, that inherits com.vivaldi.varco.common.Common and is a maven module with the same parent of com.vivaldi.varco.common.Common)

      
      <module rename-to="manager">
        <inherits name="org.jboss.errai.enterprise.All" />
        <inherits name="com.google.gwt.user.User"/>
      
      
        <inherits name="org.jboss.errai.validation.Validation" />
        <inherits name="org.hibernate.validator.HibernateValidator" />
        <inherits name="org.jboss.errai.jpa.JPA"/>
      
      
        <inherits name="com.vivaldi.varco.common.Common"/>
        <inherits name="com.vivaldi.varco.shared.Shared"/>
      </module>
      
      
      
      
      
      
      
      
      

       

       

      The Common module gwt-compiles correctly on its own.  The Manager module compiles correctly only if we comment the @ApplicationScoped annotation, otherwise it produces the following error:

       

      [ERROR] java.util.concurrent.ExecutionException: org.jboss.errai.ioc.rebind.ioc.exception.UnsatisfiedDependenciesException:  @> com.vivaldi.varco.manager.client.local.manager.NavigationWrapper
      [ERROR]  - field org.jboss.errai.codegen.meta.MetaField:NavigationWrapper.@javax.inject.Inject()   com.vivaldi.varco.common.keycloak.Keycloack keycloak could not be satisfied for type: com.vivaldi.varco.common.keycloak.Keycloack
      [ERROR]   Message: can't resolve bean: com.vivaldi.varco.common.keycloak.Keycloack ( @Default )
      [ERROR] 
      [ERROR] at java.util.concurrent.FutureTask.report(FutureTask.java:122)
      [ERROR] at java.util.concurrent.FutureTask.get(FutureTask.java:192)
      [ERROR] at org.jboss.errai.config.rebind.AsyncGenerators$FutureWrapper.get(AsyncGenerators.java:112)
      [ERROR] at org.jboss.errai.config.rebind.AsyncGenerators$FutureWrapper.get(AsyncGenerators.java:86)
      [ERROR] at org.jboss.errai.config.rebind.AbstractAsyncGenerator.startAsyncGeneratorsAndWaitFor(AbstractAsyncGenerator.java:200)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCGenerator.generate(IOCGenerator.java:62)
      [ERROR] at com.google.gwt.core.ext.IncrementalGenerator.generateNonIncrementally(IncrementalGenerator.java:40)
      [ERROR] at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:760)
      [ERROR] at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:160)
      [ERROR] at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:79)
      [ERROR] at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:276)
      [ERROR] at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:265)
      [ERROR] at com.google.gwt.dev.DistillerRebindPermutationOracle.getAllPossibleRebindAnswers(DistillerRebindPermutationOracle.java:87)
      [ERROR] at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.createStaticRebindExpression(UnifyAst.java:485)
      [ERROR] at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.createRebindExpression(UnifyAst.java:443)
      [ERROR] at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.handleMagicMethodCall(UnifyAst.java:576)
      [ERROR] at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.endVisit(UnifyAst.java:306)
      [ERROR] at com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:248)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
      [ERROR] at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:128)
      [ERROR] at com.google.gwt.dev.jjs.ast.JCastOperation.traverse(JCastOperation.java:67)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
      [ERROR] at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:128)
      [ERROR] at com.google.gwt.dev.jjs.ast.JDeclarationStatement.traverse(JDeclarationStatement.java:49)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:95)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:351)
      [ERROR] at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:92)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
      [ERROR] at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:149)
      [ERROR] at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:145)
      [ERROR] at com.google.gwt.dev.jjs.ast.JTryStatement.traverse(JTryStatement.java:93)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:95)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:351)
      [ERROR] at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:92)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
      [ERROR] at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:149)
      [ERROR] at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:145)
      [ERROR] at com.google.gwt.dev.jjs.ast.JMethodBody.traverse(JMethodBody.java:83)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
      [ERROR] at com.google.gwt.dev.jjs.ast.JMethod.visitChildren(JMethod.java:600)
      [ERROR] at com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:569)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
      [ERROR] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
      [ERROR] at com.google.gwt.dev.jjs.impl.UnifyAst.mainLoop(UnifyAst.java:1505)
      [ERROR] at com.google.gwt.dev.jjs.impl.UnifyAst.exec(UnifyAst.java:870)
      [ERROR] at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.unifyJavaAst(JavaToJavaScriptCompiler.java:1305)
      [ERROR] at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.constructJavaAst(JavaToJavaScriptCompiler.java:1038)
      [ERROR] at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.precompile(JavaToJavaScriptCompiler.java:954)
      [ERROR] at com.google.gwt.dev.jjs.MonolithicJavaToJavaScriptCompiler.precompile(MonolithicJavaToJavaScriptCompiler.java:303)
      [ERROR] at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:38)
      [ERROR] at com.google.gwt.dev.Precompile.precompile(Precompile.java:286)
      [ERROR] at com.google.gwt.dev.Precompile.precompile(Precompile.java:229)
      [ERROR] at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
      [ERROR] at com.google.gwt.dev.Compiler.run(Compiler.java:206)
      [ERROR] at com.google.gwt.dev.Compiler.run(Compiler.java:158)
      [ERROR] at com.google.gwt.dev.Compiler$1.run(Compiler.java:120)
      [ERROR] at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:55)
      [ERROR] at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50)
      [ERROR] at com.google.gwt.dev.Compiler.main(Compiler.java:127)
      [ERROR] Caused by: org.jboss.errai.ioc.rebind.ioc.exception.UnsatisfiedDependenciesException:  @> com.vivaldi.varco.manager.client.local.manager.NavigationWrapper
      [ERROR]  - field org.jboss.errai.codegen.meta.MetaField:NavigationWrapper.@javax.inject.Inject()   com.vivaldi.varco.common.keycloak.Keycloack keycloak could not be satisfied for type: com.vivaldi.varco.common.keycloak.Keycloack
      [ERROR]   Message: can't resolve bean: com.vivaldi.varco.common.keycloak.Keycloack ( @Default )
      [ERROR] 
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.exception.UnsatisfiedDependenciesException.createWithSingleFieldFailure(UnsatisfiedDependenciesException.java:39)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.injector.api.InjectionTask.doTask(InjectionTask.java:119)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.injector.InjectUtil.handleInjectionTasks(InjectUtil.java:164)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.injector.InjectUtil.access$000(InjectUtil.java:73)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.injector.InjectUtil$2.generateConstructor(InjectUtil.java:151)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.injector.basic.TypeInjector.renderProvider(TypeInjector.java:138)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCConfigProcessor$3.handle(IOCConfigProcessor.java:404)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCConfigProcessor$7.process(IOCConfigProcessor.java:674)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCConfigProcessor.process(IOCConfigProcessor.java:619)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCBootstrapGenerator.generateBootstrappingClassSource(IOCBootstrapGenerator.java:299)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCBootstrapGenerator.generate(IOCBootstrapGenerator.java:141)
      [ERROR] at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCGenerator.generate(IOCGenerator.java:72)
      [ERROR] at org.jboss.errai.config.rebind.AbstractAsyncGenerator$1.call(AbstractAsyncGenerator.java:67)
      [ERROR] at org.jboss.errai.config.rebind.AbstractAsyncGenerator$1.call(AbstractAsyncGenerator.java:55)
      [ERROR] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      [ERROR] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      [ERROR] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      [ERROR] at java.lang.Thread.run(Thread.java:745)
      

       

       

      When we comment the @ApplicationScoped annotation, the Manager module compiles without errors and everything works. We can create instances of Keycloak and even inject it as a @Dependent bean into beans of the manager module.

      I looked into the jar of the common module that we added as a dependency to the pom of the Manager module and it looks fine with classes, sources and the Common.gwt.xml in the right place.

      I am wondering if there is some code generated by errai during compilation that is not picked up by the Manager module, due to some misconfiguration of the gwt-maven plugin.

       

                  <plugin>
                      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>gwt-maven-plugin</artifactId>
                      <version>${gwt.version}</version>
                      <executions>
                          <execution>
                              <id>compile</id>
                              <phase>prepare-package</phase>
                              <goals>
                                  <goal>compile</goal>
                              </goals>
                          </execution>
                      </executions>
                      <configuration>
                          <strict>true</strict>
                          <logLevel>INFO</logLevel>
                          <noServer>false</noServer>
                          <server>org.jboss.errai.cdi.server.gwt.JBossLauncher</server>
                          <disableCastChecking>true</disableCastChecking>
                          <runTarget>${errai.dev.context}/index.html</runTarget>
                          <hostedWebapp>src/main/webapp</hostedWebapp>
                          <extraJvmArgs>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Xmx712m -XX:CompileThreshold=7000 -XX:MaxPermSize=128M -Derrai.jboss.home=${errai.jboss.home} -Derrai.dev.context=${errai.dev.context} -Derrai.jboss.javaagent.path=${settings.localRepository}/org/jboss/errai/errai-client-local-class-hider/${errai.version}/errai-client-local-class-hider-${errai.version}.jar</extraJvmArgs>
                      </configuration>
                  </plugin>
      

       

      Can you give me a hint on where to look?

       

      thanks in advance for your help


      francesco