4 Replies Latest reply on Aug 22, 2013 2:29 AM by marius.gerwinn

    Problem with Errai IOC

    marius.gerwinn

      Overall errai IOC is working pretty well for us.

       

      But sometimes we got stuck figuring out what the error message is about:

       

      [ERROR] org.jboss.errai.codegen.exception.UndefinedMethodException: undefined method: getSingletonInstanceOrNew(org.jboss.errai.ioc.client.container.async.AsyncInjectionContext, java.lang.Object, org.jboss.errai.ioc.client.container.async.CreationalCallback, java.lang.Class, [Ljava.lang.annotation.Annotation;); in class: org.jboss.errai.ioc.client.container.async.AsyncCreationalContext
      [ERROR]           at org.jboss.errai.codegen.builder.callstack.MethodCall.handleCall(MethodCall.java:73)
      [ERROR]           at org.jboss.errai.codegen.builder.callstack.AbstractCallElement.nextOrReturn(AbstractCallElement.java:46)
      [ERROR]           at org.jboss.errai.codegen.builder.callstack.LoadVariable.handleCall(LoadVariable.java:122)
      [ERROR]           at org.jboss.errai.codegen.builder.impl.AbstractStatementBuilder.generate(AbstractStatementBuilder.java:61)
      [ERROR]           at org.jboss.errai.codegen.BlockStatement.generate(BlockStatement.java:90)
      [ERROR]           at org.jboss.errai.codegen.builder.impl.AnonymousClassStructureBuilderImpl$2$1.doGenerate(AnonymousClassStructureBuilderImpl.java:111)
      [ERROR]           at org.jboss.errai.codegen.builder.impl.AnonymousClassStructureBuilderImpl.doGenerate(AnonymousClassStructureBuilderImpl.java:186)
      [ERROR]           at org.jboss.errai.codegen.builder.impl.AnonymousClassStructureBuilderImpl.access$200(AnonymousClassStructureBuilderImpl.java:43)
      [ERROR]           at org.jboss.errai.codegen.builder.impl.AnonymousClassStructureBuilderImpl$3.generate(AnonymousClassStructureBuilderImpl.java:152)
      [ERROR]           at org.jboss.errai.codegen.builder.impl.ObjectBuilder$2.doDeferred(ObjectBuilder.java:173)
      [ERROR]           at org.jboss.errai.codegen.builder.callstack.DeferredCallElement.handleCall(DeferredCallElement.java:42)
      [ERROR]           at org.jboss.errai.codegen.builder.impl.AbstractStatementBuilder.generate(AbstractStatementBuilder.java:61)
      [ERROR]           at org.jboss.errai.codegen.builder.impl.ObjectBuilder.generate(ObjectBuilder.java:181)
      [ERROR]           at org.jboss.errai.codegen.builder.impl.FieldBuilder$1.generate(FieldBuilder.java:123)
      [ERROR]           at org.jboss.errai.codegen.meta.impl.build.BuildMetaField.toJavaString(BuildMetaField.java:219)
      [ERROR]           at org.jboss.errai.codegen.meta.impl.build.BuildMetaClass.membersToString(BuildMetaClass.java:721)
      [ERROR]           at org.jboss.errai.codegen.meta.impl.build.BuildMetaClass.toJavaString(BuildMetaClass.java:662)
      [ERROR]           at org.jboss.errai.codegen.meta.impl.build.BuildMetaClass.toJavaString(BuildMetaClass.java:562)
      [ERROR]           at org.jboss.errai.codegen.builder.impl.ClassBuilder.toJavaString(ClassBuilder.java:495)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCBootstrapGenerator.generateBootstrappingClassSource(IOCBootstrapGenerator.java:341)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCBootstrapGenerator.generate(IOCBootstrapGenerator.java:144)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCGenerator.generate(IOCGenerator.java:68)
      [ERROR]           at org.jboss.errai.config.rebind.AbstractAsyncGenerator$1.call(AbstractAsyncGenerator.java:42)
      [ERROR]           at org.jboss.errai.config.rebind.AbstractAsyncGenerator$1.call(AbstractAsyncGenerator.java:39)
      [ERROR]           at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      [ERROR]           at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      [ERROR]           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      [ERROR]           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      [ERROR]           at java.lang.Thread.run(Thread.java:722)
      [ERROR] Caused by: java.lang.RuntimeException: Problem was caused by this call
      [ERROR]           at org.jboss.errai.codegen.builder.callstack.AbstractCallElement.<init>(AbstractCallElement.java:33)
      [ERROR]           at org.jboss.errai.codegen.builder.callstack.MethodCall.<init>(MethodCall.java:46)
      [ERROR]           at org.jboss.errai.codegen.builder.impl.ContextualStatementBuilderImpl.invoke(ContextualStatementBuilderImpl.java:60)
      [ERROR] Caused by: java.lang.RuntimeException: External call to API
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.injector.async.AsyncProviderInjector.getBeanInstance(AsyncProviderInjector.java:78)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.injector.basic.QualifiedTypeInjectorDelegate.getBeanInstance(QualifiedTypeInjectorDelegate.java:98)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.injector.AsyncInjectUtil.getInjectorOrProxy(AsyncInjectUtil.java:344)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.injector.AsyncInjectUtil.getInjectorOrProxy(AsyncInjectUtil.java:315)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.injector.api.AsyncInjectionTask.doTask(AsyncInjectionTask.java:164)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.injector.AsyncInjectUtil.handleAsyncInjectionTasks(AsyncInjectUtil.java:203)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.injector.AsyncInjectUtil.access$000(AsyncInjectUtil.java:62)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.injector.AsyncInjectUtil$2.generateConstructor(AsyncInjectUtil.java:174)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.injector.async.AsyncTypeInjector.renderProvider(AsyncTypeInjector.java:158)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCConfigProcessor$3.handle(IOCConfigProcessor.java:411)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCConfigProcessor$7.process(IOCConfigProcessor.java:650)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCConfigProcessor.process(IOCConfigProcessor.java:596)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCBootstrapGenerator.generateBootstrappingClassSource(IOCBootstrapGenerator.java:297)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCBootstrapGenerator.generate(IOCBootstrapGenerator.java:144)
      [ERROR]           at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCGenerator.generate(IOCGenerator.java:68)
      [ERROR]           at org.jboss.errai.config.rebind.AbstractAsyncGenerator$1.call(AbstractAsyncGenerator.java:42)
      [ERROR]           at org.jboss.errai.config.rebind.AbstractAsyncGenerator$1.call(AbstractAsyncGenerator.java:39)
      [ERROR]           at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      [ERROR]           at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      [ERROR]           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      [ERROR]           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      [ERROR]           at java.lang.Thread.run(Thread.java:722)
      

       

      .....

      INFO]    [ERROR] Errors in PATH_NAME\.generated\org\jboss\errai\ioc\client\BootstrapperImpl.java'
      [INFO]       [ERROR] Line 1236: Syntax error on tokens, delete these tokens
      [INFO]       [ERROR] Line 1236: Syntax error on tokens, delete these tokens
      [INFO]       [ERROR] Line 1429: Syntax error on tokens, delete these tokens
      [INFO]       [ERROR] Line 1429: Syntax error on token "@", invalid AssignmentOperator
      [INFO]       [ERROR] Line 1622: Syntax error on tokens, delete these tokens
      [INFO]       [ERROR] Line 1622: Syntax error on tokens, delete these tokens
      [INFO]       [ERROR] Line 1815: Syntax error on tokens, delete these tokens
      [INFO]       [ERROR] Line 1815: Syntax error on tokens, delete these tokens
      [INFO]       [ERROR] Line 3477: Syntax error on tokens, delete these tokens
      [INFO]       [ERROR] Line 3477: Syntax error on token "@", . expected
      [INFO]       [ERROR] Line 4125: Syntax error on tokens, delete these tokens
      [INFO]       [ERROR] Line 4125: Syntax error on tokens, delete these tokens
      

       

       

      We got a multi project setup with a lot of Producers, IOCProviders and even Singletons.

       

      Most of the time we can solve the errors by refactoring the creation of instances by using a different "injection approach". e.g.  Producers instead of @Singleton.

       

      Currently this can costs us hours of "random" refactoring...

      Is there any better way to find out what causes the actual problem?

        • 1. Re: Problem with Errai IOC
          edewit

          Hi Marius,

           

          We think that the problem is specific to the async bean manager can you create a small project that has the problem? And/or give us your beangraph.gv and Bootstrapper.java to be able to reproduce/figure out what is going on?

           

          Cheers,

               Erik Jan

          • 2. Re: Problem with Errai IOC
            marius.gerwinn

            Hello Erik and thanks for your reply!

             

            Unfortunatly I can't reproduce the error in a small test project.

            This is actually what we did to "efficiently" narrow down the problem.

            But it wasn't successfull. Everything we tested worked fine and as expected. The error must be a result the complex project setup.

             

            But once again the error is gone now due to some refactoring:)

            So I'm not able to give you the beangraph/bootstrapper either.

             

            I'm not exactly sure if this causes the error but here is the basic project setup:

             

            clientProject

                      abstract class A

                      class ClassThatUsesClassA

                      class ALotOfOtherClassesThatUsesA

             

             

            mainProject has client project as dependency

                      class AImpl

                      class ALotOfOtherClassesThatUsesAImpl

                 class ProduceForAAsSingleton

             

            As your correctly mentionend we use the async bean manager. Also class A/AImpl must be created by IOC in the very beginning since it's used by a lot of other classes.

             

             

            It would be quite helpful if there would be some more detailed logging/error message when "this" error occurs.

            We have our own errai version. So if you could give me some patched classes or hints were to put that logging/error handling

            we eventually find the real source of problem.

            • 3. Re: Problem with Errai IOC
              edewit

              Hi Marius,

               

              So how do you deside what to refactor when a error like this occurs, you must have some clue as to what is the cause then. Can't you rollback your refactorings, so that it fails again? In your summery what beans have the @LoadAsync annotation?

               

              Cheers,

                   Erik Jan

              • 4. Re: Problem with Errai IOC
                marius.gerwinn

                Hi Erik,

                 

                 

                So how do you deside what to refactor when a error like this occurs, you must have some clue as to what is the cause then.

                Thats kind of little bit tricky: In the beginning we added  some more detailed log statements to some of the "codegenerator classes" (see my first post above).

                But that wasn't that successfull. But looking at lines that have syntax errors in the Bootstrapper.java give us some hints. The classes that were "injected" in this lines is most of the time our class A.

                So at least we knew what class cause problemes.

                In your summery what beans have the @LoadAsync annotation?

                Actually none of the beans that are causing the problem are using @LoadAsync. Of course class A is used in some @LoadAsync annotated classes as well since it's a very common class.

                 

                We are still trying to reproduce the problem in a small test project. Until then we need to deal with that issues and try to avoid them.

                I'll update this post when we got progress on that test-project.