cancel
Showing results for 
Search instead for 
Did you mean: 

ClassCastException...

Former Member
0 Kudos

Dear all,

In our project we have the following situation: (i'll TRY to explain 😛 )

Track A containing an EJB and track B containing an EJB.

EJB in Track A contains a AnInterface.java with some method.

EJB in Track B contains a SomeClass which implements AInterface.

For this, there's a @buildtime dependency on public part of EJB in A added to the used dc's of B.

In the EJB in track A there's also a class that contains the following code:

AnInterface a = (AnInterface)Class.forName("package.SomeClass").newInstance();

At first there were NoClassDefFound Exceptions, but after adding the classes from EJB in track B to a jar and adding that jar to a library and adding a reference to that library in the EJB in track B the ClassDef was found, but now there is a ClassCastException...

Is this because of different classloaders? What is the correct way to do this? (Previously it was working on BEA)

Kind regards,

J.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182372
Active Contributor
0 Kudos

Joren, ejb from A and B tracks are in different ears? You need to specify reference in ear from A to ear from B.

Former Member
0 Kudos

Hello,

yes they indeed are in different ears. But if i add a reference from A to B because A needs the classes from B, i also have to add a reference from B to A, because B also needs to know the interface class from A. This however gives a cyclic reference error at deploy.

I tried a workaround by adding the classes from A to libraryA and from B to a libraryB... and referencing these so i dont get a cyclic reference error, but this solution gives me the classcastexception...

Kind regards,

J.

Former Member
0 Kudos

if your interfaces / classes due to which you are getting cyclick ref error are such that you can take them out of both the projects and create a new library DC with that and set the dependancy of the two ear projects onto the library dc..

Former Member
0 Kudos

The classes are developed in different tracks so i prefer to keep them in different libraries... These libraries are a solution to the cyclic reference situation, but when running the application, i still get a ClassCastException because the classes are taken from different Classloaders, i think...

greetz,

J.