You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Bravo, Kris X" <KX...@ups-scs.com> on 2002/08/21 19:45:45 UTC

Classloader issue with Weblogic 6.1sp3

I'm having a problem deploying an application on Weblogic(WL) 6.1sp3, using
Struts, and extending MessageResourcesFactory and MessageResources in my
webapp. I found a work-around, but I need a better solution for production.

<plug>I caught Chuck Cavaness' presentation on Struts for the Atlanta Java
Users Group last night.</plug> I got some solid feedback from the folks
there, but I'm still looking for an answer as to what is ultimately
happening.

The Background:

This is a basic web app, with about 8 action/form pairs, and business logic
in EJBs. I'm using an .ear file to deploy to the WL server. Again, Weblogic
6.1sp3.

The Problem:

I am also using a custom MessageResourceFactory to load the strings for the
web pages from a database (don't ask. I was ordered) instead of a
.properties file. Everything works just great without the custom factory.
But when I identify it in the web.xml,

<init-param>
  <param-name>factory</param-name>
 
<param-value>com.ups.apennine.outbound.language.LanguageLoader</param-value>
</init-param>

I get a NoClassDefFound on MessageResourceFactory. If I call the factory
later, (e.g., in an action object), as oppose to the ActionServlet.init(),
the same thing happens. Keep in mind that by this time, the ActionServlet
has already used an instance of MessageResourceFactory to load the messages
property resource bundle:

<init-param>
   <param-name>application</param-name>
   <param-value>com.ups.apennine.outbound.Constants</param-value>
</init-param>

I just can't seem to extend org.apache.struts.util.MessageResourceFactory,
despite the fact that the actions extend org.apache.struts.action.Action
just fine. The classloader fails to see the class, even though it loads the
original messages properties file just fine. I checked just to be certain,
and the same classloader that loaded the messages in the first place is
failing to create an instance of the custom factory.

I have tried putting struts in the .ear file and reference it in the .war
file manifest Class-Path; the error goes away, but, because of Weblogic's
classloader heirarchy and an SP2 bug fix (number 056911), struts can no
longer load the action objects for my application.

I tried exploding the struts.jar library into my /WEB-INF/classes directory
with my application classes. It still doesn't work!

The Workaround:

Finally, I split the struts.jar file into two jars (!): One just containing
the util package classes, and the other containing the rest of Struts. I
kept the main struts archive under /WEB-INF/lib, and I put the
"struts-util.jar" file, if you will, under /lib in the application .ear file
and added this to my .war manifest:

Class-Path: lib/struts-util.jar

So that worked. The MessageResourceFactory and MessageResource were loaded
by a more visible classloader, solving my problem, and the rest of the
struts.jar stayed put. Everyone is happy.

The question is, WHAT HAPPENED?!?! Any ideas on how I can deploy in this
scenario without splitting the library?

Kris Bravo