• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

ClasscastException when passing an object between 2 EAR's

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have the following problem. I have a serializable object which I pass between 2 EJB's. These EJB's are located in 2 seperate EAR files. When I pass a Vector of these objects between those 2 beans, I get a ClassCastException in the receiving EJB. I am completely sure that those 2 EAR's have the same version of this class in their classpath's.
Also, an instanceof resturns false, but when I walk through the code with a debugger, I look into the Vector and see that there are indeed objects inside which have the name of the class which I'm trying to cast. So It's really weird.
I use Websphere 5.
Maybe someone has already encountered this problem before, or all sugestions or ideas are welcome...
Thanks
Johan Vandevenne
[ May 12, 2003: Message edited by: Johan Vandevenne ]
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When did you get ClassCastException? Is it thrown when you cast Vector.get(int) or sth else? It seems a RMI issue.
I got a similar problem when I tried to pass ArrayList across .ear files, but that is because ArrayList uses transient member variables to hold its elements. Vector is a totally different story, it holds its element with this:
protected Object elementData[];
So it's weird unable to use Vector across .ears.
One possible way to avoid ClassCastException is to package the common objects in a separate .jar and put this .jar in a shared directory such as $WAS_ROOT/lib/app. This is also recommeneded in WebSphere InfoCenter.
tao
[ May 14, 2003: Message edited by: Tao Liu ]
[ May 21, 2003: Message edited by: Tao Liu ]
[ May 21, 2003: Message edited by: Tao Liu ]
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if this will help but here's some info regarding the ClassCastException. I hope this is useful.
Classloader Mode
Specifies whether the classloader searches in the parent classloader or in the application classloader first to load a class. The standard for JDK classloaders and WebSphere Application Server classloaders is PARENT_FIRST. By specifying PARENT_LAST, your application can override classes contained in the parent classloader, but this action can potentially result in ClassCastException or LinkageErrors if you have mixed use of overridden classes and non-overridden classes.
The options are PARENT_FIRST and PARENT_LAST. The default is to search in the parent classloader before searching in the application classloader to load a class.
 
Ranch Hand
Posts: 925
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try turning off jit compiler.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
An object that is used by 2 EAR can be put into <websphere>/lib/ext. In this case the class that encapsulated by vector.
I think it's because of diffrent classloader mecanishm (as Randal said)
Hopefully it's help...
 
Tao Liu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With 2 EARs, I can recreate the ClassCastException in WAS 4.0.4 (as in WSAD5), but it's OK (no exception) in WAS 5.0. I make the two configurations equivalent according to WebSphere documentation. Could you please explain why it works on one version but not the other?
Thanks in advance,
-----------------------------------------------
The server configurations are set as default:
1) The module visibility of WAS 4.0.4 is J2EE (com.ibm.ws.classloader.J2EEApplicationMode=true);
disableJIT="false"
2) The server configuration of WAS 5.0:
Application classloader policy = MULTIPLE;
Application classloder mode = PARENT_FIRST
WAR classloader policy = MODULE
disableJIT="false"
[ May 28, 2003: Message edited by: Tao Liu ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic