Is it wise to put jars in classpath for a application server?
Hello!I have struggled to solve a problem.
The background to the problem was that I had this code:
Object object = context.lookup("namesejb/client/NameManagerEJBHome");
NameManagerEJBHome nameManagerEJBHome = (NameManagerEJBHome)PortableRemoteObject.narrow(object, NameManagerEJBHome.class);
That gave me this exception:
java.lang.ClassCastException: Cannot narrow remote object to namesejb.client.NameManagerEJBHome
I found some code that could tell me the location from where the class was loaded and then:
Class c = Class.forName("namesejb.client.NameManagerEJBHome");
Followed by:
System.out.println("\tClassloaction1: " +getClassLocation(object.getClass()));
System.out.println("\tClassloaction2: " +getClassLocation(c));
..told me:
Classloaction1: jar:file:/home/fredrik/Applications/bea/weblogic81/server/lib/weblogic.jar!/namesejb/server/NameManagerSessionBean_o0oo54_HomeImpl_816_WLStub.class
Classloaction2: file:/home/fredrik/Applications/bea/user_projects/domains/mydomain/./webserviceserver/.wlnotdelete/extract/webserviceserver_axis2_axis2/public/axis223088nameswebservice.aar
This page acctually told me what to do:
http://forums.sun.com/thread.jspa?threadID=5190032&tstart=391
Put the class namesejb.client.NameManagerEJBHome into the classpath for the server. (Btw I use wls 8.1.5)
I did that and now it is working fine.
But the feeling of need to manually put the class in the classpath does not feel right.
Does any one see any better way. I would just love to put it inside my webservice app - fine!
Perhaps this is a common classloader issue in wls?
Would love to get som comments around this!
Best regards
Fredrik