Class Loader Crazy!!!

2004-11-24 Thread Regis Santos
Hello everbody,

I've read in Tomcat 5 Docs that when a web application needs a class or a 
resource, the Class Loader looks in the following repositories, in this order:

- Bootstrap classes of your JVM 
- System class loader classses (described above) 
- /WEB-INF/classes of your web application 
- /WEB-INF/lib/*.jar of your web application 
- $CATALINA_HOME/common/classes 
- $CATALINA_HOME/common/endorsed/*.jar 
- $CATALINA_HOME/common/lib/*.jar 
- $CATALINA_BASE/shared/classes 
- $CATALINA_BASE/shared/lib/*.jar 

Recently, I copied a web application (called W1) from a Tomcat 4.0.18 to a 
Tomcat 5.0.28 and in the W1/WEB-INF/lib folder had two common JAR files: 
jasper-runtime.jar and jasper-compile.jar, both from Tomcat 4.x version.

Then, I started the server (Tomcat 5) and the application W1. After that, I 
deployed a second web application (called W2) that was devolped using the new 
JSP spec (it means that I've written my JSP's with EL - Expression Language). 
In the W2/WEB-INF/lib folder, there wasn't any jasper-*.jar. My objective was 
to use the jasper-runtime.jar and the jasper-compile.jar from the common/lib 
folder.

When I tried to access the W2 application... CRASH (See the details below)

004-11-23 15:17:40 StandardWrapperValve[action]: Servlet.service() for servlet 
action threw exception
java.lang.AbstractMethodError: 
javax.servlet.jsp.PageContext.getVariableResolver()Ljavax/servlet/jsp/el/VariableResolver;
at 
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:899)
at 
org.apache.jsp.pages.index_jsp._jspx_meth_html_html_0(index_jsp.java:99)
at org.apache.jsp.pages.index_jsp._jspService(index_jsp.java:66)
at 
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
...

After that, I undeployed the W1 application and removed the files (include the 
JARs from the WEB-INF/lib folder and... TADA!!! The W2 application worked.

I know that the JARs was the problem and that they are not compatible with the 
JARs from the Tomcat 5 commom/lib folder. 

My question is: Why didn't Tomcat load the class from jasper-runtime.jar in the 
common/lib folder when I tried to access the W2 app? Should not Tomcat isolate 
the libs from a webapp, making the classes accessible only for that application?

Thanks!
Regis Santos

 


Re: Class Loader Crazy!!!

2004-11-24 Thread Tim Funk
jasper-compile.jar is not meant to be copied.
jasper-runtime.jar is for use when you precompile your jsp's so they may be 
used in any container (including a newer tomcat version)

If you precompile your jsp's against tomcat 4 - they will run fine in tomcat 
5 if you copy jasper-runtime.jar into WEB-INF/lib.

If you try to copy the tomcat 4 libs into WEB-INF/lib for a tomcat5 
installation and try to compile at runtime a JSP  - bad things will happen.

-Tim
Regis Santos wrote:
Hello everbody,
I've read in Tomcat 5 Docs that when a web application needs a class or a 
resource, the Class Loader looks in the following repositories, in this order:
- Bootstrap classes of your JVM 
- System class loader classses (described above) 
- /WEB-INF/classes of your web application 
- /WEB-INF/lib/*.jar of your web application 
- $CATALINA_HOME/common/classes 
- $CATALINA_HOME/common/endorsed/*.jar 
- $CATALINA_HOME/common/lib/*.jar 
- $CATALINA_BASE/shared/classes 
- $CATALINA_BASE/shared/lib/*.jar 

Recently, I copied a web application (called W1) from a Tomcat 4.0.18 to a 
Tomcat 5.0.28 and in the W1/WEB-INF/lib folder had two common JAR files: 
jasper-runtime.jar and jasper-compile.jar, both from Tomcat 4.x version.
Then, I started the server (Tomcat 5) and the application W1. After that, I 
deployed a second web application (called W2) that was devolped using the new 
JSP spec (it means that I've written my JSP's with EL - Expression Language). 
In the W2/WEB-INF/lib folder, there wasn't any jasper-*.jar. My objective was 
to use the jasper-runtime.jar and the jasper-compile.jar from the common/lib 
folder.
When I tried to access the W2 application... CRASH (See the details below)
004-11-23 15:17:40 StandardWrapperValve[action]: Servlet.service() for servlet 
action threw exception
java.lang.AbstractMethodError: 
javax.servlet.jsp.PageContext.getVariableResolver()Ljavax/servlet/jsp/el/VariableResolver;
at 
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:899)
at 
org.apache.jsp.pages.index_jsp._jspx_meth_html_html_0(index_jsp.java:99)
at org.apache.jsp.pages.index_jsp._jspService(index_jsp.java:66)
at 
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
...
After that, I undeployed the W1 application and removed the files (include the 
JARs from the WEB-INF/lib folder and... TADA!!! The W2 application worked.
I know that the JARs was the problem and that they are not compatible with the JARs from the Tomcat 5 commom/lib folder. 

My question is: Why didn't Tomcat load the class from jasper-runtime.jar in the common/lib folder when I tried to access the W2 app? Should not Tomcat isolate the libs from a webapp, making the classes accessible only for that application?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]