1 2 3 4 5 Previous Next 70 Replies Latest reply on Apr 20, 2006 3:38 PM by clebert.suconic Go to original post
      • 15. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
        clebert.suconic

        I'm trying to replicate this problem.


        Any help is appreciated.


        From what I read here it looks like AOPProxy serialization. I have seen recent changes on that. I will do some tests trying to replicate that.

        http://jira.jboss.com/jira/browse/EJBTHREE-423

        (Look also at the development thread:)

        http://www.jboss.com/index.html?module=bb&op=viewtopic&t=77115

        • 16. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
          ajwhitney

          Just to add some more data to this thread...

          I'm running into the same issue. JBoss AS 4.0.4RC1.

          I have a web application running inside JBoss referencing stateless session beans and detached entities in the same JBoss instance via remote interfaces.

          This occurs whether the the web application is in the same ear as the SSBs/entities or deployed as a separate WAR.

          The same application running entirely remotely (i.e. not in JBoss but accessing the SSBs/entities remotely) works fine.

          So...it appears to just be an issue within the same JVM.

          • 17. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
            bill.burke

            Guys,

            I need more information. I need a test case I can reproduce. Currently, we cannot reproduce any of your problems.

            There are two completely different problems I see on this thread:

            1) Stateful Session Bean passivation errors

            2) Remoting serialization errors.

            Please, I need small test cases for both. Please complete a JIRA issue and attach your code then I can look into the problem.

            • 18. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
              elkner

               

              "bill.burke@jboss.com" wrote:
              Guys,
              I need more information. I need a test case I can reproduce. Currently, we cannot reproduce any of your problems.


              Now I've found one too in an old app, which I'm currently converting to 4.0.4RC1. Reduced stuff looks like this:
              @Entity
              @Table(name="categories")
              public class A_CatTest implements Serializable {
               private int id;
               private A_CatTest parent;
              
               A_CatTest() { }
              
               @Id @GeneratedValue(strategy=GenerationType.AUTO)
               @Column(name="categories_id", nullable=false)
               public int getId() {
               return this.id;
               }
              
               public void setId(int id) {
               this.id = id;
               }
              
               @ManyToOne(fetch = FetchType.LAZY)
               @JoinColumn(name="parent_id", referencedColumnName="categories_id",
               nullable=true)
               public A_CatTest getParent() {
               return this.parent;
               }
              
               public void setParent(A_CatTest parent) {
               this.parent = parent;
               }
              }
              
              @Remote
              public interface CatTestDao {
               List<A_CatTest> getRoots();
              }
              
              @Stateless
              @Interceptors(foo.TraceInterceptor.class)
              public class CatTestManager extends Manager
               implements CatTestDao
              {
               @SuppressWarnings("unchecked")
               public List<A_CatTest> getRoots() {
               return manager
               .createQuery("SELECT m FROM A_CatTest m WHERE m.parent.id=0")
               .getResultList();
               }
              }
              
              public class RichClient() {
              ...
               public void doSomething() {
               List<A_CatTest> lt = null;
               try {
               InitialContext ctx = manager.getContext();
               CatTestDao d = (CatTestDao)
               ctx.lookup("foo/CatTestManager/remote");
               lt = d.getRoots();
               } catch (Exception e) {
               log.warn(e.getLocalizedMessage());
               if (log.isDebugEnabled()) {
               log.debug("doSomething", e);
               }
               }
               for (A_CatTest c : lt) {
               System.out.println(c.getId());
               }
               }
              }
              


              03:06:42,958 [AWT-EventQueue-0] ERROR (SocketClientInvoker.java:279) - Got marshalling exception, exiting
              java.lang.ClassCastException: cannot assign instance of org.hibernate.proxy.SerializableProxy to field foo.A_CatTest.parent of type foo.A_CatTest in instance of foo.A_CatTest
              at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:1977)
              at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1157)
              ...
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
              at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:107)
              at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
              ...
              at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
              at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
              at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:265)
              at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:136)
              at org.jboss.remoting.Client.invoke(Client.java:444)
              at org.jboss.remoting.Client.invoke(Client.java:407)
              at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
              at $Proxy2.getRoots(Unknown Source)
              at foo.RichClient.doSomething(RichClient.java:71)


              • 19. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
                clebert.suconic

                In your example, you were using JavaSerialization over remoting (JavaSerializationManager in your stack trace).

                So, it looks this is a problem of AOP Proxy Serialization.

                I will try to replicate this problem on monday. (Althrough I have already used Remote Proxies on Friday. But I will update every single piece of source code I have. Maybe someone changed something)

                I have seen another thread about AOPProxy serialization being broken.


                But we still need help replicating this.

                If you can produce a small application that does it, you can attach it to JIRA at:

                http://jira.jboss.com/jira/browse/EJBTHREE-423

                • 20. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
                  clebert.suconic

                  I still haven't replicated the issue on EJB3, but I have replicated a problem saving Class arrays. (Thanks for Adrian Brock who discovered the error just by looking at my code :-) )

                  So, if whoever is having the issue, could try replacing jboss-serialization.jar by this JAR:

                  http://jira.jboss.com/jira/secure/attachment/12311542/jboss-serialization.jar


                  Warning: This is not an official release. This is just a test, ok?


                  The fix is OK and pretty small (Just the way I was solving Persisters on PersisterResolver), but I want to run few more tests before officially releasing it.

                  Thanks,


                  Clebert Suconic

                  • 21. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
                    elkner

                    Does not help. Still the same problem.

                    • 22. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
                      elkner

                      But I think, I know why: The legacy db has no/does not support FKs.

                      Try the given example with mysql (I'm using 5.0.15):

                      USE test;
                      DROP TABLE IF EXISTS `categories`;
                      CREATE TABLE `categories` (
                       `categories_id` int(11) NOT NULL auto_increment,
                       `parent_id` int(11) NOT NULL default '0',
                       PRIMARY KEY (`categories_id`),
                       KEY `idx_categories_parent_id` (`parent_id`)
                      ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
                      
                      /*!40000 ALTER TABLE `categories` DISABLE KEYS */;
                      LOCK TABLES `categories` WRITE;
                      INSERT INTO `categories` VALUES (1,0),(4,0),(5,0),(8,0),(2,1),(3,2),(6,5),(7,6);
                      UNLOCK TABLES;
                      /*!40000 ALTER TABLE `categories` ENABLE KEYS */;
                      commit;


                      If you still want the testapp, just let me know. I've now a separate eclipse project for sharing complete "test" apps (i.e. relevant parts only, but usually working ;-)).

                      • 23. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
                        phon

                        i've not been able to isolate a test which evokes this error each time. my only observations until now are (concercning the remote serialization):

                        1 ) it doesn't work all the time with a Swing client from eclipse, but it works sometimes , i guess it depends on the kind of data i fetch but haven't been able to narrow down what data

                        2 ) it works always in the Java Web Start environment..

                        i'll try to get that test working

                        • 24. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4

                          Test case that reliably reproduces the problem added to new JIRA report:

                          http://jira.jboss.com/jira/browse/EJBTHREE-440

                          • 25. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
                            phon

                            thanks, the test fails here also.. i hope someone finds the cause of this soon

                            i want to set something straight from my previous post though. i said that the exception did not happen for all data. i found that kinda strange, so i checked again. i noticed it does happen for all data, but not when the attribute is null, which seems logical.

                            still doesn't happen in a web start environment using the same jars thought. the only difference is that they are signed in the webstart env. could that have something to do with it ?

                            concercing the exception on the server when passivating, i think it's actually the same problem, as i only have problems with stateful session bean if they work with obejcts that can have lazy attributes. maybe they can't be serialized for passivation, and that's why an exception occurs ?

                            • 26. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4

                              I noticed that the whole client app very much depends on class loader issues. For example when you change my ant script not to fork the VM for the test target, you will get different exceptions. All depends a lot on the classpath as well. If you miss out certain jar files you get quite strange exceptions...

                              • 27. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
                                clebert.suconic

                                This post is just to state that these issues:

                                http://jira.jboss.com/jira/browse/EJBTHREE-423

                                http://jira.jboss.com/jira/browse/EJBTHREE-440


                                Are totally different issues.

                                423 was about proxy serialization on SFB passivation.
                                440 is about proxy serialization over regular ObjectOutputStream.

                                For some reason readResolve is not being called. The testcase on 440 is relevant.

                                A proxy instance is being set with an invalid readResolve call.

                                • 28. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
                                  elkner

                                  Another hint I got wrt. 440:

                                  0 DEBUG [ main ] org.jboss.security.SecurityAssociation - Using ThreadLocal: false
                                  50 DEBUG [ main ] org.jboss.remoting.Client - invoke called, but our invoker is disconnected, discarding and fetching another fresh invoker for: InvokerLocator [socket://192.168.21.1:3873/?serializationtype=java]
                                  51 DEBUG [ main ] org.jboss.remoting.transport.socket.SocketClientInvoker - connect called for: org.jboss.remoting.transport.socket.SocketClientInvoker@8a0d5d
                                  69 DEBUG [ main ] org.jboss.remoting.marshal.MarshalFactory - Tried to find marshaller from locator by both data type and class name but was unsuccessful. Will try to load it from remote server.
                                  70 DEBUG [ main ] org.jboss.remoting.marshal.MarshalFactory - Could not find unmarshaller by data type ('null'). Will try to load dynamically.
                                  112 DEBUG [ main ] org.jboss.remoting.marshal.MarshalFactory - Tried to find marshaller from locator by both data type and class name but was unsuccessful. Will try to load it from remote server.
                                  112 DEBUG [ main ] org.jboss.remoting.marshal.MarshalFactory - Could not find unmarshaller by data type ('null'). Will try to load dynamically.
                                  1480 ERROR [ main ] org.jboss.remoting.transport.socket.SocketClientInvoker - Got marshalling exception, exiting
                                  java.lang.ClassCastException: cannot assign instance of org.hibernate.proxy.SerializableProxy to field foo.bar.entities.CatTest.parent of type foo.bar.entities.CatTest in instance of foo.bar.entities.CatTest
                                  at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:1977)

                                  So I guess this is really a bug...

                                  • 29. Re: Problem with Lazy attributes - 4.0.3SP1-EJB3.0RC4
                                    clebert.suconic

                                    Just a FYI,

                                    http://jira.jboss.com/jira/browse/EJBTHREE-440

                                    I have removed everything from the attached testcase that was not generating the error, and kept only what was causing the issue.

                                    Apparently this is caused by Lazy attributes over Inheritance. I have tried several different combinatios of lazy attributes and all of them worked while I was trying to replicate this.

                                    Well, the testcase is now created. It will be easier to fix the problem now.