Avatar billede fredand Forsker
26. august 2008 - 21:29 Der er 3 kommentarer og
1 løsning

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
Avatar billede babelfish Nybegynder
10. oktober 2008 - 10:15 #1
The classloader of the app server of course needs to have the classes on its classpath. One should think it was able to extract them from the app itself, but all app servers have their quirks.

I have had the same problem with ActiveMQ - where I needed it to handle some of my classes - and had to put a jar of the classes on its classpath.
The problem, in my opinion, only exists if you cannot automate putting the necessary classes/jars on the servers classpath during deploy of the app it self.

My two cents.
/Brian
Avatar billede fredand Forsker
10. oktober 2008 - 16:33 #2
Hello!

Thanks for your input!
Then I guess that this is a common solution in some case!

Please give a svar so I can reward you mate!

Best regards
Fredrik
Avatar billede babelfish Nybegynder
10. oktober 2008 - 19:14 #3
I belive thats the pragmatic solution.

/Brian
Avatar billede fredand Forsker
11. oktober 2008 - 15:58 #4
Thanks mate!
/Fredrik
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester