8 Replies Latest reply on Feb 4, 2014 4:36 PM by csa

    Multiple Errai modules in single Errai project

    piotr.b

      Hi,

       

      Is it even possible in Errai to have many gwt (errai) modules?

       

      I have two modules in my project: Portal and Upload.

      During gwt-compilation of the latter this pop ups:

       

      [INFO] Adding '1' new generated units

      [INFO]       Validating units:

      [INFO]          Errors in '/home/piotrb/workspace-media/portal/target/.generated/org/jboss/errai/ioc/client/BootstrapperImpl.java'

      [INFO]             See snapshot: /tmp/org.jboss.errai.ioc.client.BootstrapperImpl6905182164881964385.java

      [INFO]          Ignored 1 unit with compilation errors in first pass.

      [INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.

      [INFO]    [ERROR] Errors in '/home/piotrb/workspace-media/portal/target/.generated/org/jboss/errai/ioc/client/BootstrapperImpl.java'

      [INFO]       [ERROR] Line 168: No source code is available for type com.media.portal.errai.ui.portal.AdminPage; did you forget to inherit a required module?

      [INFO]       [ERROR] Line 259: No source code is available for type com.media.portal.errai.ui.portal.Messages; did you forget to inherit a required module?

      [INFO]       [ERROR] Line 306: No source code is available for type com.media.portal.errai.ui.portal.NavBar; did you forget to inherit a required module?

      [INFO]       [ERROR] Line 314: No source code is available for type com.media.portal.errai.ui.portal.Stream; did you forget to inherit a required module?

      [INFO]       [ERROR] Line 315: No source code is available for type com.media.portal.errai.ui.portal.LoginForm; did you forget to inherit a required module?

      [INFO]       [ERROR] Line 360: No source code is available for type com.media.portal.errai.ui.portal.App; did you forget to inherit a required module?

      [INFO]       [ERROR] Line 485: No source code is available for type com.media.portal.errai.ui.portal.WelcomePage; did you forget to inherit a required module?

      [INFO]       See snapshot: /tmp/org.jboss.errai.ioc.client.BootstrapperImpl5429366040707418659.java

      [INFO]    [ERROR] Errors in 'org/jboss/errai/ioc/client/Container.java'

      [INFO]       [ERROR] Line 64: Rebind result 'org.jboss.errai.ioc.client.BootstrapperImpl' could not be found

      [INFO]    Computing all possible rebind results for 'org.jboss.errai.marshalling.client.api.MarshallerFactory'

      [INFO]       Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory

      [INFO]          Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator

      [INFO]             Generating Marshallers Bootstrapper...

      [INFO] 2014-01-30 22:33:15,264 INFO  [com.google.gwt.core.ext.Generator] thread:[pool-3-thread-2] ** deposited marshaller class in : /home/piotrb/workspace-media/portal/src/main/webapp/WEB-INF/classes

      [INFO]    Computing all possible rebind results for 'org.jboss.errai.ioc.client.QualifierEqualityFactory'

      [INFO]       Rebinding org.jboss.errai.ioc.client.QualifierEqualityFactory

      [INFO]          Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.QualifierEqualityFactoryGenerator

      [INFO]             Generating Extensions Bootstrapper...

      [INFO]    Computing all possible rebind results for 'org.jboss.errai.marshalling.client.api.MarshallerFactoryImpl.Marshaller_for_com_media_portal_errai_shared_UserComplaint'

      [INFO]       Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactoryImpl.Marshaller_for_com_media_portal_errai_shared_UserComplaint

      [INFO]          Invoking generator org.jboss.errai.marshalling.rebind.MarshallerGenerator

      [INFO]             [ERROR] Generator 'org.jboss.errai.marshalling.rebind.MarshallerGenerator' threw an exception while rebinding 'org.jboss.errai.marshalling.client.api.MarshallerFactoryImpl.Marshaller_for_com_media_portal_errai_shared_UserComplaint'

        • 1. Re: Multiple Errai modules in single Errai project
          csa

          Hi Piotr,

           

          Yes, you can use multiple GWT modules.

           

          You will have to make sure your modules are proper GWT modules. They need a gwt.xml and specify the correct source path. So from your error above: Your portal module needs a gwt.xml in the package com.media.portal.errai.ui which specifies a <source path="portal">:

          http://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html

           

          Then you can inherit the portal module in your other modules.

           

          Cheers,

          Christian

          • 2. Re: Multiple Errai modules in single Errai project
            piotr.b

            Hi Christian,

            Thank you for your answer.

             

            Unfortunately, I think this isn't gwt modules configuration problem per se. For instance, I can gwt-compile each single module without any problems. The problems I described arise when I compile them one after another in single maven gwt:compile.

                            <artifactId>gwt-maven-plugin</artifactId>

                            <configuration>

                                <modules>

                                    <module>com.media.portal.Portal</module> <-- if I remove this or Upload it works fine but fails with both modules

                                    <module>com.media.portal.Upload</module>

                                </modules>

                                ...

                           </configuration>

            It looks to me like .errai folder contents after one compilation interfere with the second compilation... Compilation output I attached comes from gwt-compilation of Upload after successful compilation of Portal using above gwt-plugin config. I don't use any classes from Portal inside Upload.

             

            I have my Upload.gwt.xml and Portal.gwt.xml in src/main/resources/com.media.portal. Portal.gwt.xml, for instance, has:

                <source path="errai/shared" />

                <source path="errai/ui/portal" />

            Upload.gwt.xml:

                <source path="client" />

                <source path="errai/shared" />

                <source path="errai/ui/upload" />

             

            So I think it's not the problem of gwt modules. I've done it many times in pure gwt. But I don't know how to do it with Errai.

            • 3. Re: Multiple Errai modules in single Errai project
              piotr.b

              Can I assume that for now it is impossible to achieve what I want with Errai? And I have make two maven modules for my webapp, although it is one single webapp with just couple host html pages inside from which I want to run different GWT modules?

              I hope that I'm mistaken but... Could you provide some example to prove that I'm wrong?

               

              The issue to me lays clearly in some conflicts between code generated by Errai for one module and code for the second.

              • 4. Re: Multiple Errai modules in single Errai project
                csa

                Hi,

                 

                We never had anyone try this as most people seem to use a separate JAR/Maven module for their individual GWT modules. I am interested in making this work though. The files in .errai are not the problem. They are just outputted for debugging/logging purposes. So, you will just see the ones of the last build.

                 

                It seems to me the problem happens when Errai generates the bootstrapper for your Upload module as it brings in all the types of the Portal module as well and the Upload module doesn't (and probably shouldn't) inherit the Portal module. Is that correct - can you share your Upload.gwt.xml?

                 

                If that's the problem we have a feature that can solve this. We can configure Errai IOC to ignore specific types and packages. So, when building the Upload module we could configure it to ignore the Portal types. This currently can only be done using an ErraiApp.properties file but we could add this configuration to the gwt.xml file as well.

                 

                Cheers,

                Christian

                • 5. Re: Multiple Errai modules in single Errai project
                  piotr.b

                  Thanks, would be great if it worked with the feature you are referring  to. You are right about everything you just posted.

                  Could you describe how could I make it with ErraiApp.properties before it is available from gwt.xml? I mean how to control different types in different modules...

                   

                  Portal.gwt.xml:

                  <module>

                      <inherits name='com.google.gwt.user.User' />

                      <inherits name="org.jboss.errai.ui.UI" />

                      <inherits name="org.jboss.errai.ui.nav.Navigation"/>

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

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

                      <set-property name="user.agent" value="safari" />

                      <source path="errai/shared" />

                      <source path="errai/ui/shared" />

                      <source path="errai/ui/portal" />

                  </module>

                  Upload.gwt.xml:

                  <module>

                      <inherits name='com.google.gwt.user.User' />

                      <inherits name="com.google.gwt.inject.Inject" />

                      <inherits name='com.gwtplatform.dispatch.Dispatch'/>

                      <inherits name="org.jboss.errai.ui.UI" />

                      <inherits name="org.jboss.errai.ui.nav.Navigation"/>

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

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

                      <set-property name="user.agent" value="safari" />

                      <source path="client" />

                      <source path="errai/ui/shared" />

                      <source path="errai/ui/upload" />

                  </module>


                  First compiles with no problems

                   

                  [INFO]    Computing all possible rebind results for 'org.jboss.errai.marshalling.client.api.MarshallerFactory'

                  [INFO]       Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory

                  [INFO]          Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator

                  [INFO]             Generating Marshallers Bootstrapper...

                  [INFO]    Computing all possible rebind results for 'org.jboss.errai.ioc.client.QualifierEqualityFactory'

                  [INFO]       Rebinding org.jboss.errai.ioc.client.QualifierEqualityFactory

                  [INFO]          Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.QualifierEqualityFactoryGenerator

                  [INFO]             Generating Extensions Bootstrapper...

                  [INFO]    Compiling 1 permutation

                  [INFO]       Compiling permutation 0...

                  [INFO]    Compile of permutations succeeded

                  [INFO] Linking into /home/path_to_workspace/portal/src/main/webapp/com.media.portal.Portal; Writing extras to /home/path_to_workspace/portal/target/extra/com.media.portal.Portal

                  [INFO]    Link succeeded

                  [INFO]    Compilation succeeded -- 45.760s

                   

                  During the compilation of Upload:

                   

                  [INFO] Compiling module com.media.portal.Upload

                  ... bunch of DEBUG [org.jboss.errai.config.rebind.* and ErraiMarshalling] output ...

                  [INFO] 2014-02-03 20:43:11,529 DEBUG [ErraiMarshalling] thread:[pool-3-thread-1] <<< Done searching for all jars by META-INF/MANIFEST.MF

                  [INFO]    Computing all possible rebind results for 'org.jboss.errai.ioc.client.container.IOCEnvironment'

                  [INFO]       Rebinding org.jboss.errai.ioc.client.container.IOCEnvironment

                  [INFO]          Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCEnvironmentGenerator

                  [INFO]             Generating Extensions Bootstrapper...

                  [INFO]    Computing all possible rebind results for 'org.jboss.errai.ioc.client.Bootstrapper'

                  [INFO]       Rebinding org.jboss.errai.ioc.client.Bootstrapper

                  [INFO]          Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCGenerator

                  [INFO]             generating ioc bootstrapping code...

                  [INFO]    Adding '1' new generated units

                  [INFO]       Validating units:

                  [INFO]          Errors in '/home/path_to_workspace/portal/target/.generated/org/jboss/errai/ioc/client/BootstrapperImpl.java'

                  [INFO]             See snapshot: /tmp/org.jboss.errai.ioc.client.BootstrapperImpl5195108202280439774.java

                  [INFO]          Ignored 1 unit with compilation errors in first pass.

                  [INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.

                  [INFO]    [ERROR] Errors in '/home/path_to_workspace/portal/target/.generated/org/jboss/errai/ioc/client/BootstrapperImpl.java'

                  [INFO]       [ERROR] Line 159: No source code is available for type com.media.portal.errai.ui.portal.AdminPage; did you forget to inherit a required module?

                  [INFO]       [ERROR] Line 215: No source code is available for type com.media.portal.errai.ui.portal.PortalNavBar; did you forget to inherit a required module?

                  [INFO]       [ERROR] Line 224: No source code is available for type com.media.portal.errai.ui.portal.Stream; did you forget to inherit a required module?

                  [INFO]       [ERROR] Line 225: No source code is available for type com.media.portal.errai.ui.portal.LoginForm; did you forget to inherit a required module?

                  [INFO]       [ERROR] Line 226: No source code is available for type com.media.portal.errai.ui.portal.Messages; did you forget to inherit a required module?

                  [INFO]       [ERROR] Line 364: No source code is available for type com.media.portal.errai.shared.UserComplaintEndpoint; did you forget to inherit a required module?

                  [INFO]       [ERROR] Line 399: No source code is available for type com.media.portal.errai.ui.portal.App; did you forget to inherit a required module?

                  [INFO]       [ERROR] Line 515: No source code is available for type com.media.portal.errai.ui.portal.WelcomePage; did you forget to inherit a required module?

                  [INFO]       See snapshot: /tmp/org.jboss.errai.ioc.client.BootstrapperImpl2601521577531150994.java

                  [INFO]    [ERROR] Errors in 'org/jboss/errai/ioc/client/Container.java'

                  [INFO]       [ERROR] Line 62: Rebind result 'org.jboss.errai.ioc.client.BootstrapperImpl' could not be found

                  [INFO]    Computing all possible rebind results for 'org.jboss.errai.marshalling.client.api.MarshallerFactory'

                  [INFO]       Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory

                  [INFO]          Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator

                  [INFO]             Generating Marshallers Bootstrapper...

                  [INFO] 2014-02-03 20:43:11,907 INFO  [com.google.gwt.core.ext.Generator] thread:[pool-3-thread-1] ** deposited marshaller class in : /home/path_to_workspace/portal/src/main/webapp/WEB-INF/classes

                  [INFO]    Adding '1' new generated units

                  [INFO]       Validating units:

                  [INFO]          Errors in '/home/path_to_workspace/portal/target/.generated/org/jboss/errai/marshalling/client/api/MarshallerFactoryImpl.java'

                  [INFO]             See snapshot: /tmp/org.jboss.errai.marshalling.client.api.MarshallerFactoryImpl6653057078350002085.java

                  [INFO]          Ignored 1 unit with compilation errors in first pass.

                  [INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.

                  [INFO]    [ERROR] Errors in '/home/path_to_workspace/portal/target/.generated/org/jboss/errai/marshalling/client/api/MarshallerFactoryImpl.java'

                  [INFO]       [ERROR] Line 84: No source code is available for type com.media.portal.errai.shared.UserComplaint; did you forget to inherit a required module?

                  [INFO]       See snapshot: /tmp/org.jboss.errai.marshalling.client.api.MarshallerFactoryImpl7989412329766875105.java

                  [INFO]    [ERROR] Errors in 'org/jboss/errai/marshalling/client/api/MarshallerFramework.java'

                  [INFO]       [ERROR] Line 42: Rebind result 'org.jboss.errai.marshalling.client.api.MarshallerFactoryImpl' could not be found

                  [INFO]    Computing all possible rebind results for 'org.jboss.errai.ioc.client.QualifierEqualityFactory'

                  [INFO]       Rebinding org.jboss.errai.ioc.client.QualifierEqualityFactory

                  [INFO]          Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.QualifierEqualityFactoryGenerator

                  [INFO]             Generating Extensions Bootstrapper...

                  • 6. Re: Multiple Errai modules in single Errai project
                    csa

                    Hi,

                     

                    OK good. At least we know exactly what the problem is now. Right now you'd need to create an ErraiApp.properties file adding errai.ioc.blacklist = com.media.portal.errai.ui.portal.*.

                     

                    The trick we need is to make sure this file is only considered when building the Upload module. Do you have an idea? I need to think about this more. Are you on 3.0-SNAPSHOT, btw?

                     

                    Christian

                    • 7. Re: Multiple Errai modules in single Errai project
                      piotr.b

                      That's the problem with ErraiApp.properties.

                      Initially I was thinking about making some workarounds with Maven - making two different gwt-compilation cycles for two modules but it's too much work for me considering that it works when I manually remove each module and make two separate mvn builds.

                      And it's still only a workaround. Not very elegant.

                       

                      I have the same doubts about the feature you described in previous post. Does this feature (.gwt.xml options) do the same as ErraiApp.properties? I mean black-listing?

                      From my perspective it's not the best solution because I would still have to refer in one module (Upload) to the second one (Portal) even if it's only black-listing options. These modules are separate (they only share a 'shared' package - btw that's one of the reasons why I don't want them to have their own maven modules/jars). So I think it would not be elegant to make them refer each other in any possible way.

                      It would be ideal if the whole process of Errai's code generation was transparent to me.

                      Is it not possible to generate Errai's classes with some dynamic suffixes like timestamp or module's name? Like it is in error message I pasted above '/tmp/org.jboss.errai.ioc.client.BootstrapperImpl5195108202280439774.java' - I don't what this class is but maybe...

                       

                      I am on 3.0-SNAPSHOT

                      • 8. Re: Multiple Errai modules in single Errai project
                        csa

                        Hi,

                         

                        While looking at Re: Re: Issues with errai jax-rs marshalling with multiple entry points a possible workaround is to only inherit Errai IOC and Errai Marshalling from your Portal module not your Upload module. Then the boostrapper and marshallers are only generated once (for your Portal module).

                         

                        It looks like you're using all these Errai features in your Upload module though in which case there's no workaround and at least for now you will have to use separate projects/jars for your Errai GWT modules.

                         

                        Feel free to create a JIRA for us of course. We always welcome pull requests if you have a suggestion how we could implement this.

                         

                        Thanks,

                        Christian