1 Reply Latest reply on Nov 8, 2005 1:43 AM by Mark Brazil

    bidirectional onetomany

    Mark Brazil Newbie

      I'm trying to setup a bidirectional onetomany with ejb3.

      If I just have the manytoone side everything works fine, as below

      @ManyToOne
      @JoinColumn(name="MODULEID_FK", nullable=false)
      public Module getModule() {
      return module;
      }
      public void setModule(Module module) {
      this.module=module;
      }


      However if I add the onetomany side in as follows

      @OneToMany(mappedBy="module")
      public List getBales() {
      return bales;
      }
      public void setBales(List bales) {
      this.bales = bales;
      }


      I get the following error from the client. Any help would be great.

      Thanks,
      Mark.


      Exception in thread "pool-3-thread-3" java.lang.reflect.UndeclaredThrowableException
      at $Proxy3.queryRecords(Unknown Source)
      at apps.client.BaleClient.getResultData(Unknown Source)
      at apps.client.BaleClient.access$2000(Unknown Source)
      at apps.client.BaleClient$14.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.ClassNotFoundException: org.hibernate.collection.PersistentBag
      at com.sun.jnlp.JNLPClassLoader$1.run(JNLPClassLoader.java:259)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.jnlp.JNLPClassLoader.findClass(JNLPClassLoader.java:247)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at com.sun.jnlp.JNLPClassLoader.loadClass(JNLPClassLoader.java:600)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:242)
      at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:574)
      at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:102)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1538)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
      at java.util.ArrayList.readObject(ArrayList.java:592)
      at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:919)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1813)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      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 java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
      at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:73)
      at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:242)
      at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:112)
      at org.jboss.remoting.Client.invoke(Client.java:226)
      at org.jboss.remoting.Client.invoke(Client.java:189)
      at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:41)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:88)
      ... 7 more

        • 1. Re: bidirectional onetomany
          Mark Brazil Newbie

          Ok, found the answer.

          For anyone interested, when you are using remote clients add hibernate3.jar to your list of library's.




          "markbrazil" wrote:
          I'm trying to setup a bidirectional onetomany with ejb3.

          If I just have the manytoone side everything works fine, as below

          @ManyToOne
          @JoinColumn(name="MODULEID_FK", nullable=false)
          public Module getModule() {
          return module;
          }
          public void setModule(Module module) {
          this.module=module;
          }


          However if I add the onetomany side in as follows

          @OneToMany(mappedBy="module")
          public List<Bale> getBales() {
          return bales;
          }
          public void setBales(List<Bale> bales) {
          this.bales = bales;
          }


          I get the following error from the client. Any help would be great.

          Thanks,
          Mark.


          Exception in thread "pool-3-thread-3" java.lang.reflect.UndeclaredThrowableException
          at $Proxy3.queryRecords(Unknown Source)
          at apps.client.BaleClient.getResultData(Unknown Source)
          at apps.client.BaleClient.access$2000(Unknown Source)
          at apps.client.BaleClient$14.run(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
          at java.lang.Thread.run(Thread.java:595)
          Caused by: java.lang.ClassNotFoundException: org.hibernate.collection.PersistentBag
          at com.sun.jnlp.JNLPClassLoader$1.run(JNLPClassLoader.java:259)
          at java.security.AccessController.doPrivileged(Native Method)
          at com.sun.jnlp.JNLPClassLoader.findClass(JNLPClassLoader.java:247)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
          at com.sun.jnlp.JNLPClassLoader.loadClass(JNLPClassLoader.java:600)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
          at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Class.java:242)
          at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:574)
          at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:102)
          at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1538)
          at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
          at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
          at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
          at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
          at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
          at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
          at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
          at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
          at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
          at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
          at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
          at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
          at java.util.ArrayList.readObject(ArrayList.java:592)
          at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:585)
          at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:919)
          at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1813)
          at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
          at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
          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 java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
          at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
          at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
          at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
          at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
          at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
          at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
          at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:73)
          at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:242)
          at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:112)
          at org.jboss.remoting.Client.invoke(Client.java:226)
          at org.jboss.remoting.Client.invoke(Client.java:189)
          at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
          at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
          at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
          at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:41)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
          at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:88)
          ... 7 more