Matt,
Congratulations on getting it to work. AFAIK, hardly
any of the modules/interceptors are written to be extensible
at the moment. The public methods are for configuration
and interaction within the server architecture. The
implementation, I think, is typlically private. Using the
existing code as a starting point for a customized version
will be the norm for most modules.
Making WebXmlReader more customizable could be done, but
there probably isn't time to include it in the 3.3
release.
Cheers,
Larry
> -----Original Message-----
> From: Matt Small [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 12, 2001 2:06 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: Two contexts sharing one WebApp
>
>
> Ok, I got it working but in doing so I found a couple of
> weaknesses in the
> WebXmlReader class (it is difficult to extend), I think. I
> think that there
> might be room here for improvements in tomcat, flexibility
> could be added
> without breaking the requirements of the spec. I realize that
> there are
> proper ways to get the behaviour I want but supporting
> multiple contexts
> from one web-app is pretty convenient in this case.
>
> What I wanted to do was add an attribute to my context
> specifying the name
> of the the web-app descriptor. If the attribute is not
> specified then tomcat
> would implicitly load web.xml.
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <webapps>
> <Context path="/pub"
> docBase="webapps/myapp"
> descriptor="pub.xml"
> crossContext="false"
> debug="0"
> reloadable="true">
> </Context>
> </webapps>
>
> I then wanted to sub-class WebXmlReader and provide my own
> implementation of
> contextInit(Context ctx) that would get the descriptor file
> from the Context
> and read that file.
>
> This seems like it would be a pretty clean implementation to
> me but I could
> not do it for a couple reasons:
>
> 1) I did not have the time to properly reasearch how
> "descriptor" attrib
> would be parsed and stored in Context.java. I'm sure though
> that you guys
> who know how it all works could implement that in a snap.
>
> 2) I had trouble sub-classing WebXmlReader. The method
> "processWebXmlFile()"
> is package private and must be called. If it were protected I
> dont thing I
> would have had any trouble. If anything please open up the
> access on this
> method.
>
> I eventually hacked up an implementation that works for me
> but is definately
> not good. I actually just modified WebXmlReader so that it
> gets the Path
> from the Context, builds the xml file name from the path (in
> my case it
> assumes pub.xml because the path is /pub) and if that file
> exists it reads
> that one, if not it reads web.xml. I then just found it
> easiest to rebuilt
> the whole facade22.jar and updated it in lib/container.
>
> Is this the sort of change you guys would be willing to make
> in Tomcat? Or
> would something like this not fly because its not in the spec?
>
> Thanks for all of your advice on this one Larry
>
> Matt
>
> -----Original Message-----
> From: Larry Isaacs [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 11, 2001 5:19 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: Two contexts sharing one WebApp
>
>
> Hi Matt,
>
> Congratulations on getting this far. Off the top of my head, I'm
> not sure if "tomcat/classes" is supported. I'll try to review
> what methods are available to add classes rather than jars to
> Tomcat 3.3's classloader hierarchy. I suspect there is room for
> improvement here.
>
> In the meantime, the simplest way to add your class to Tomcat 3.3
> is to put it in a jar and put that jar in the "tomcat/lib/container"
> directory. This will get your class into the correct classloader.
>
> Cheers,
> Larry
>
>
> > -----Original Message-----
> > From: Matt Small [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, September 10, 2001 6:11 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: Two contexts sharing one WebApp
> >
> >
> > Ok, so I extended WebXmlReader and added the functionality
> I need and
> > compiled it. I added the class to /tomcat/classes/. I updated
> > my modules.xml
> > and server.xml to use my new CustWebXmlReader. I think
> > everything is set up
> > right.
> >
> > When I start Tomcat I get A class not found Exception though:
> >
> > E:\scripts>ERROR reading
> > E:\jakarta-tomcat-3.3-b2\conf\server.xml
> > At Line 28 /Server/ContextManager/CustWebXmlReader/
> > validate=true
> >
> > java.lang.ClassNotFoundException:
> > org.apache.tomcat.facade.CustWebXmlReader
> > at
> > java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> > at java.security.AccessController.doPrivileged(Native
> > Method)
> > at
> > java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> >
> > According to the user docs, if you make a classes dir: "Any
> > class that you
> > add to this directory will find its place in Tomcat's
> > classpath." Am I doing
> > something wrong here. I would prefer not to have to re-jar
> > all of the tomcat
> > classes.
> >
> > Thanks
> >
> > Matt
> >
> > -----Original Message-----
> > From: Larry Isaacs [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, September 10, 2001 11:26 AM
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: Two contexts sharing one WebApp
> >
> >
> > Hi Matt,
> >
> > Use of web.xml is mandated by the Servlet 2.2 spec, so there
> > isn't supposed to be a way to do what you want. However,you are
> > welcome to try customizing org.apache.tomcat.facade.WebXmlReader
> > to make a choice somehow.
> >
> > Cheers,
> > Larry
> >
> >
> > > -----Original Message-----
> > > From: Matt Small [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, September 10, 2001 2:11 PM
> > > To: Tomcat (E-mail)
> > > Subject: Two contexts sharing one WebApp
> > >
> > >
> > >
> > > I have my tomcat server set up with two contexts that share
> > > the same web-app
> > > directory. I want to specify a different web.xml in each
> > > context though so
> > > that different servlets are available from each context. Is
> > > there any way to
> > > specify the web.xml file name or path from the context
> > > definition? I am
> > > hoping that there is just a simple config line for this. I
> > > know I get the
> > > behavior I want by building my code into two different
> > > web-apps, but I want
> > > to keep my build file simple. I am using Tomcat 3.3 beta 2.
> > >
> > > Thanks,
> > > Matt
> > >
> >
>