On 13/01/2017 11:14, Tom Eugelink wrote:
> I'm trying to migrate a very old ANT based project into the future, the
> ANT scripts I inherited are (of course) very complex, so I need to make
> babysteps. The first thing I did was compile the Java code with Maven and
> thus replaced a lot of copy statements and checked in lib directories with
> dependencies. This is working fine, but it also means that there is no
> single directory anymore where all the classfiles, jars, configuration
> files, etc are copied to. So now I need a way to start Tomcat for
> developers using (still) separated directories.
> The best approach seemed like to start Tomcat embedded, this also allows
> me to use it for running cucumber and integration tests against. The thing
> is I cannot get it to work, even after searching google, stackoverflow and
> reading the Tomcat (8.0.39) configuration guides for 2 days. It should, I
> would not mind if it did, but it does not.
> To begin I have a maven project with:
> - classes in target/classes
> - web files in webapps
> - configuration files in /somewhere/outside/the/project/cfg
> This what I have so far:
> StandardContext standardContext =
> "MijnCaress Backend Container");
> // returns a
> org.apache.catalina.webresources.StandardRoot standardRoot = new
> // add classes
> "/WEB-INF/classes", new File("target/classes").getAbsolutePath(),
> // add configuration files
> "/WEB-INF/classes", new
> This ends with a ClassNotFoundException on a class that is in
> target/classes, also if I remove the configuration files resource.
> The target/classes absolute path is correct, exists and contains the class.
> It would be great to get some pointers on why this is not working.
Class loader resources have special handling. I think you'll be able to
get this to work with:
new File("target/classes").getAbsolutePath(), null, "/");
If that doesn't work, I'd recommend using a debugger to figure out what
is going on. It wouldn't surprise me to find we need to extend the API
as more use cases emerge.
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org