0
votes

I have two classes org.my.ClassA and org.my.ClassB both classes are in the same package org.my in the WEB-INF/src in the same database. ClassA has the method public add(org.my.ClassB newB){...}.

In SSJS I have a code block in which I call ClassA.add(ClassB) which normally works fine. Until some unknown point where the Server can't see that org.my.ClassB === org.my.ClassB and it returns the error (message translated from German maybe looks different in English version):

    error calling method 'add(org.my.ClassB)' in java-class 'ClassA'. 
    'org.my.ClassB' is incompatible with 'org.my.ClassB'.

and it points to my line in the SSJS: ClassA.add(ClassB);

What I tried so far:

First I added the line importPackage(org.my); to my SSJS Code. No luck.

I tried to add another method add(Object newB) and then cast the object to ClassB but same result. The error does not seem to come from the java class its from the SSJS code because it cant find the method with an argument of the type org.my.ClassB. But if I test the object in the SSJS code it returns org.my.ClassB.

Then I tried to add the classpath to all variables in the SSJS block like: var newB:org.my.ClassB = new org.my.ClassB(). But same result after some time the application breaks with the same error.

From my Point of view it got to do something with the caching of compiled classes, or so because if I clear the database everything works just fine again.

Hope someone has a solution on this.

1
Went the last dot lost during translation (org.myClassB instead of org.my.ClassB) ?Sven Hasselbach
.. Y got lost in translation.. Correct it as soon as i can login to stackoverflow with my PC again. These two classes are just for example... But i already double checked all classnames and methode namens.Michael Saiz
Can you post the whole stack trace? Maybe a class loader problem... stackoverflow.com/questions/5352550/…Sven Hasselbach
Thanks Sven that realy sounds like my issue.. i will give it a shot... update: jup..java.lang.ClassCastException: org.my.ClassB incompatible with org.my.ClassBMichael Saiz

1 Answers

1
votes

This is a class loader problem.

You can find more details about the issue in the answer from Frantisek Kossuth: See here more details: Meaning of java.lang.ClassCastException: someClass incompatible with someClass