2 Replies Latest reply on Dec 8, 2014 12:07 AM by hr.stoyanov

    Google Guice usage in Errai 3.1.0/3.0.4

    hr.stoyanov

      I pulled the dependencies in Errai 3.1 and I see that Google Guice is pulled in by errai-bus:

      org.jboss.errai:errai-bus:3.1.0.Final

      +--- org.jboss.errai:errai-common:3.1.0.Final

      |    +--- org.jboss.errai.reflections:reflections:3.1.0.Final

      |    |    +--- org.javassist:javassist:3.18.1-GA

      |    |    +--- org.slf4j:slf4j-api:1.7.2

      |    |    \--- dom4j:dom4j:1.6.1

      |    |         \--- xml-apis:xml-apis:1.0.b2

      |    +--- junit:junit:4.11

      |    |    \--- org.hamcrest:hamcrest-core:1.3

      |    +--- de.benediktmeurer.gwt-slf4j:gwt-slf4j:0.0.2

      |    \--- commons-lang:commons-lang:2.6

      +--- org.jboss.errai:errai-config:3.1.0.Final

      +--- org.jboss.errai:errai-marshalling:3.1.0.Final

      |    +--- org.jboss.errai:errai-common:3.1.0.Final (*)

      |    +--- org.jboss.errai:errai-config:3.1.0.Final

      |    +--- org.jboss.errai:errai-codegen:3.1.0.Final

      |    |    +--- org.jboss.errai:errai-common:3.1.0.Final (*)

      |    |    +--- org.mvel:mvel2:2.2.1.Final

      |    |    \--- junit:junit:4.11 (*)

      |    +--- org.jboss.errai:errai-codegen-gwt:3.1.0.Final

      |    |    \--- org.jboss.errai:errai-codegen:3.1.0.Final (*)

      |    \--- javax.inject:javax.inject:1

      +--- com.google.inject:guice:3.0

      |    +--- aopalliance:aopalliance:1.0

      |    \--- org.sonatype.sisu.inject:cglib:2.2.1-v20090111

      |         \--- asm:asm:3.1

       

      There are two problems with it:

      A. The Errai 3.10 documentation mentions nothing about Google Guice in the dependencoes required  (and btw, is probably very outdated)

      B. As thoroughly discussed in the GWT community, ASM 3.1 makes for some nasty compile errors with GWT 2.7.0, which requires ASM 5:

      [ERROR] Unexpected internal compiler error

      java.lang.IncompatibleClassChangeError: class com.google.gwt.dev.javac.asm.CollectMethodData has interface org.objectweb.asm.MethodVisitor as super class

        at java.lang.ClassLoader.defineClass1(Native Method)

        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)

        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

       

      Since Google Guice is not listed as required by Errai 3.1.0, I removed it to arrive at this compile error:

      SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

      SLF4J: Defaulting to no-operation (NOP) logger implementation

      SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

      java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: com/google/inject/Inject

        at java.util.concurrent.FutureTask.report(FutureTask.java:122)

        at java.util.concurrent.FutureTask.get(FutureTask.java:192)

        at org.jboss.errai.config.rebind.AsyncGenerators$FutureWrapper.get(AsyncGenerators.java:112)

        at org.jboss.errai.config.rebind.AsyncGenerators$FutureWrapper.get(AsyncGenerators.java:86)

        at org.jboss.errai.config.rebind.AbstractAsyncGenerator.startAsyncGeneratorsAndWaitFor(AbstractAsyncGenerator.java:188)

        at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCGenerator.generate(IOCGenerator.java:59)

       

      Ok, so with no way around Google Guice, I decided to do something nasty - replace the ASM underneath it, with the one that GWT 2.7.0 brings in. This compiles my project, but when I run it, I get a nullMethod() exception as in:

      ...

      function com_google_gwt_lang_com_100046peruncs_100046s4g_100046web_100046gwt_100046S4GWebApp_1_1EntryMethodHolder_init__V(){

        $wnd.setTimeout($entry(com_google_gwt_useragent_client_UserAgentAsserter_assertCompileTimeUserAgent__V));

        com_google_gwt_user_client_DocumentModeAsserter_$onModuleLoad__Lcom_google_gwt_user_client_DocumentModeAsserter_2V();

        com_google_gwt_logging_client_LogConfiguration_$onModuleLoad__Lcom_google_gwt_logging_client_LogConfiguration_2V(com_google_gwt_logging_client_LogConfiguration_$clinit__V());

        org_jboss_errai_common_client_logging_LoggingHandlerConfigurator_$onModuleLoad__Lorg_jboss_errai_common_client_logging_LoggingHandlerConfigurator_2V(new org_jboss_errai_common_client_logging_LoggingHandlerConfigurator_LoggingHandlerConfigurator__V);

        org_jboss_errai_common_client_api_extension_InitVotes_startInitPolling__V();

        org_jboss_errai_marshalling_client_api_MarshallerFramework_$clinit__V();

        org_jboss_errai_enterprise_client_jaxrs_JaxrsModule_$onModuleLoad__Lorg_jboss_errai_enterprise_client_jaxrs_JaxrsModule_2V(org_jboss_errai_enterprise_client_jaxrs_JaxrsModule_$clinit__V());

        org_jboss_errai_bus_client_ErraiBus_$clinit__V();

        org_jboss_errai_ioc_client_Container_$bootstrapContainer__Lorg_jboss_errai_ioc_client_Container_2V(org_jboss_errai_ioc_client_Container_$clinit__V());

        org_jboss_errai_enterprise_client_cdi_CDIClientBootstrap_$onModuleLoad__Lorg_jboss_errai_enterprise_client_cdi_CDIClientBootstrap_2V(org_jboss_errai_enterprise_client_cdi_CDIClientBootstrap_$clinit__V());

      (new com_peruncs_s4g_web_gwt_client_local_S4GWebApp_S4GWebApp__V).nullMethod();

      }

       

      I checked a few links and it points to Google Guice issues ... so can someone from Errai help with explaining the Google Guice relationship with Errai. Thanks.

        • 1. Re: Google Guice usage in Errai 3.1.0/3.0.4
          hr.stoyanov

          A little update:

          I decided to swap out Google Guice 3.x dependency caused by Errai 3.1 and force Google Guice 4.0 Beta 5. This solved both problems :

          1. GWT 2.7.0 ASM version seems to be not coliding with Guice 4's one

          2. I got rid of the nasty nullMethod() exception !

           

          here is my dependency after the hack:

          ...

          +--- com.google.inject:guice:4.0-beta5

          |    +--- javax.inject:javax.inject:1

          |    +--- aopalliance:aopalliance:1.0

          |    \--- com.google.guava:guava:16.0.1 -> 18.0

           

           

          I still have the same questions for the Errai team, though.

          • 2. Re: Google Guice usage in Errai 3.1.0/3.0.4
            hr.stoyanov

            ... more corrections:

            It turns out that the nullMethod() issue is caused by the GWT 2.7.0 compiler - depending on the optimization level N (0..9) set perhaps not related to Guice , although I am still interested in the relation between guice and errai.