File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Application Frameworks and the fly likes Seam: Misterious ClassCastExceptions during EJB use Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Seam: Misterious ClassCastExceptions during EJB use" Watch "Seam: Misterious ClassCastExceptions during EJB use" New topic

Seam: Misterious ClassCastExceptions during EJB use

Ole Hornischer

Joined: Nov 14, 2008
Posts: 27
Hey everyone!
I have a weird problem. I get ClassCastExceptions of the following kind while using EJB stateless session beans from my seam project:

Caused by javax.el.ELException with message: "java.lang.ClassCastException: com.tza.dto.RegisteredClientDTO cannot be cast to com.tza.dto.RegisteredClientDTO"

The history: I have an application, that used to be deployed as an ear file in my app server and served to a set of java clients. All worked fine. Now I wanted to add a web component to the application providing visualisation for some data retrieved from the sever ear. So at first I created a seam war file accessing stateless session beans on the server ear to retrieve the data. But that wouldn't work. I got said ClassCastExceptions.
I then packaged the old application and the new web app into one big ear file. The data was still accessed via SSBs and I have the same problem.

Somewhere I read that this can be caused by duplicate class files in the classpath, so i cleaned up the cp and now do not have any doubles left - same problem.

The example exception I get after trying to access objects from a List<RegisteredClientDTO> I retrieved via an EJB from the server app to my web app.

Any ideas what could cause this behaviour?

Vinod Tiwari
Ranch Hand

Joined: Feb 06, 2008
Posts: 466

Can you provide stack trace?

Vinod Tiwari | Twitter | Shikshanirman | Guftgu
Ole Hornischer

Joined: Nov 14, 2008
Posts: 27
The Stacktrace is:

And ClientLister is:

Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

I noticed that you are using JNDI to locate a service object, why you aren't using Seam BI?
Are you sure that RegisteredClientDTO's version returned from bean.getRegisteredClients() is same of your Seam RegisteredClientDTO version?
I mean what if the two versions aren't compatible? some updated and recompile RegisteredClientDTO ?
I'm not saying this the problem, but I will dig it if I were you.
Ole Hornischer

Joined: Nov 14, 2008
Posts: 27
That was my first idea as well, but I recompiled both applications again with current sources and made sure that there is only one occurence of the class file in the classpath of both applications (which are by now merged to one exploded ear).

I did not know about Seam BI, so I will look into that, I used JNDI because I knew how to. Is there some kind of incompatibility between Seam and JNDI?
I agree. Here's the link:
subject: Seam: Misterious ClassCastExceptions during EJB use
It's not a secret anymore!