You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Baquedano Jesús <je...@yahoo.es> on 2001/01/10 15:52:00 UTC

Weblogic 5.1 Problem wtih Only one copy of struts.jar

I want to deploy applications in weblogic, and I do
not want to disturbute struts.jar in each war file of
every application. 
I have included struts.jar in the weblogic class path.
Then I find the problem that classes fromstruts.jar
are not able to find classes fron the application. 
For example, ther ActionForm classes cannot be loaded
by struts. Struts is not able to load the resources
file  (ApplicationResources.properties)
Is there any workaround to solve this problem without
including struts within all the war files?

This is the exception I get.

javax.servlet.jsp.JspException: Exception creating
bean of class org.apache.struts.example.LogonForm:
java.lang.ClassNot
FoundException: org.apache.struts.example.LogonForm
        at
org.apache.struts.taglib.FormTag.doStartTag(FormTag.java:506)
        at
jsp_servlet._logon._jspService(_logon.java:130)
        at
weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:106)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:124)
        at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:907)
        at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:851)
        at
weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:252)
        at
weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:364)
        at
weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:252)
        at
weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)





_______________________________________________________________
Do You Yahoo!?
Consiga gratis su dirección @yahoo.es en http://correo.yahoo.es

Re: Weblogic 5.1 Problem wtih Only one copy of struts.jar

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.

Baquedano Jesús wrote:

> I want to deploy applications in weblogic, and I do
> not want to disturbute struts.jar in each war file of
> every application.

If so, it is not going to work correctly ... the technical reasons for this are discussed below.

>
> I have included struts.jar in the weblogic class path.
> Then I find the problem that classes fromstruts.jar
> are not able to find classes fron the application.
> For example, ther ActionForm classes cannot be loaded
> by struts. Struts is not able to load the resources
> file  (ApplicationResources.properties)
> Is there any workaround to solve this problem without
> including struts within all the war files?
>
> This is the exception I get.
>
> javax.servlet.jsp.JspException: Exception creating
> bean of class org.apache.struts.example.LogonForm:
> java.lang.ClassNot
> FoundException: org.apache.struts.example.LogonForm
>         at
> org.apache.struts.taglib.FormTag.doStartTag(FormTag.java:506)
>         at
> jsp_servlet._logon._jspService(_logon.java:130)
>         at
> weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>         at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:106)
>         at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:124)
>         at
> weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:907)
>         at
> weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:851)
>         at
> weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:252)
>         at
> weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:364)
>         at
> weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:252)
>         at
> weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
>

What is happening has to do with how class loaders work in servlet containers.  A typical
container has a "hierarchy" of class loaders installed for a particular app:

    Bootstrap class loader (i.e. Java's startup classes)

    System class loader (i.e. contents of CLASSPATH)

    Webapp class loader (for this particular webapp)

When you try to load a new class, you start with the bottom class loader, and work your way up
until the class is found.  In the scenario here, the Digester module (the piece of Struts that
reads the "struts-config.xml" file, and is also used in the example app to read the
pseudo-database file) would be in the system class loader (because you installed struts.jar
there).  However, the application level classes (such as LogonForm) are found only in the webapp
class loader because those files are under WEB-INF/classes or WEB-INF/lib.

A particular class (the Digester) starts from where it was loaded from in looking for new classes
to load.  The fundamental class loader rule:  you can go *up* the hierarchy, but you cannot go
*down*.  Therefore, the Digester cannot see LogonForm, and throws ClassNotFoundException.

The moral of the story is that Struts requires you to install struts.jar in each web application
individually for it to work correctly.

Craig McClanahan