File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes help: where must I store my custom Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "help: where must I store my custom "WebAppClassLoader"" Watch "help: where must I store my custom "WebAppClassLoader"" New topic
Author

help: where must I store my custom "WebAppClassLoader"

ogattaz
Greenhorn

Joined: Jul 22, 2002
Posts: 1
Bonjour,

Is my problem very complex ?
I had no response in the mailing list "tomcat-user".
To store a group of special classes shared by multiple webapps, out of the
standard class directoy of the WebApps ("WEF-INF/classes"), I try to
write a custom WebAppClassLoader, but tomcat cant load it at startup !
note: these classes are dynamicly generated with the design tool of an "ERP".
My classLoader are stored in a jar file in the lib directory of my WebApp :
�CATALINA_HOME\SERVERS_BASE\webapps_x3\WAWEBSERVER\WEB-INF\lib\WAWEBSERVER.jar
But Catalina delivers me an error at each startup :
java.lang.ClassNotFoundException
At this time the context does'nt exist ?
Although I read information "Normally, application classes should NOT be
placed here" in the "how-to" of the tomcat's classloader, I tried to place
my classes in a jar file located in the directory "$CATALINA_HOME/common/lib"
so that they are visible for catalina,
but that does not run either!
Where must I store my custom WebAppClassLoader classes ?
See behind the details of what I did and how is configured my platform.
Thanks a lot in advance.
Best regards
Olivier Gattaz
Adonix - 5 avenue Victor Hugo - 38130 Echirolles - France

1) I created the two classes :
------------------------------
- "com.adonix.x3.x3web.tomcat.loader.CAdapiLoader"
public class CAdapiLoader extends WebappLoader
{
...
}
- "com.adonix.x3.x3web.tomcat.loader.CAdapiClassLoader"
public class CAdapiClassLoader extends WebappClassLoader
{
...
}

## 2) I store these classes in a Jar file :
-------------------------------------------
�CATALINA_HOME\SERVERS_BASE\webapps_x3\WAWEBSERVER\WEB-INF\lib\WAWEBSERVER.jar

## 3) I defined a "Loader" tag in the "context" of my WebApp :
--------------------------------------------------------------
<Context path="/x3webgarp"
docBase="C:\Program files\Adonix\X3Web\SERVERS_BASE\webapps_x3\WAWEBSERVER"
debug="0"
reloadable="false">
<Loader className="com.adonix.x3.x3web.tomcat.loader.CX3WebLoader"
delegate="false"
reloadable="false"
checkInterval="15"
debug="9"
loaderClass="com.adonix.x3.x3web.tomcat.loader.CX3WebClassLoader"
AdapiClassPath="D:\Adonix\X3Web\Data\X3Classes" />
</Context>

## 4) When Tomcat start, I always get the error message in the output :
-----------------------------------------------------------------------
ERROR reading C:\Program files\Adonix\X3Web\SERVERS_BASE\conf\server.xml
At Line 217 /Server/Service/Engine/Host/Context/Loader/
className=com.adonix.x3.x3web.tomcat.loader.CX3WebLoader delegate=false
reloadable=false checkInterval=15 debug=9
loaderClass=com.adonix.x3.x3web.tomcat.loader.CX3WebClassLoader
Catalina.start:
java.lang.ClassNotFoundException:com.adonix.x3.x3web.tomcat.loader.CX3WebLoader

## 5) The configuration of my plaform :
---------------------------------------
- W2000 SP2
- Apache httpd 2.0.39 + Mod_jk
- Sun JDK 1.3.1_03
- Tomcat 4.0.4 running like a service and configured for
multiple instances by setting $CATALINA_BASE
- set CATALINA_LOG=D:\Adonix\X3Web\data\SERVERSLOGS\TOMCAT
- set CATALINA_HOME=C:\Program Files\Apache Tomcat 4.0
- set CATALINA_BASE=C:\Program files\Adonix\X3Web\SERVERS_BASE
- set JAVA_HOME=C:\jdk1.3.1_03

NOTE: although I set $CATALINA_BASE different of $CATALINA_HOME, the
directory $CATALINA_BASE/common/lib is ignored !
Chris Reeves
Ranch Hand

Joined: Apr 03, 2002
Posts: 95
If you want to share classes across webapps, you don't have to write your own classloader.
All you have to do is drop them in tomcat/common/classes or tomcat/common/lib.
Enjoy!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help: where must I store my custom "WebAppClassLoader"