While porting an application from WebLogic server to 4.0.0, I've noticed a 
strange feature of the server's classloader. Well, it was hard to miss a 
NullPointerException raised deep inside an EJB method call.... ;)

In brief, the problem is this: if jar file with my.test.package classes is 
stored in /lib directory of the configuration, java.lang.Package.getPackage( 
"my.test.package" ) call returns null, but Class.forName( 
"my.test.package.SomeClass" ).getPackage() returns the information from the 
jar's manifest.mf.

I tried moving the jar into my webapp's WEB-INF/lib, and in this case both 
calls returned valid results.

I wonder if the server can be configured in a way that allows access to 
manifest information of /lib jarfiles via Package.getPackage() calls... I 
suspect there should be some tricks, since in the array returned by 
Package.getPackages() there are entries that apparently correspond to some of 
the /lib jarfiles.

--------------------------------------

The effect is easily reproducable in the default server configuration: I've put 
test.jsp (below) into server/default/jbossweb-tomcat50.sar/ROOT.war and put the 
jar into server/default/lib or ....ROOT.war/WEB-INF/lib.

test.jsp:

  | <html>
  | <body>
  | <%
  |     Package pack = Class.forName( "mypackage.TestClass" ).getPackage();
  |     if( pack ==null ) { %><h3>nulllllll</h3><%}
  |     else
  |     {
  |     %><h3><%= pack.getName() %></h3>
  | <pre>Spec.title   : <%= pack.getSpecificationTitle() %>
  | Spec.vendor  : <%= pack.getSpecificationVendor() %>
  | pack.toString: <%= pack.toString() %>
  | </pre><%
  |     }
  | 
  |     pack = Package.getPackage( "mypackage" );
  |     if( pack ==null ) { %><h3>nulllllll</h3><%}
  |     else
  |     {
  |     %><h3><%= pack.getName() %></h3>
  | <pre>Spec.title   : <%= pack.getSpecificationTitle() %>
  | Spec.vendor  : <%= pack.getSpecificationVendor() %>
  | pack.toString: <%= pack.toString() %>
  | </pre><%
  |     }
  | %>
  | </body>
  | </html>
  | 

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3873192#3873192

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3873192


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to