3 Replies Latest reply on Aug 26, 2013 6:06 PM by Jonathan Fuerth

    Generic types and marshalling

    Anton Hughes Master

      Hi

       

      I'm trying to use generic types in our errai app, but am having problems with marshalling.

       

      Ive attached a simple sample app to demonstrate.

       

      For example, I'm getting the following error:

       

       

       

      Caused by: org.jboss.errai.marshalling.client.api.exceptions.InvalidMappingException: portable entity magick.nu.generic.events.client.shared.Response contains a field (payLoad) that is not known to the marshaller framework: magick.nu.generic.events.client.shared.Bar at org.jboss.errai.marshalling.rebind.api.impl.defaultjava.DefaultJavaDefinitionMapper.map(DefaultJavaDefinitionMapper.java:225) at org.jboss.errai.marshalling.rebind.DefinitionsFactoryImpl.loadCustomMappings(DefinitionsFactoryImpl.java:330)

        • 1. Re: Generic types and marshalling
          Jonathan Fuerth Master

          Hi Anton,

           

          Thanks for taking the time to package up an example app that illustrates the problem. This is a huge help!

           

          Now for the bad (good?) news: I downloaded and unzipped the attached application, and the whole thing built properly for me. No errors generating either the client or server marshallers:

           

          jfuerth@LapCow-Pro:~/tmp/generic.events$ mvn clean package
          [INFO] Scanning for projects...
          [INFO]                                                                       
          [INFO] ------------------------------------------------------------------------
          [INFO] Building generic.events 0.0.1-SNAPSHOT
          [INFO] ------------------------------------------------------------------------
          [INFO]
          [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ generic.events ---
          [INFO] Deleting /Users/jfuerth/tmp/generic.events (includes = [www-test/**, .gwt/**, .errai/**, src/main/webapp/app/**, src/main/webapp/WEB-INF/deploy/**, src/main/webapp/WEB-INF/lib/**, src/main/webapp/WEB-INF/classes/**, **/gwt-unitCache/**, **/*.JUnit/**], excludes = [])
          [INFO]
          [INFO] --- gwt-maven-plugin:2.4.0:clean (gwt-clean) @ generic.events ---
          [INFO] auto discovered modules [magick.nu.generic.events.App]
          [INFO]
          [INFO] --- jacoco-gwt-maven-plugin:0.5.4.201202141554:prepare-agent (jacoco-gwt-prepare-agent) @ generic.events ---
          [INFO] argLine set to -javaagent:/Users/jfuerth/.m2/repository/org/jboss/errai/jacoco-gwt-maven-plugin/0.5.4.201202141554/jacoco-gwt-maven-plugin-0.5.4.201202141554.jar=snapshotDirectory=/Users/jfuerth/tmp/generic.events/target/snapshot-classes,snapshotClassLoaders=*gwt* -javaagent:/Users/jfuerth/.m2/repository/org/jacoco/org.jacoco.agent/0.5.4.201111111111/org.jacoco.agent-0.5.4.201111111111-runtime.jar=destfile=/Users/jfuerth/tmp/generic.events/target/jacoco.exec
          [INFO]
          [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ generic.events ---
          [debug] execute contextualize
          [INFO] Using 'UTF-8' encoding to copy filtered resources.
          [INFO] Copying 6 resources
          [INFO]
          [INFO] --- gwt-maven-plugin:2.4.0:resources (gwt-compile) @ generic.events ---
          [INFO] auto discovered modules [magick.nu.generic.events.App]
          [INFO] 7 source files from GWT module magick.nu.generic.events.App
          [INFO]
          [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ generic.events ---
          [INFO] Compiling 7 source files to /Users/jfuerth/tmp/generic.events/src/main/webapp/WEB-INF/classes
          [INFO]
          [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ generic.events ---
          [debug] execute contextualize
          [INFO] Using 'UTF-8' encoding to copy filtered resources.
          [INFO] Copying 3 resources
          [INFO]
          [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ generic.events ---
          [INFO] Compiling 2 source files to /Users/jfuerth/tmp/generic.events/target/test-classes
          [INFO]
          [INFO] --- maven-surefire-plugin:2.5:test (default-test) @ generic.events ---
          [INFO] Tests are skipped.
          [INFO]
          [INFO] --- gwt-maven-plugin:2.4.0:compile (gwt-compile) @ generic.events ---
          [INFO] auto discovered modules [magick.nu.generic.events.App]
          [INFO] Compiling module magick.nu.generic.events.App
          [INFO]    Validating newly compiled units
          [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]    Scanning for additional dependencies: jar:file:/Users/jfuerth/.m2/repository/org/jboss/errai/errai-ioc/2.4.0.Beta1/errai-ioc-2.4.0.Beta1.jar!/org/jboss/errai/ioc/client/Container.java
          [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] INFO [Reflections] Reflections took 815 ms to scan 9 urls, producing 362 keys and 1212 values [using 2 cores]
          [INFO]          Rebinding org.jboss.errai.ioc.client.QualifierEqualityFactory
          [INFO]            Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.QualifierEqualityFactoryGenerator
          [INFO]                Generating Extensions Bootstrapper...
          [INFO]          Rebinding org.jboss.errai.ioc.client.QualifierEqualityFactory
          [INFO]            Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.QualifierEqualityFactoryGenerator
          [INFO]                Generating Extensions Bootstrapper...
          [INFO]          Rebinding org.jboss.errai.ioc.client.QualifierEqualityFactory
          [INFO]            Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.QualifierEqualityFactoryGenerator
          [INFO]                Generating Extensions Bootstrapper...
          [INFO]          Rebinding org.jboss.errai.ioc.client.QualifierEqualityFactory
          [INFO]            Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.QualifierEqualityFactoryGenerator
          [INFO]                Generating Extensions Bootstrapper...
          [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.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]          Rebinding org.jboss.errai.ioc.client.container.IOCEnvironment
          [INFO]            Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCEnvironmentGenerator
          [INFO]                Generating Extensions Bootstrapper...
          [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]          Rebinding org.jboss.errai.ioc.client.container.IOCEnvironment
          [INFO]            Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCEnvironmentGenerator
          [INFO]                Generating Extensions Bootstrapper...
          [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]          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] INFO [CacheUtil] clearing all generation caches...
          [INFO] INFO [AsyncGenerators] discovered async generator org.jboss.errai.bus.rebind.RpcProxyLoaderGenerator; for type: org.jboss.errai.bus.client.framework.RpcProxyLoader
          [INFO] INFO [AsyncGenerators] discovered async generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCGenerator; for type: org.jboss.errai.ioc.client.Bootstrapper
          [INFO] INFO [AsyncGenerators] discovered async generator org.jboss.errai.marshalling.rebind.MarshallersGenerator; for type: org.jboss.errai.marshalling.client.api.MarshallerFactory
          [INFO] INFO [AsyncGenerators] started async generation for >> org.jboss.errai.marshalling.client.api.MarshallerFactory
          [INFO] INFO [AsyncGenerators] started async generation for >> org.jboss.errai.ioc.client.Bootstrapper
          [INFO] INFO [AsyncGenerators] started async generation for >> org.jboss.errai.bus.client.framework.RpcProxyLoader
          [INFO] INFO [IOCBootstrapGenerator] generating IOC bootstrapping class...
          [INFO] WARN [EnvUtil] reachability analysis disabled. errai may generate unnecessary code.
          [INFO] WARN [EnvUtil] enable reachability analysis with -Derrai.compile.perf.perform_reachability_analysis=true
          [INFO] INFO [MarshallerGeneratorFactory] generating marshalling class...
          [INFO]                Checking ErraiApp.properties for configured types ...
          [INFO] INFO [MarshallerGeneratorFactory] generated marshalling class in 434ms.
          [INFO] INFO [Generator] considering '/Users/jfuerth/tmp/generic.events/src/main/webapp/WEB-INF/classes/' as module output path ...
          [INFO] INFO [Generator]    found '/Users/jfuerth/tmp/generic.events/src/main/webapp/WEB-INF/classes' output directory
          [INFO] INFO [Generator] ** deposited marshaller class in : /Users/jfuerth/tmp/generic.events/src/main/webapp/WEB-INF/classes
          [INFO] WARN [EnvUtil] reachability analysis disabled. errai may generate unnecessary code.
          [INFO] WARN [EnvUtil] enable reachability analysis with -Derrai.compile.perf.perform_reachability_analysis=true
          [INFO] INFO [MarshallerGeneratorFactory] generating marshalling class...
          [INFO] INFO [MarshallerGeneratorFactory] generated marshalling class in 117ms.
          [INFO] INFO [IOCBootstrapGenerator] generated IOC bootstrapping class in 1640ms (1802 beans processed)
          [INFO] INFO [IOCBootstrapGenerator] using IOC bootstrapping code at: /Users/jfuerth/tmp/generic.events/.errai/BootstrapperImpl.java
          [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]          Rebinding org.jboss.errai.ioc.client.Bootstrapper
          [INFO]            Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCGenerator
          [INFO]                generating ioc bootstrapping code...
          [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]          Rebinding org.jboss.errai.ioc.client.Bootstrapper
          [INFO]            Invoking generator org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCGenerator
          [INFO]                generating ioc bootstrapping code...
          [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]    Scanning for additional dependencies: jar:file:/Users/jfuerth/.m2/repository/org/jboss/errai/errai-marshalling/2.4.0.Beta1/errai-marshalling-2.4.0.Beta1.jar!/org/jboss/errai/marshalling/client/api/MarshallerFramework.java
          [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]          Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory
          [INFO]            Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator
          [INFO]                Generating Marshallers Bootstrapper...
          [INFO]          Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory
          [INFO]            Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator
          [INFO]                Generating Marshallers Bootstrapper...
          [INFO]          Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory
          [INFO]            Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator
          [INFO]                Generating Marshallers Bootstrapper...
          [INFO]          Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory
          [INFO]            Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator
          [INFO]                Generating Marshallers Bootstrapper...
          [INFO]          Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory
          [INFO]            Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator
          [INFO]                Generating Marshallers Bootstrapper...
          [INFO]    Compiling 6 permutations
          [INFO]      Compiling permutation 0...
          [INFO]      Process output
          [INFO]          Compiling
          [INFO]      Process output
          [INFO]          Compiling
          [INFO]            Compiling permutation 1...
          [INFO]            Compiling permutation 3...
          [INFO]      Process output
          [INFO]          Compiling
          [INFO]            Compiling permutation 2...
          [INFO]      Compiling permutation 4...
          [INFO]      Compiling permutation 5...
          [INFO]    Compile of permutations succeeded
          [INFO] Linking into /Users/jfuerth/tmp/generic.events/target/generic.events-0.0.1-SNAPSHOT/app
          [INFO]    Link succeeded
          [INFO]    Compilation succeeded -- 71.619s
          [INFO]
          [INFO] --- maven-war-plugin:2.1.1:war (default-war) @ generic.events ---
          [INFO] Packaging webapp
          [INFO] Assembling webapp [generic.events] in [/Users/jfuerth/tmp/generic.events/target/generic.events-0.0.1-SNAPSHOT]
          [INFO] Processing war project
          [INFO] Copying webapp webResources [/Users/jfuerth/tmp/generic.events/src/jetty] to [/Users/jfuerth/tmp/generic.events/target/generic.events-0.0.1-SNAPSHOT]
          [INFO] Copying webapp resources [/Users/jfuerth/tmp/generic.events/src/main/webapp]
          [INFO] Webapp assembled in [2875 msecs]
          [INFO] Building war: /Users/jfuerth/tmp/generic.events/target/generic.events.war
          [INFO] WEB-INF/web.xml already added, skipping
          [INFO] ------------------------------------------------------------------------
          [INFO] BUILD SUCCESS
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 1:38.517s
          [INFO] Finished at: Mon Aug 26 14:05:44 EDT 2013
          [INFO] Final Memory: 28M/67M
          [INFO] ------------------------------------------------------------------------
          jfuerth@LapCow-Pro:~/tmp/generic.events$ find . -name \*Marsh\*Impl\*
          ./.errai/MarshallerFactoryImpl.java
          ./src/main/webapp/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl$1.class
          ./src/main/webapp/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl$2.class
          ./src/main/webapp/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl$3.class
          ./src/main/webapp/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl$4.class
          ./src/main/webapp/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl$5.class
          ./src/main/webapp/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl.class
          ./target/.generated/org/jboss/errai/marshalling/client/api/MarshallerFactoryImpl.java
          ./target/generic.events-0.0.1-SNAPSHOT/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl$1.class
          ./target/generic.events-0.0.1-SNAPSHOT/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl$2.class
          ./target/generic.events-0.0.1-SNAPSHOT/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl$3.class
          ./target/generic.events-0.0.1-SNAPSHOT/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl$4.class
          ./target/generic.events-0.0.1-SNAPSHOT/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl$5.class
          ./target/generic.events-0.0.1-SNAPSHOT/WEB-INF/classes/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl.class
          

           

          I also tried running the app in Dev Mode (mvn gwt:run), and that worked too.

           

          -Jonathan

          1 of 1 people found this helpful
          • 2. Re: Generic types and marshalling
            Anton Hughes Master

            Thanks Jonathan

             

            Thats strange that it worked for you.

             

            I did, however, find the problem. I simply needed to ensure the event classes had default no-args constructors.

             

            Thanks again.

            • 3. Re: Generic types and marshalling
              Jonathan Fuerth Master

              For mutable @Portable value types like all the ones in your example app's shared package, you don't need to write explicit default constructors. Errai Marshalling knows about the implicit public no-args constructor, and will use it.

               

              Immutable types, of course, don't generally have a no-args constructor. In this case, you need to choose one constructor and annotate each of its parameters with @MapsTo. But this doesn't apply to any of the @Portable types in your example app; they are all mutable and have either an explicit or implicit no-args constructor.

               

              Which leaves us with a mystery as to what caused your build to fail. Perhaps some old .class files that needed to be wiped out by a Maven clean?

               

              -Jonathan