Tomcat 3.3.1a question - servlets not under WEB-INF\classes\

M

M

Sorry if this question has been asked before but I've searched google
groups, and the tomcat user's guide to no avail.

I've been asked to update our existing Apache / ApacheJServ system to
Tomcat with Apache. At the moment I'm looking into Tomcat 3.3.1a but
might consider the newer versions. Currently I'm running tomcat as a
stand alone to test my servlets.

I've installed tomcat under d:\apps\tomcat\ but my TOMCAT_HOME is
under d:\tomcat\

The first line of my server.xml (d:\tomcat\conf\server.xml):
<ContextManager workDir="d:\tomcat\work" home="d:\tomcat">

My web app is under d:\test\ but all my servlets are NOT under
d:\test\WEB-INF\classes\ but rather somewhere else on the filesystem

My web.xml for this app looks like:

<web-app>
<servlet>
<servlet-name>
Test
</servlet-name>
<servlet-class>
dx.servlet.profile.TestServlet
</servlet-class>
</servlet>
</web-app>

The servlet dx.servlet.profile.TestServlet lies under
d:\sites\server\classes\dx\servlet\profile\

I know older versions of tomcat would use the system classpath on
start up, and I guess that's the problem as to why tomcat can't find
my servlets. Is there a way to have my servlets NOT under
WEB-INF\classes but under some other directory? If so how would I go
about doing this?

thanks
 
A

Alexei Betin

I'd imagine adding d:\sites\server\classes to -classpath
in Tomcat startup command in catalina.bat will do it,

or copy your classes into a directory which Tomcat adds to CP
automatically - such as shared\classes in Tomcat 4.

The difference from putting to WEB-INF\classes is that
they will get loaded by a different ClassLoader - and
be shared by all Web Applications rather than one.

Which may or may not be what you want.

Good luck,
~Alexei
 
M

M

Hi Alexei,

Thanks for the reply.
I'm actually using tomcat 3.3.1a but I did modify tomcat.bat to add
d:\sites\server\classes to -classpath. This seems to do the trick,
there only seems to be one problem:

At the BOTTOM of tomcat.bat is a line like:

set CLASSPATH=%_CLASSPATH%

I simply added my additional classpath like:

set CLASSPATH=d:\sites\server\classes;%_CLASSPATH%

an "echo %CLASSPATH%" right after, however produces:

d:\sites\server\classes;d:\sites\server\classes;d:\sites\server\classes;d:\sites\server\classes;d:\sites\server\classes;;d:\sites\server\classes;d:\sites\server\classes;d:\sites\server\classes;d:\sites\server\classes;d:\sites\server\classes;d:\sites\server\classes;;d:\sites\server\classes;

in the dos window that runs tomcat.bat. This seems strange and I'm not
sure why. Any ideas?

The reason I don't want to put my classes under WEB-INF\classes is b/c
the package hierarchy is made up of two main components. The servlets
and a stand alone java server that has nothing do with the servlets.
My package structure looks something like:

-db
-log
-mainserver
-monitor
-servlets
-profile
-forms
-util
-xml

the servlets package uses classes from the other packages, but the
mainserver package does not use the servlets package. Therefore it
seems incorrect to me to place all the packages under WEB-INF, and I
definitely don't want to restructure the packages to separate the
servlets package from the rest of them as this would only cause
headaches.

thanks
 
A

Alexei Betin

M said:
Hi Alexei,

Thanks for the reply.
I'm actually using tomcat 3.3.1a but I did modify tomcat.bat to add
d:\sites\server\classes to -classpath. This seems to do the trick,
there only seems to be one problem:

At the BOTTOM of tomcat.bat is a line like:

set CLASSPATH=%_CLASSPATH%

I simply added my additional classpath like:

set CLASSPATH=d:\sites\server\classes;%_CLASSPATH%

an "echo %CLASSPATH%" right after, however produces:

d:\sites\server\classes;d:\sites\server\classes;d:\sites\server\classes;d:\s
ites\server\classes;d:\sites\server\classes;;d:\sites\server\classes;d:\site
s\server\classes;d:\sites\server\classes;d:\sites\server\classes;d:\sites\se
rver\classes;d:\sites\server\classes;;d:\sites\server\classes;

in the dos window that runs tomcat.bat. This seems strange and I'm not
sure why. Any ideas?

weird, but you need to look at (debug) the all the scripts that are
involved,
they are tricky, maybe there's some unwanted recursion in how the
final classpath gets built - cannot tell you
The reason I don't want to put my classes under WEB-INF\classes is b/c
the package hierarchy is made up of two main components. The servlets
and a stand alone java server that has nothing do with the servlets.
My package structure looks something like:

-db
-log
-mainserver
-monitor
-servlets
-profile
-forms
-util
-xml

the servlets package uses classes from the other packages, but the
mainserver package does not use the servlets package. Therefore it
seems incorrect to me to place all the packages under WEB-INF, and I
definitely don't want to restructure the packages to separate the
servlets package from the rest of them as this would only cause
headaches.

well, if all your classes are used in the same WebApp I'd still keep
them under this Apps' WEB-INF, having said that, it does not have
to be WEB-INF\classes, I instead prefer
WEB-INF\lib\myservlets.jar
WEB-INF\lib\mycorelibs.jar
with a clear dependency separation, and all that sits inside the WAR
file which is a single deployment unit.

Tomcat will be able to unpack it for you automatically with no need
for hacking with CLASSPATH.

Thanks,
~Alexei
 
L

Lordy

I've been asked to update our existing Apache / ApacheJServ system to
Tomcat with Apache. At the moment I'm looking into Tomcat 3.3.1a but might
consider the newer versions.

Why not consider Tomcat 4.x from the start ?

Lordy
 
C

Christophe Vanfleteren

Lordy said:
Why not consider Tomcat 4.x from the start ?

Exaclty. wasn't it also so that Tomcat 4 is a (complete) rewrite, and that
it performs much better than the 3.x series?

I'd even suggest using Tomcat 5, JSP 2 syntax is much better on the eyes :)
But that would of course depend on the timescale / requirements of the
project in question: Tomcat 5 is still in beta.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top