12 Replies Latest reply on Dec 9, 2011 6:02 PM by Alvin McMurdy

    Problems with rebinding of MarshallerFactory in current snapshot build

    Alvin McMurdy Newbie

      I'm trying to use the current snapshot-2.0 (build #193).  [We're still using 1.3.0-CR1 for our product, because it's the last release that doesn't suffer from bug #150, which has only been fixed in trunk.  So, I figure I'd try trunk, since 1.3.0-CR1 has other bugs...]

       

      I grabbed the errai-marshaller and errai-codegen jars from that build independently, since they weren't packed with the distribution zip file.

       

      When I try to build our product, I get a slew of errors of the form (actual names anonymized to protect our IP, yadda, yadda):

       

           [java] 2011-12-02 11:13:24,992  INFO [org.jboss.errai.bus.rebind.RpcProxyLoaderGenerator] nothing has changed. using cached rpc proxy loader class.
           [java]    [ERROR] Errors in 'generated://8F011AF8194ADFC2CFCE2878118BCFF7/org/jboss/errai/marshalling/client/api/MarshallerFactoryImpl.java'
           [java]       [ERROR] Line 31:  The import myproject.shared.Aaa.Nested collides with another import statement
           [java]       [ERROR] Line 33:  The import myproject.shared.Bbb.Nested collides with another import statement
           [java]       [ERROR] Line 34:  The import myproject.shared.shadow.Ccc.NestedTwo collides with another import statement
           [java]       [ERROR] Line 35:  The import myproject.shared.Ddd.Nested collides with another import statement
           [java]       [ERROR] Line 258:  The method setDdd(Ddd.Nested) in the type Fff is not applicable for the arguments (Eee.Nested)
           [java]       [ERROR] Line 261:  The method setGgg(Ddd.Nested) in the type Fff is not applicable for the arguments (Eee.Nested)
           [java]       [ERROR] Line 264:  The method setAaa(Aaa.Nested) in the type Fff is not applicable for the arguments (Eee.Nested)
           [java]       [ERROR] Line 282:  The method marshall(Eee.Nested, MarshallingSession) in the type Marshaller is not applicable for the arguments (Ddd.Nested, MarshallingSession)
           [java]       [ERROR] Line 282:  The method marshall(Eee.Nested, MarshallingSession) in the type Marshaller is not applicable for the arguments (Ddd.Nested, MarshallingSession)
           [java]       [ERROR] Line 282:  The method marshall(Eee.Nested, MarshallingSession) in the type Marshaller is not applicable for the arguments (Aaa.Nested, MarshallingSession)
           [java]       [ERROR] Line 834:  The method setDdd(Ddd.Nested) in the type Ccc is not applicable for the arguments (Eee.Nested)
           [java]       [ERROR] Line 855:  The method marshall(Eee.Nested, MarshallingSession) in the type Marshaller is not applicable for the arguments (Ddd.Nested, MarshallingSession)
           [java]       [ERROR] Line 1025:  The method setEee(Eee.Nested) is undefined for the type Eee.Nested
           [java]       [ERROR] Line 1043:  The method getEee() is undefined for the type Eee.Nested
           [java]       [ERROR] Line 1122:  The method setFoo(Integer) is undefined for the type Eee.Nested
           [java]       [ERROR] Line 1125:  The method setBar(Integer) is undefined for the type Eee.Nested
           [java]       [ERROR] Line 1143:  The method getFoo() is undefined for the type Eee.Nested
           [java]       [ERROR] Line 1143:  The method getBar() is undefined for the type Eee.Nested
           [java]       [ERROR] Line 1372:  The method setBaz(List) is undefined for the type Fff.NestedTwo
           [java]       [ERROR] Line 1375:  The method setBuz(List) is undefined for the type Fff.NestedTwo
           [java]       [ERROR] Line 1393:  The method getBaz() is undefined for the type Fff.NestedTwo
           [java]       [ERROR] Line 1393:  The method getBuz() is undefined for the type Fff.NestedTwo
      

       

      I figure something is messed up in a code-generator somewhere --- perhaps another bug in dealing with (static) nested classes?

       

      For future reference, what's the best way to debug stuff like this?  Is there a way to get a look at the generated code?

        • 1. Re: Problems with rebinding of MarshallerFactory in current snapshot build
          Christian Sadilek Master

          That's an issue we are currently working on: https://issues.jboss.org/browse/ERRAI-167

           

          For debugging, you can pass the -gen flag to dev mode to emit the generated code into files (e.g -gen target/gen).

          • 2. Re: Problems with rebinding of MarshallerFactory in current snapshot build
            Alvin McMurdy Newbie

            Ah-ha.

             

            Well, perusing the generator code a bit (thanks for the tip about -gen), I would think that the implementations of JavaReflectionClass.getName() and BuildMetaClass.getName() are part of the problem.  These both return a simple-name, i.e. only the last component of the Complete.Dotted.Name --- whereas java's own Class.getName() returns the complete binary name (fully-qualified, with '$' as member separator, etc).  I bet this is causing confusion in the code, because clearly the generated code is using simple-names in places where it should be using complete names.

             

            My humble suggestion, don't name methods at odds with what java already has:

            • any method called "getName()" should return a complete binary name;
            • any method returning just the last written class component should be called "getSimpleName()".

             

            The disposition of "getFullyQualifiedName()" is not crystal clear --- that method name should probably just be eschewed in favor of "getCanonicalName()", which is mostly the same (except when a member class is referenced through a subclass, I think).

            • 3. Re: Problems with rebinding of MarshallerFactory in current snapshot build
              Christian Sadilek Master

              The colliding imports issue is fixed now. Can you try upgrading to the latest snapshots and see if you still experience the problem?

               

              In case you don't use maven, here's the link to the distribution: http://hudson.jboss.org/hudson/job/Errai/194/org.jboss.errai$errai-distribution/

               

              Also, it's important to mention that Errai 2.0 uses a code generation cache which will be used by subsequent builds when no changes in your classpath have been detected. So, after upgrading make sure you either delete the .errai subdirectory of your project or pass -Derrai.devel.nocache=true to your build.

               

              Thanks!

              • 4. Re: Problems with rebinding of MarshallerFactory in current snapshot build
                Alvin McMurdy Newbie

                (Sorry for delay ... was out for a couple of days.)

                 

                A quick smoke test reveals:

                • Build #194 does seem to fix the MarshallerFactoryImpl import/name collisions.  However, something is wrong with RPC... a call that used to work now throws an exception.. on client-side.. that has me confused:
                  java.lang.IllegalStateException: Cannot reply.  Cannot find RequestDispatcher resource.
                        at org.jboss.errai.bus.client.api.builder.AbstractMessageBuilder$1.reply(AbstractMessageBuilder.java:94)
                        at org.jboss.errai.bus.client.api.base.DefaultErrorCallback.error(DefaultErrorCallback.java:74)
                        at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.callErrorHandler(ClientMessageBusImpl.java:408)
                        at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.send(ClientMessageBusImpl.java:401)
                        at org.jboss.errai.bus.client.api.base.CommandMessage.sendNowWith(CommandMessage.java:500)
                        at org.jboss.errai.bus.client.api.builder.AbstractRemoteCallBuilder$1.sendNowWith(AbstractRemoteCallBuilder.java:115)
                        at org.jboss.errai.bus.client.framework.RpcProxyLoaderImpl$1MyRpcInterfaceImpl.setSomeValue(RpcProxyLoaderImpl.java:37)
                        at myproject.client.MyRpcClient.setSomeValue(MyRpcClient.java:117)
                  
                • Build #200 (the latest) doesn't even get that far; some JSONParseError (from my faulty memory) exception thrown very early on.

                 

                If you'd like more details, formal bug reports, etc for either build, let me know.

                • 5. Re: Problems with rebinding of MarshallerFactory in current snapshot build
                  Mike Brock Master

                  Can you show me the full trace? -- including log messages. We may have fixed this today.

                  • 6. Re: Problems with rebinding of MarshallerFactory in current snapshot build
                    Alvin McMurdy Newbie

                    Full trace from the RPC issue in build 194, or other(?) issue in build 200?

                     

                    (Both?  )

                    • 7. Re: Problems with rebinding of MarshallerFactory in current snapshot build
                      Alvin McMurdy Newbie

                      I made a reduced test case, and built against Build #194.  Here is the full trace, the rpc invocation, and the "Boron" class definition.

                       

                      java.lang.IllegalStateException: Cannot reply.  Cannot find RequestDispatcher resource.
                          at org.jboss.errai.bus.client.api.builder.AbstractMessageBuilder$1.reply(AbstractMessageBuilder.java:94)
                          at org.jboss.errai.bus.client.api.base.DefaultErrorCallback.error(DefaultErrorCallback.java:74)
                          at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.callErrorHandler(ClientMessageBusImpl.java:408)
                          at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.send(ClientMessageBusImpl.java:401)
                          at org.jboss.errai.bus.client.api.base.CommandMessage.sendNowWith(CommandMessage.java:500)
                          at org.jboss.errai.bus.client.api.builder.AbstractRemoteCallBuilder$1.sendNowWith(AbstractRemoteCallBuilder.java:115)
                          at org.jboss.errai.bus.client.framework.RpcProxyLoaderImpl$1MyRpcInterfaceImpl.setBoron(RpcProxyLoaderImpl.java:28)
                          at innerds.client.BadInnerds$2.onClick(BadInnerds.java:83)
                          at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:54)
                          at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1)
                          at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
                          at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
                          at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
                          at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
                          at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
                          at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
                          at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
                          at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
                          at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
                          at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                          at java.lang.reflect.Method.invoke(Method.java:616)
                          at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
                          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
                          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
                          at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
                          at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
                          at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
                          at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
                          at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
                          at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                          at java.lang.reflect.Method.invoke(Method.java:616)
                          at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
                          at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
                          at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
                          at java.lang.Thread.run(Thread.java:636)
                      

                       

                                 final Boron boron = Boron.fromXAndY(7, 21);
                                 MessageBuilder.createCall(NOOP_CALLBACK, MyRpcInterface.class)
                                  .setBoron(Boron.Bean.from(boron));
                      

                       

                      public final class Boron {
                        private final int x;
                        private final int y;
                      
                        private Boron() {
                          this(0, 0);
                        }
                      
                        private Boron(final int x, final int y) {
                          this.x = x;
                          this.y = y;
                        }
                      
                        public static Boron fromXAndY(final int x, final int y) {
                          return new Boron(x, y);
                        }
                        
                        public int getX() { return x; }
                      
                        public int getY() { return y; }
                      
                        /**
                         * Mutable bean-like variant of Boron, until immutable classes can be
                         * serialized by errai.
                         */
                        @ExposeEntity
                        public static final class Bean {
                          private int x;
                          private int y;
                      
                          public int getX() { return x; }
                          public int getY() { return y; }
                          public void setX(int x) { this.x = x; }
                          public void setY(int y) { this.y = y; }
                        
                          /** Create a Bean from a real Boron. */
                          @Nonnull
                          public static Bean from(@Nonnull final Boron b) {
                            final Bean result = new Bean();
                            result.x = b.getX();
                            result.y = b.getY();
                            return result;
                          }
                      
                          /** Create a real Boron from a Bean. */
                          @Nonnull
                          public Boron unbean() {
                            return new Boron(x, y);
                          }
                        }
                      }
                      
                      • 8. Re: Problems with rebinding of MarshallerFactory in current snapshot build
                        Mike Brock Master

                        We are pushing out a new SNAPSHOT -- should be published in about an hour from this post. Can you try against that?

                         

                        Also, you should be using the new @Portable annotation in place of @ExposeEntity.

                         

                        Mike.

                        • 9. Re: Problems with rebinding of MarshallerFactory in current snapshot build
                          Alvin McMurdy Newbie

                          No go.  Tried out build #203, and the following appears in the dev-mode Jetty tab:

                           

                          org.jboss.errai.marshalling.client.api.exceptions.InvalidMappingException: portable entity innerds.shared.Boron$Bean contains a field (x) that is not known to the marshaller: java.lang.Integer
                              at org.jboss.errai.marshalling.rebind.api.impl.defaultjava.DefaultJavaDefinitionMapper.map(DefaultJavaDefinitionMapper.java:205)
                              at org.jboss.errai.marshalling.rebind.DefinitionsFactoryImpl.loadCustomMappings(DefinitionsFactoryImpl.java:228)
                              at org.jboss.errai.marshalling.rebind.DefinitionsFactoryImpl.(DefinitionsFactoryImpl.java:61)
                              at org.jboss.errai.marshalling.server.MappingContextSingleton$1.(MappingContextSingleton.java:41)
                              at org.jboss.errai.marshalling.server.MappingContextSingleton.(MappingContextSingleton.java:40)
                              at org.jboss.errai.marshalling.server.JSONStreamDecoder.(JSONStreamDecoder.java:50)
                              at org.jboss.errai.marshalling.server.JSONStreamDecoder.decode(JSONStreamDecoder.java:65)
                              at org.jboss.errai.bus.server.io.MessageFactory.createCommandMessage(MessageFactory.java:76)
                              at org.jboss.errai.bus.server.servlet.JettyContinuationsServlet.doPost(JettyContinuationsServlet.java:77)
                              at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
                              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                              at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
                              at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
                              at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
                              at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
                              at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
                              at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
                              at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
                              at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
                              at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
                              at org.mortbay.jetty.Server.handle(Server.java:324)
                              at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
                              at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
                              at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
                              at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
                              at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
                              at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
                              at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
                          

                          FWIW, I did go and change @ExposeEntity to @Portable.

                          • 10. Re: Problems with rebinding of MarshallerFactory in current snapshot build
                            Alvin McMurdy Newbie

                            (Also, I would have tried Build #202, but, despite all the changes, it appears the the Errai::Distribution module did not get rebuilt in that build.)

                            • 11. Re: Problems with rebinding of MarshallerFactory in current snapshot build
                              Mike Brock Master

                              I have pushed a fix for your problem, which I was able to reproduce with your code. The build will likely not be available for at least an hour. We have also added test coverage for this problem with your test code -- I hope that's okay. =)

                              • 12. Re: Problems with rebinding of MarshallerFactory in current snapshot build
                                Alvin McMurdy Newbie

                                Quite a long hour --- I don't see any builds newer than #203 yet today.

                                 

                                With regards to using the test code, let me consult with the Boron Holdings Corp legal team... Nope, not a problem, they say.

                                I'm glad to contribute something more than just a bug report.