8 Replies Latest reply on Jan 10, 2013 4:49 AM by robert.geisler

    Jboss AS 7.1, EJB exceptions and java.io.StreamCorruptedException

    Vt Ysh Newbie

      Hello Community.

      I am trying to invoke EJB methods remotely from the standalone application. When EJB gives some result all works OK but if during EJB invocation some exception occurres it can't be properly transferred to the client. Please see the stacktrace. As usual on Jboss 5.1 i didn't have such problems.

       

      java.io.StreamCorruptedException: Unexpected byte found when reading an object: 53

                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:750)

                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)

                at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1677)

                at org.jboss.marshalling.river.RiverObjectInputStream.defaultReadObject(RiverObjectInputStream.java:73)

                at java.lang.Throwable.readObject(Throwable.java:913)

                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:601)

                at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:213)

                at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1574)

                at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)

                at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)

                at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)

                at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1235)

                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)

                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)

                at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1677)

                at org.jboss.marshalling.river.RiverObjectInputStream.defaultReadObject(RiverObjectInputStream.java:73)

                at java.lang.Throwable.readObject(Throwable.java:913)

                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:601)

                at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:213)

                at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1574)

                at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)

                at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)

                at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)

                at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1235)

                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)

                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)

                at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)

                at org.jboss.ejb.client.remoting.InvocationExceptionResponseHandler$MethodInvocationExceptionResultProducer.getResult(InvocationExceptionResponseHandler.java:82)

                at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:270)

                at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:47)

                at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:272)

                at org.jboss.ejb.client.ReceiverInterceptor.handleInvocationResult(ReceiverInterceptor.java:132)

                at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:260)

                at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:399)

                at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:140)

                at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)

                at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)

                ... 28 more

      Caused by: an exception which occurred:

                in field suppressedExceptions

                in object of type custom.java.CustomApplicationException

                in field cause

                in object of type javax.ejb.EJBException

        • 1. Re: Jboss AS 7.1, EJB exceptions and java.io.StreamCorruptedException
          jaikiran pai Master

          Can you try this against latest nightly build available here https://community.jboss.org/thread/167590. We have fixed some issues in this area recently.

          • 2. Re: Jboss AS 7.1, EJB exceptions and java.io.StreamCorruptedException
            robert.geisler Newbie

            hi!

             

            we use jboss-as-7.1.1.Final and see StreamCorruptedException, too.
            did you resolve the issue in the meantime?

             

            we found that StreamCorruptedException is raised when we use Java 1.6 on the server side and Java 1.7 on the client side and ApplicationException is thrown on the server.

            the same action with the same ApplicationException as the result does not show StreamCorruptedException when using Java 1.6 on both sides!

             

            we guess it is a bug/ missing feature in org.jboss.marshalling.river.RiverUnmarshaller, because Java 1.7 java.lang.Throwable has field suppressedExceptions that Java 1.6 doesnt have.
            what do you think?

             

            regards
            robert

            • 3. Re: Jboss AS 7.1, EJB exceptions and java.io.StreamCorruptedException
              jaikiran pai Master

              robert.geisler wrote:

               

              hi!

               

              we use jboss-as-7.1.1.Final and see StreamCorruptedException, too.
              did you resolve the issue in the meantime?

               

              we found that StreamCorruptedException is raised when we use Java 1.6 on the server side and Java 1.7 on the client side and ApplicationException is thrown on the server.

              the same action with the same ApplicationException as the result does not show StreamCorruptedException when using Java 1.6 on both sides!

               

              we guess it is a bug/ missing feature in org.jboss.marshalling.river.RiverUnmarshaller, because Java 1.7 java.lang.Throwable has field suppressedExceptions that Java 1.6 doesnt have.
              what do you think?

               

              regards
              robert

              That's fixed as part of https://issues.jboss.org/browse/EJBCLIENT-46. You can just use 1.0.12.Final version (which contains the fix) of EJB client library on the remote client side to get this fix.

              • 4. Re: Jboss AS 7.1, EJB exceptions and java.io.StreamCorruptedException
                robert.geisler Newbie

                thank you, jaikiran, for the fix and for your instant answer!

                • 5. Re: Jboss AS 7.1, EJB exceptions and java.io.StreamCorruptedException
                  robert.geisler Newbie

                  jaikiran,

                   

                  i just tried jboss-ejb-client 1.0.12.Final, but i still get UndeclaredThrowableException/ java.io.StreamCorruptedException.

                  why? 0: )

                   

                  i updated jbossall-client.jar and replaced org/jboss/ejb/client/ package by the new version. my ide shows that deprecatedClassTableClasses exists and is set during runtime.

                  nevertheless StreamCorruptedException get raised in RiverUnmarshaller while readFields of our CustomException object. ProtocolV1ClassTable seems not to be called.

                   

                  do i have to update jboss-ejb-client library on the server side, too? remember, my server runs on Java 1.6 while remote client uses Java 1.7.

                  or do i have to update jboss-marshalling-river instead?

                   

                  regards

                  robert

                   

                  EDIT:

                  just updated JBoss 7 module org.jboss.ejb-client with 1.0.12.Final and it works.

                  thanks jaikiran!

                  • 6. Re: Jboss AS 7.1, EJB exceptions and java.io.StreamCorruptedException
                    jaikiran pai Master

                    Sorry, when I suggested that you update only your client classpath, I forgot that the server side EJB client module jar too needs to be updated since the same marshalling ClassTable implementation is used on the server side during marshalling. So you did the right thing by updating even the server side module jar.

                    • 7. Re: Jboss AS 7.1, EJB exceptions and java.io.StreamCorruptedException
                      robert.geisler Newbie

                      hi, jaikiran,

                       

                      as i told you i updated EJB client module to version 1.0.12.Final.

                       

                      next step is to install a remoting connection to another JBoss AS Server as shown here: https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+server+instance .
                      i need this to invoke EJBs deployed on a 1st JBoss AS from a WAR within a 2nd JBoss AS.

                       

                      during deployment of my WAR/ start of JBoss 7.1.1 i get the following error:

                       

                      ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.ejb3.dd-based-ejb-client-context."[MYWEBAPP].war": org.jboss.msc.service.StartException in service jboss.ejb3.dd-based-ejb-client-context."[MYWEBAPP].war": Failed to start service

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]

                          at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]

                      Caused by: java.lang.AbstractMethodError: org.jboss.as.ejb3.remote.JBossEJBClientXmlConfiguration.getDeploymentNodeSelector()Lorg/jboss/ejb/client/DeploymentNodeSelector;

                          at org.jboss.ejb.client.EJBClientContext.<init>(EJBClientContext.java:107)

                          at org.jboss.ejb.client.EJBClientContext.create(EJBClientContext.java:172)

                          at org.jboss.ejb.client.EJBClientContext.create(EJBClientContext.java:155)

                          at org.jboss.as.ejb3.remote.DescriptorBasedEJBClientContextService.start(DescriptorBasedEJBClientContextService.java:92)

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                          ... 3 more


                      i had a look at the code. EJBClientContext is version 1.0.12.Final and EJBClientConfiguration defines getDeploymentNodeSelector,
                      but JBossEJBClientXmlConfiguration doesnt implement that because it is version jboss-as-ejb3-7.1.1.Final .

                       

                      so i need an update to JBossEJBClientXmlConfiguration.

                      i found version 7.1.2.Final: http://grepcode.com/snapshot/repo1.maven.org/maven2/org.jboss.as/jboss-as-ejb3/7.1.2.Final/ .
                      but is it save to use 7.1.2.Final when using JBoss 7.1.1.Final?? how am i supposed to update JBossEJBClientXmlConfiguration?

                       

                      thanks in advance

                      regards

                      robert

                      • 8. Re: Jboss AS 7.1, EJB exceptions and java.io.StreamCorruptedException
                        robert.geisler Newbie

                        hi everyone!

                         

                        after a while i am back to that topic : )

                         

                        i tried to update module org.jboss.as.ejb3 to jboss-as-ejb3-7.1.2.Final.jar.

                        as expected it leads to others exceptions, because (newer) dependencies are missing.

                         

                        next i took a step back: i reinstalled jboss-ejb-client-1.0.5.Final.

                        to get the fix i replaced org.jboss.ejb.client.remoting.ProtocolV1ClassTable from jboss-ejb-client-1.0.12.Final.
                        that works for me.

                         

                        after that i installed a remoting connection to another JBoss AS Server as told before:
                        https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+server+instance
                        now that works, too. no more errors : )

                         

                        regards
                        robert