You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Robert J. Carr" <rj...@gmail.com> on 2007/06/30 07:22:29 UTC

CGIServlet

I'd like to use some basic CGI in my webapp but I don't want to rely
on server admins to set it up per the directions of the how to (found
at http://tomcat.apache.org/tomcat-5.5-doc/cgi-howto.html).  When I
follow those directions, everything works fine, however I'd like to
put the CGIServlet definition into my own webapp.

To do this, I simply put the servlet definitions into my own web.xml,
and then put the servlets-cgi.jar into my own lib.  When doing this, I
get a ClassNotFound exception on CGIServlet.

At first I was pretty stumped by this, because I was sure the classes
were there to be found, but after digging a bit deeper, I think it was
just a bad exception.  I'm guessing the reason I'm getting the error
is because CGIServlet.jar imports two other classes:

import org.apache.catalina.Globals;
import org.apache.catalina.util.IOTools;

Those classes are located in catalina.jar and catalina-optional.jar,
respectively, which are both in servert/lib, which aren't visible to
webapps.

I can try putting those two jars into my webapp, but it is likely to
cascade and those jars need jars, etc.  So, my question is, what would
be the best approach for getting the CGISerlet into my own webapp
without having to set it up at a global level?  Or maybe I'm wrong in
my ClassNotFound diagnosis?  Thanks!

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: CGIServlet

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
> Subject: RE: CGIServlet
> 
> > So, in summary, you're saying the only way I can get CGIServlet
> > defined in a single webapp is to leave servlets-cgi.jar in 
> > /server/lib and require an administrator to rename it?
> 
> Put it in the deployment script for your webapp - with appropriate
> documentation about what it's doing.

You could also use Tomcat 6 - no renaming is required, since the CGI and
SSI servlets are now in catalina.jar (the comments in the version 6
conf/web.xml are out of date).

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: CGIServlet

Posted by "Robert J. Carr" <rj...@gmail.com>.
> Both.  You've made the incorrect assumption that "made visible" means
> "made visible to web applications", which is incorrect.  A classloader
> makes classes and resources visible to whoever has access to the
> classloader; webapps do not have access to the Catalina classloader.

...

> Tomcat is the one that processes the servlet mappings, so the CGIServlet
> needs to be visible only to Tomcat, not the rest of the webapp.

GREAT explanation ... I hadn't looked at it this way.  Thank you very
much!  Knowing is half the battle. :)

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: CGIServlet

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Robert J. Carr [mailto:rjcarr@gmail.com] 
> Subject: Re: CGIServlet
> 
> http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html
> 
> So I'm not following, are the resources "TOTALLY invisible to web
> applications"  or are they "made visible through this class loader"?

Both.  You've made the incorrect assumption that "made visible" means
"made visible to web applications", which is incorrect.  A classloader
makes classes and resources visible to whoever has access to the
classloader; webapps do not have access to the Catalina classloader.

> If they are "TOTALLY invisible" then your suggestion wouldn't work, as
> the CGIServlet is in /server/lib.

Tomcat is the one that processes the servlet mappings, so the CGIServlet
needs to be visible only to Tomcat, not the rest of the webapp. 

> So, in summary, you're saying the only way I can get CGIServlet
> defined in a single webapp is to leave servlets-cgi.jar in /server/lib
> and require an administrator to rename it?

Put it in the deployment script for your webapp - with appropriate
documentation about what it's doing.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: CGIServlet

Posted by "Robert J. Carr" <rj...@gmail.com>.
Thanks for the quick reply, I don't believe I've tried that, but it
isn't the complete solution I was looking for.  Remember, tomcat (5.5)
is shipped with the CGIServlet jar in a package named
/server/lib/servlets-cgi.renametojar.  Using your solution would
remove the servlet setup from the global web.xml, but still require an
admin to rename the jar.  Sure, not a big deal, but an installation
requirement I'd like to avoid.

So I guess the question comes down to classloading, and I'm getting
confused there.  On, this page:

http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html

It says:

"Catalina - This class loader is initialized to include all classes
and resources required to implement Tomcat 5 itself. These classes and
resources are TOTALLY invisible to web applications. All unpacked
classes and resources in $CATALINA_HOME/server/classes, as well as
classes and resources in JAR files under $CATALINA_HOME/server/lib,
are made visible through this class loader."

So I'm not following, are the resources "TOTALLY invisible to web
applications"  or are they "made visible through this class loader"?
The two parts seem contradictory to me.  Is is saying the actual
*files* are inivisble, but the classes (in either classes or lib) are
made visible by the classloader?  Again, not sure.

If they are "TOTALLY invisible" then your suggestion wouldn't work, as
the CGIServlet is in /server/lib.  However, the WebdavServlet runs in
a stand-alone webapp and it is also located in /server/lib.

So, in summary, you're saying the only way I can get CGIServlet
defined in a single webapp is to leave servlets-cgi.jar in /server/lib
and require an administrator to rename it?



On 6/30/07, Mark Thomas <ma...@apache.org> wrote:
> Robert J. Carr wrote:
> > To do this, I simply put the servlet definitions into my own web.xml,
> > and then put the servlets-cgi.jar into my own lib.  When doing this, I
> > get a ClassNotFound exception on CGIServlet.
>
> Try just putting the definition in your web.xml and leave the jar where
> it is.
>
> Mark
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: CGIServlet

Posted by Mark Thomas <ma...@apache.org>.
Robert J. Carr wrote:
> To do this, I simply put the servlet definitions into my own web.xml,
> and then put the servlets-cgi.jar into my own lib.  When doing this, I
> get a ClassNotFound exception on CGIServlet.

Try just putting the definition in your web.xml and leave the jar where
it is.

Mark


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org