Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / August 2003

Tip: Looking for answers? Try searching our database.

UndeclaredThrowableException on collection return to client

Thread view: 
Tomer Ben-David - 23 Aug 2003 16:59 GMT
Hi

Im using jboss 3.2.1 & xdoclets
I wrote some test code to return a collection of entity beans:

-----------
The problem
-----------

On my client i receive this exception:

java.lang.reflect.UndeclaredThrowableException
        at $Proxy1.getTomer(Unknown Source)
        at com.doridan.master.master.client.UserSessionFacadeTest.testMethod(UserSessionFacadeTest.java:66)
        at com.doridan.master.master.client.UserSessionFacadeTest.main(UserSessionFacadeTest.java:38)
Caused by: java.io.NotSerializableException:
org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
        at java.rmi.MarshalledObject.<init>(MarshalledObject.java:92)
        at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:363)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)

        at sun.rmi.transport.Transport$1.run(Transport.java:148)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
        at java.lang.Thread.run(Thread.java:534)
        at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
        at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
        at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown
Source)
        at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
        at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:87)
        at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
        at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)

        at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
        at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
        ... 3 more

-------
My Code
-------

Here is the method im using (from my session bean)

 /**
  *
  * @ejb.interface-method   view-type="remote"
  * @ejb.permission         unchecked="true"
  **/
 public java.util.Collection getChildren(String username, String
password) throws ObjectNotFoundException
 {
   System.out.println("UserEntityLocal user = null;");
   UserEntityLocal user = null;
   try {
     System.out.println("user = _userHome.findUser(username,
password);");
     user = _userHome.findUser(username, password);
   } catch (ObjectNotFoundException objectNotFoundException) {
     throw (objectNotFoundException);
   } catch (FinderException finderException) {
     finderException.printStackTrace();
   }
   System.out.println("return (user.getChildren());");
   System.out.println("count of children is: " +
user.getChildren().size());
   return (user.getChildren());
 }

Here is the code from my client:

   System.out.println(((UserEntityData) ejbObj.findUser("tomerbd",
"tomerbd")).getEmail()); // fine
   System.out.println("getting children"); // fine
   ejbObj.getChildren("tomerbd", "tomerbd"); // i get the exception

-----------------
The jboss console
-----------------

18:48:10,734 INFO  [Server] JBoss (MX MicroKernel) [3.2.1 (build:
CVSTag=JBoss_3
_2_1 date=200305041533)] Started in 2m:17s:67ms
18:48:39,135 INFO  [STDOUT] _userInfoHome <-
ejb/master/LocalUserInfoEntityHome
18:48:40,617 INFO  [STDOUT] UserEntityLocal user = null;
18:48:40,617 INFO  [STDOUT] user = _userHome.findUser(username,
password);
18:48:40,667 INFO  [STDOUT] return (user.getChildren());
18:48:40,868 INFO  [STDOUT] count of children in tomer is: 0

----

Anybody knows whats the problem? since it seems like i do have a
collection on my session bean on the server (the console of the jboss
is printing it as 0), however when getting this collection to the
client on the client i get this exception............................

Thanks in advance...
Chris Lamprecht - 23 Aug 2003 23:15 GMT
The problem (I'm 99% sure) is that you're trying to return a CMR collection
(getChildren()) to the client, which you can't do.  They're only available
locally, and in the context of the current transation.  I ran into the same
problem, so in my session bean, I copy the collection to a new Collection of
value objects, and return that.  (You could also copy it to a collection of
new children that aren't necessarily value objects, as long as the actual
Collection you're returning isn't the one getChildren() returned to you.

-Chris

> Hi
>
> Im using jboss 3.2.1 & xdoclets
> I wrote some test code to return a collection of entity beans:


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.