4 Replies Latest reply on Feb 4, 2014 4:56 PM by webdevwilson

    Issues with errai jax-rs marshalling with multiple entry points

    webdevwilson

      We are having issues with errai marshalling json. Our project consists of 3 entry-point modules. We have other modules that contain jax-rs service calls.

       

      For example:

       

      LoginModule depends on LoginRest module

      ApplicationModule depends on InventoryRestModule, CheckoutRestModule, etc...

       

      When the marshaller runs in hosted mode it will generate the marshaller for only a single entry point. As a quick fix we added all rest modules as dependencies of that entry point module. This works in hosted mode. However, it is failing when compiled.

       

      Is there a setting or something I could be missing?

        • 1. Re: Issues with errai jax-rs marshalling with multiple entry points
          csa

          Hi Kerry,

           

          Which version of Errai are you using? I assume InventoryRestModue and CheckoutRestModule etc. are all inherited GWT modules in your ApplicationModule.

           

          Do all your modules have an ErraiApp.properties file (we use this file as a marker for classpath scanning)?

           

          Cheers,

          Christian

          • 2. Re: Issues with errai jax-rs marshalling with multiple entry points
            webdevwilson

            We are using version 3.0.0.20131205-M3, we only use jax-rs so we depend on errai-jaxrs-client and errai-jaxrs-provider.

             

            ApplicationModule inherits those two where LoginModule inherits the single one. All the modules are in the same war project which does contain a ErraiApp.properties. In this example, LoginModule would work fine, but ApplicationModule would be broken (or vice versa) due to the marshaller only being generated for a single module.

             

            I have created an example app based on the jaxrs-quickstart archetype.

             

            webdevwilson/errai-issue · GitHub

            • 3. Re: Re: Issues with errai jax-rs marshalling with multiple entry points
              csa

              Hi Kerry,

               

              I attached a version of your example that works in DevMode and also compiles to production code. This setup (multiple GWT module in one Maven module) is not really supported in Errai.

               

              The trick to make it work is to make sure only one module (i.e. the app module) is inheriting Errai IOC. So that the boostrapper is only generated once. The problem is that both Errai IOC and Errai Marshalling scan the whole classpath for types not just the currently compiled GWT module.

               

              I am wondering though what is the advantage of organizing your modules that way...wouldn't it be better to have separate projects/jars for each submodule?

               

              Here's another recent thread discussing the same limitation:

              Multiple Errai modules in single Errai project

               

              Cheers,

              Christian

              • 4. Re: Issues with errai jax-rs marshalling with multiple entry points
                webdevwilson

                We haven't run into problems with it, so I haven't thought about splitting them apart before. I guess the advantage is that it is simple and we can run the app in hosted mode and all the modules are available. We also have a host page servlet that all of them are served through. I am not sure exactly how you put entry point modules in separate projects. Multiple wars packaged in an ear perhaps?

                 

                Thanks for the help. We weren't using IOC but we moved the errai.jaxrs import to a single entry point module and it seems to have worked.