-
1. Re: Beta1: wrong object class when getting session bean from
fushion Jun 29, 2005 8:29 AM (in response to elmosca)Instead of
UserManager um = (UserManager) ctx.lookup(UserManager.class.getName());
Maybe you should tryUserHandler uh = (UserHandler) ctx.lookup(UserHandler.class.getName());
:-) -
2. Re: Beta1: wrong object class when getting session bean from
fushion Jun 29, 2005 8:34 AM (in response to elmosca)... and why are you extending your UserHandler interface instead of implementing it?
Maybe you should post some better (correct) samples so we can have a proper look at them. -
3. Re: Beta1: wrong object class when getting session bean from
elmosca Jun 29, 2005 9:35 AM (in response to elmosca)Ups, sorry :-( I wrote it by heart as I am not at the office, and I wanted to make the code more readable using classes with common names... and the effect has been the oposite :-(
Of course, Fushion I get the instance of the been doing:UserHandler uh = (UserHandler) ctx.lookup(UserHandler.class.getName());
and of course, UserHandlerBean implements UserHandler, Serializable...
The good thing in all this is that it seems that I am the only one having this problem.... :-/
Thanks and regards,
Bruno -
4. Re: Beta1: wrong object class when getting session bean from
elmosca Jun 29, 2005 12:06 PM (in response to elmosca)Well, now I have it running in jboss4.0.1sp1 again (but with the EJB3.0 beta1). Should be ok, until I can upgrade again,
Regards,
Bruno -
5. Re: Beta1: wrong object class when getting session bean from
elmosca Jun 30, 2005 11:33 AM (in response to elmosca)I am having more problems with jboss4.0.1sp1 so I've decided to give a new try to jboss4.0.3RC1 to see if I find where I might have something wrong...
I've tried to see why the server is throwing a ClassCastException when doing from a webapp (and not from a standalone client outside Jboss):my.company.UserHandler uh = (my.company.UserHandler) ctx.lookup(my.company.UserHandler.class.getName());
I've tried to see what king of object is returning ctx.lookup, and the results have been those:
Object class returned by ctx.lookup -> $Proxy127
(obj instanceof my.company.UserHandler) -> returns false
But, surprisingly, if I get the interfaces of this object using reflection I get two interfaces:
- my.company.UserHandler
- org.jboss.ejb3.JBossProxy
Weird, if one of the interfaces is UserHandler (as expected) why is the cast throwing an exception, how can the instanceof return false if one of the interfaces implemented by the Proxy is UserHandler?
Another question, how can the application from the server fail and the standalone test client work? Could it be a classpath issue?
The only difference I see is that in the server I have to copies of UserHandler (one inside the *.par file) and another inside a jar (the jar that my application has in the WEB-INF/lib to be able to use the session bean).
Any help will be appreciated,
Bruno -
6. Re: Beta1: wrong object class when getting session bean from
kabirkhan Jun 30, 2005 11:51 AM (in response to elmosca)With the tomcat classloader settings that ship with 4.0.3 you will always load the copy from WEB-INF/lib from the web layer, and this uses a different classloader from the one used inside the ejb layer. Two classes loaded by different classloaders are not the same to the java runtime, and will cause runtime exceptions when you try to assign a reference to one to the other.
Try removing UserHandler from the jar in WEB-INF/lib, this will make sure that there is only one copy of the class ever loaded.
Take a look at
http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration
and
http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossClassLoadingUseCases
(The classloading settings for the web layer changed after 4.0.1, which is why you are suddenly having these problems w/ 4.0.3) -
7. Re: Beta1: wrong object class when getting session bean from
elmosca Jun 30, 2005 12:14 PM (in response to elmosca)Thanks Kabir!, that was exactly the cause...
Regards,
Bruno
p.s. now there is another happy person in the World ...