Well, the "embedded" option in the startup isn't really intended for
production use anyway, since it only fires off the demonstration main()
method that runs for a couple of minutes and shuts off.
I've seen two basic approaches people take to embedding Tomcat:
* If they like configuration from conf/server.xml, they will
build wrappers around calling the main() method of the Bootstrap
class, which will do all the usual initialization, but without
requiring you to run the startup shell script.
* If they like configuration based on some other representation
of the Tomcat components to create, they will use the Embedded
class. For example, the J2EE Reference Implementation (version 1.3)
does this, because it has its own internal description of what
virtual hosts and web apps need to be created.
Craig
On Thu, 30 Aug 2001, Nick Betteridge wrote:
> Date: Thu, 30 Aug 2001 16:51:37 +0100
> From: Nick Betteridge <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Re: Catalina 4.0-b7 - StandardWrapper.load() - bug?
>
> I suspect that I may be opening a can of worms on this one as I see that
> the 'embedded' option in the 'catalina.sh' doesn't have a '-security'
> option.
>
> I guess that the only sensible way to proceed is to try and mimic the
> embedded functionality with a mapper type approach as used with the
> standalone implementation.
>
> If nobody hears from me within a week, send in the dogs.
>
> Nick
>
>
>
> Nick Betteridge wrote:
> >
> > Hi Craig
> >
> > Thanks for your reply and apologies for the late reply. The goalposts
> > have changed slightly but the problem appears to be the same.
> >
> > I've set up the MBean server environment to create the two classloaders
> > (a la Bootstrap) and when I fire up the server with a Security Manager,
> > I find that the (catalina) loader can find the javax.servlet.Servlet
> > class but the Container Base cannot.
> >
> > servlet.jar is not in any CLASSPATH (save the classloaders).
> >
> > For the simple example ......
> >
> >
> > System.out.println(CatalinaClassLoaders.getCatalinaClassLoader());
> > System.out.println(CatalinaClassLoaders.getSharedClassLoader());
> >
> > try {
> >
>System.out.println(Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.Servlet"));
> > } catch (Exception ex) {
> > ex.printStackTrace();
> > }
> >
> > Embedded embedded = new Embedded();
> > Engine engine = embedded.createEngine();
> >
> > ......... I get the following output showing the classloaders (including
> > the servlet.jar), the 'javax.servlet.Servlet' interface and then the
> > stacktrace with NoClassDefFoundError: javax/servlet/Servlet Exception
> > ...
> >
> > StandardClassLoader
> > available:
> > delegate: false
> > repositories:
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/server/lib/jakarta-regex
> > p-1.2.jar
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/server/lib/crimson.jar
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/server/lib/catalina.jar
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/server/lib/warp.jar
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/server/lib/jaxp.jar
> > required:
> > ----------> Parent Classloader:
> > StandardClassLoader
> > available:
> > delegate: false
> > repositories:
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/common/lib/servlet.jar
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/common/lib/naming.jar
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/common/lib/resources.jar
> > required:
> > ----------> Parent Classloader:
> > sun.misc.Launcher$AppClassLoader@2c3c08
> >
> > StandardClassLoader
> > available:
> > delegate: false
> > repositories:
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/lib/namingfactory.jar
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/lib/jasper-runtime.jar
> > required:
> > ----------> Parent Classloader:
> > StandardClassLoader
> > available:
> > delegate: false
> > repositories:
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/common/lib/servlet.jar
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/common/lib/naming.jar
> >
> > file:/export/home/servers/web/jakarta-tomcat-4.0-b7/common/lib/resources.jar
> > required:
> > ----------> Parent Classloader:
> > sun.misc.Launcher$AppClassLoader@2c3c08
> >
> > interface javax.servlet.Servlet
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > javax/servlet/Servlet
> > Exception
> > at
> > org.apache.catalina.core.ContainerBase.<init>(ContainerBase.java:254)
> > at
> > org.apache.catalina.core.StandardEngine.<init>(StandardEngine.java:10
> > 4)
> > at
> > org.apache.catalina.startup.Embedded.createEngine(Embedded.java:577)
> > at
> > com.syntactics.server.management.catalina.Bootstrap.<init>(Bootstrap.
> > java:191)
> > at
> > com.syntactics.server.management.catalina.Bootstrap$1.run(Bootstrap.j
> > ava:61)
> > at java.security.AccessController.doPrivileged(Native Method)
> > at
> > com.syntactics.server.management.catalina.Bootstrap.main(Bootstrap.ja
> > va:58)
> >
> > .... this code is running in class driven by a PrivilegedAction.
> >
> > Getting this to work with MBeans and a Security Manager is turning out
> > to be quite tricky!
> >
> > Cheers
> >
> > Nick
> >
> > >On Wed, 22 Aug 2001, Nick Betteridge wrote:
> > >
> > >
> > >> javax.servlet.ServletException: Class
> > >> org.apache.jasper.servlet.JspServlet is not a Servlet
> > >
> > >The only time I've seen this kind of thing happen is when servlet.jar is
> > >loaded from the "wrong" class loader -- it needs to be visible to both
> > >Catalina internal classes *and* web apps. In the usual stand-alone
> > >configuration, this is accomplished by putting servlet.jar into the
> > >$CATALINA_HOME/common/lib directory. Also, make sure servlet.jar is *not*
> > >in your Java system extensions directory ($JAVA_HOME/jre/lib/ext) or on
> > >the CLASSPATH.
> > >
> > >Could you double check to see if any of those issues might be the problem?
> > >
> > >> Nick
> > >
> > >Craig
>