Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

unmarshal exception

 
arnold yan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to make an EJB call. I have a stand-alone ELB client running on my PC to call the EJB. The input I pass to EJB is a HashMap and the output is another HashMap. It works fine. However, as soon as I move the client into another EJB, meaning, I make the same EJB call from a second EJB, I get the exeption like this,

java.rmi.UnmarshalException: failed to unmarshal class java.util.HashMap; nested exception is: java.io.StreamCorruptedException

How come the exactly same code works locally but not inside an EJB? Is it because the returned HashMap is too large? It does have hundreds of entries. I've specified <trans-attribute> as NotSupported, so the credential should not be an issue, either.

Thanks for help.

Arnold
 
arnold yan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone has an idea about this problem?
 
asif aleem
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
unmarshallException comes when Serialization of that value is not possible try importing java.io.* and then make ur class implements Serializable interface it will work fine
 
arnold yan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have import java.io.*, and the return value is a HashMap which is serializable. What confused me is, why the same code works as a standalone client but does not work inside an EJB. Is there something in the deployment descriptor that I need to change?

Thanks.

Arnold
 
parthiban subramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
imporing io etc is just silly,
Hashtable is Serializable but the objects that you place in the hashtable might not be,
they too have to implement Serializable interface otherwise it just wont work mate

cheers,
parthi
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not too sure that i get it
"...Hashtable is Serializable but the objects that you place in the hashtable might not be,they too have to implement Serializable interface otherwise it just wont work mate..."
Agree with the above statement.But in this case, if it is so, how come it works when called from a client - doesnt Serialization have any part to play in that case ?
 
Amit Jaipaul
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
confusing problem. i agree both with parthiban and PNS. This exception comes only when stuff within a Hashtable does implement Serializable.

However this is not a solution, Arnold just try recreating the Jar(with EJB calling another EJB) and redeploying ur EJB's.
 
arnold yan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks folks for the help. I believe I finally found the problem. It seems to be some internal problems with BEA. I reduced the size of return HashMap from 15k to 4k and then it worked fine when I made an EJB to EJB call. I would think there are something configurable inside BEA to allow me getting large amount of data via EJB calls. I searched deployment descriptors but had no luck.

Arnold
 
S Manch
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>>. I reduced the size of return HashMap from 15k to 4k and
are you sure that is the problem....

Just reducing the size from .15MB to .4MB works...that is a little hard to believe! I am not sure how u cut the size.. try increasing the size from .4MB to .15 MB in little chunks and see where it breaks! probably you might catch a value that might not be serializable! :-)

sanjay.
 
parthiban subramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm wonder how you reduce the size of your HahMap,
i would suggest you look for all the objects you place in your hashmap there would be something which does not implement the Serializable,

parthi
 
arnold yan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make the case clear, it works fine in a local client, and it does not work in an EJB. The code is exactly the same, it is where I make the call from makes the difference. This should clearly rule out the possibility of serialization issue, don't you agree?

fyi, I reduced the hashmap size by filtering out some entries I don't need.

Arnold
 
parthiban subramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no it wont,
App servers are a bit intelligent then you think,
even if you use remote ejb's a few app servers out there wont marshal and unmarshal data if the entire app is running in one jvm where there is no need to transport the data over a network layer.

parthi
 
arnold yan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Let me restate my original problem.

My local client runs on my PC (JVM1), it calls a remote EJB (JVM2), getting a hashmap back, able to serialize it.

I put my client inside another EJB (JVM3), it calls the same remote EJB (JVM2), getting the same hashmap back, not able to serialize it.

None of the EJBs runs on the same app server. Each component runs on a diferrent JVM.

Arnold
 
Ade Barkah
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might be encountering a "network classloading" issue.

Among the hundreds of objects in your HashMap, some of them might be of a derived type not directly available in the client's classpath. Eg., suppose you have a HashMap of "Animals", containing "Dogs" and "Cats", but the client only knows about "Animals" (the base class or interface.)

Consider then two scenarios:

1. When you have a non-server client, the underlying RMI mechanism will automatically "download" the implementation of the subtypes ("Dogs" and "Cats") over the network, and everything works transparently. This is known as "network classloading."

2. When the call is between two servers, the container might block network classloading for security reasons. The client server will not be able to unmarshall the object, and an exception is thrown.

Solutions include: a) configure the servers to enable "network classloading"; b) include stubs for all required objects on both servers so classloading isn't necessary.

I'm not certain that this is the problem as I would have expected a different error message, but perhaps this avenue is worth exploring.

HTH,

-Ade Barkah
[ August 03, 2004: Message edited by: Ade Barkah ]
 
arnold yan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The returned HashMap contains objects such as String, Character, Double, ArrayList, Integer and Exception. All of the data types are defined in jdk. No third party ADT is used. I don't believe class loading is a factor in this case.

Arnold
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!