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

Discussion in 'Java' started by M, Sep 12, 2003.

  1. M

    M Guest

    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
    M, Sep 12, 2003
    #1
    1. Advertising

  2. M

    Alexei Betin Guest

    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" <> wrote in message
    news:...
    > 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
    Alexei Betin, Sep 12, 2003
    #2
    1. Advertising

  3. M

    M Guest

    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




    "Alexei Betin" <> wrote in message news:<bjtg6l$n3qap$-berlin.de>...
    > 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" <> wrote in message
    > news:...
    > > 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
    M, Sep 15, 2003
    #3
  4. M

    Alexei Betin Guest

    "M" <> wrote in message
    news:...
    > 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


    > thanks
    >
    >
    >
    >
    > "Alexei Betin" <> wrote in message

    news:<bjtg6l$n3qap$-berlin.de>...
    > > 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" <> wrote in message
    > > news:...
    > > > 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
    Alexei Betin, Sep 19, 2003
    #4
  5. M

    Lordy Guest

    On Fri, 12 Sep 2003 08:33:07 -0700, M wrote:

    > 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
    Lordy, Sep 20, 2003
    #5
  6. Lordy wrote:

    > On Fri, 12 Sep 2003 08:33:07 -0700, M wrote:
    >
    >> 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 ?


    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.

    --
    mvg,
    Christophe Vanfleteren
    Christophe Vanfleteren, Sep 20, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim
    Replies:
    2
    Views:
    869
  2. pradeep gummi
    Replies:
    1
    Views:
    932
    dhek bhun kho
    Sep 5, 2003
  3. Matthew Macchia
    Replies:
    3
    Views:
    1,062
    Roedy Green
    Apr 13, 2004
  4. Hans
    Replies:
    3
    Views:
    2,481
    Ryan Stewart
    May 16, 2004
  5. Chris Widmer
    Replies:
    1
    Views:
    414
    Wendy Smoak
    Apr 18, 2005
Loading...

Share This Page