On 02/03/2016 22:12, Philippe Busque wrote: <snip/>
> In short, Tomcat is deployed with a bare minimum war containing the jar > dependencies for the JSP and the web.xml. All the other content, we > used a CMS do deploy inside the unpacked war webapps folder of a > particular site. > > The drawback of that approach was that, if I needed to redeploy a new > war, I had to unpack it manually (as an automatic unpack would delete > the files deployed through the CMS along with the file from the > previously unpacked WAR). > > With Tomcat 8, I was hoping to use the new PreResources and > PostResource to move the static content away from the webapps, into it's > own droppath. > > On my first attempt, I had this setup for my context > ---------- > <Host name="www.example1.com<http://www.example1.com>" > appBase="webapps/example1" unpackWARs="true" autoDeploy="false"> > <Context path="" reloadable="false" workDir="work/example1"> > <JarScanner scanBootstrapClassPath="false"/> > <Resources> > <PreResources > className="org.apache.catalina.webresources.DirResourceSet" > readOnly="true" webAppMount="/" base="/home/tomcat/CMS/example1.com" /> > </Resources> > </Context> > </Host> > ------------------- > > This worked fine to access static resources (images, css, js) deployed > into "/home/tomcat/CMS/example1.com" . > However, for some reason, any JSP file deployed inside that folder would > crash, unable to access the dependencies Jar unpacked inside the > appBase. I thought, from reading the documentation, that the classpath > from WEB-INF/lib and WEB-INF/class was always available. But from the > NoClassDefFound errors, I got, it doesn't seem to be the case. <snip/> > So I tried adding the folder of my appBase manually as a PostResources. > > ------------------- > <Host name="www.example1.com<http://www.example1.com>" > appBase="webapps/example1" unpackWARs="true" autoDeploy="false"> > <Context path="" reloadable="false" workDir="work/example1"> > <JarScanner scanBootstrapClassPath="false"/> > <Resources> > <PreResources > className="org.apache.catalina.webresources.DirResourceSet" > readOnly="true" webAppMount="/" base="/home/tomcat/CMS/example1.com" /> > <PostResources > className="org.apache.catalina.webresources.DirResourceSet" > readOnly="true" webAppMount="/" base="${catalina.base}/webapps/example1" /> > </Resources> > </Context> > </Host> > ------------------- > > > With this setup, the JSP deployed inside /home/tomcat/CMS/example1.com > are able to access the web.xml and library from the appBase, I would no > longer receive the error and the pages would display. > > However, Tomcat is validating the Resources *BEFORE* unpacking the War > file into the appBase. As a result, if I start Tomcat from an undeployed > state (example1.war exists under ${catalina.base}/webapps/), tomcat > crash saying that the folder "${catalina.base}/webapps/example1" does > not exist. If I create the folder and deploy the war manually, tomcat > work. But that leave me to the same point as I was with Tomcat 7: I > need to manually unpack my war. <snip/> > At this point, I'm not sure where to look. I don't know why my > PreResources JSP are not seeing the lib from my appBase, nor how to > configure Tomcat to set them without a manual intervention,. > > > Tomcat Version 8.0.32 > OS: Red Had 6.5 > Java 1.8.0_65 > > Thanks That was pretty much a perfect question. A clear problem statement. A clear description of what you expected to happen vs. what actually happened. A clear description of what you tried. If only all posts to the users list were like this. This is an easy fix. The problem is that with no docBase defined and a path of "", tomcat is going to use a docBase of "ROOT". That means Tomcat is going to look for these files in "work/example1/ROOT" not in "work/example1". Generally, I'd recommend a slightly different directory structure. Something like: webapps-example1/ROOT.war which auto expands into webapps-example1/ROOT Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org