3 Replies Latest reply on Apr 14, 2016 11:21 AM by mbarkley

    [4.0.0.-SNAPSHOT] Migration problems

    hr.stoyanov

      The following code starts causing compile errors when moving from 3.2.3.Final to 4.0.0.-SNAPSHOT:

       

      @Templated("Skeleton.html#pusher")

      @ApplicationScoped

      public class Pusher extends Composite {

          @Inject    @DataField

          private HeaderMenu headerMenu;

         @Inject    @DataField

          private SimplePanel contentContainer;

          HeaderMenu getHeaderMenu() {

              return headerMenu;

          }

          SimplePanel getContentContainer() {

              return contentContainer;

          }

      }

       

      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.RuntimeException: The following dependency problems were found:

        Ambiguous resolution for field [class=com.google.gwt.user.client.ui.SimplePanel, injectorType=Reference, qualifier=[@Default]] in [class=com.xxxx.web.client.Pusher, injectorType=Type, qualifier=[@Any, @Default]].

      Resolved types:

      [class=com.xxxx.web.client.FooterMessage, injectorType=Type, qualifier=[@Any, @Default]], [class=org.jboss.errai.security.client.local.context.SecurityContextImpl$SecurityRolesConstraintPage, injectorType=Type, qualifier=[@Any, @Default]]

       

       

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

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

        • 1. Re: [4.0.0.-SNAPSHOT] Migration problems
          hr.stoyanov

          ... the issue is still valid, but since I started getting rid of all Widgets and Composites, it is no longer an issue for me.

           

          Starting to like new Errai APIs a lot and how it takes advantage of JsInteroip, but it is some learning!

           

          Not sure how would that play with the Google's official/unofficial  "elemental" library though?

          • 2. Re: [4.0.0.-SNAPSHOT] Migration problems
            mbarkley

            Hi Hristo,

             

            Glad this isn't holding you back any more, but for the benefit of anyone else who encounters this, let me explain the issue.

             

            In Errai 4 the dependency resolution algorithm is much more like CDI. As a consequence if you try an inject a type like SimplePanel, it will be satisfied by any non-abstract class that extends SimplePanel as well as SimplePanel itself. In this case, the IoC has found a type in your app as well as an internal Errai type, both extending SimplePanel. (As an aside, that Errai type shouldn't extend SimplePanel any more. This will be fixed for our next release.)

             

            There is some special logic for injecting Widgets so that you can have usage like injecting a TextBox without it being ambiguous (which it would be in a pure CDI resolution because of the subclass PasswordTextBox) but generally this special case logic only applies if there are no other types in your classpath that extend the widget you're trying to inject.

             

            Obviously we're encouraging users to avoid Widgets for new development, but in cases where it's unavoidable you can work around most resolution issues by giving your widget subtypes custom qualifiers.

             

            Cheers.

            • 3. Re: [4.0.0.-SNAPSHOT] Migration problems
              mbarkley
              Not sure how would that play with the Google's official/unofficial  "elemental" library though?

              There is currently limited support for the current GWT Elemental types in Errai. For example you can use elemental types as @DataFields. That being said we will not likely be adding more support for the current elemental library because it uses JS overlay types which have been supplanted by JS interop.

               

              But if there is a new elemental library using JS interop in the future it should work with Errai UI from day one. That's because Errai UI is currently capable of using any @JsType that wraps an element as a @DataField.