tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Gordon <adam.n.gor...@gmail.com>
Subject Classpath issues with Embedded Tomcat 7
Date Thu, 19 Apr 2012 17:46:29 GMT
UPDATE:

By adding all my jars in WEB-INF/lib to my launch command classpath, I can
get the embedded server to run, but this does not seem correct as then what
would be the point of WEB-INF/lib?

-----------------------------------

I've been unable to find any decent documentation on how to use Embedded
Tomcat so I've been winging it.  The issue I'm having is that from what
I've gleaned from the web all I *should* need in my classpath for my main
method is my main class, tomcat-embed-core.jar,
tomcat-embed-logging.juli.jar, tomcat-embed-jasper.jar, and ecj.jar but I'm
finding that when trying to launch my main from the command line I keep
having to append more and more jars from WEB-INF/lib to my classpath to get
it to continue to try and start up because it keeps spitting out
NoClassDefFoundErrors.  I was under the impression that it would use
WEB-INF/lib for the web app's  classpath but this is not what's happening.
 The syntax used below was used from
http://people.apache.org/~markt/presentations/2010-11-04-Embedding-Tomcat.pdf,
see the section for running a web application.

Here's my main:

public static void main(String[] args)
   throws LifecycleException, InterruptedException, ServletException {

   Tomcat tomcat = new Tomcat();
   tomcat.setPort(9090);

   File docBase = new File("/usr/local/foo/foo-ui");
   tomcat.addWebapp(null, "", docBase.getAbsolutePath());

   tomcat.start();
   tomcat.getServer().await();
 }

and here's my launch command:

user@host: /usr/local/foo/foo-ui
$ java -cp
WEB-INF/classes:WEB-INF/lib/tomcat-embed-core-7.0.27.jar:WEB-INF/lib/tomcat-juli-7.0.27.jar:WEB-INF/lib/tomcat-embed-jasper-7.0.27.jar:WEB-INF/lib/ecj-3.7.1.jar
com.foo.WebAppMain

Anyone have any ideas what I'm doing wrong?  Thanks.

--adam

http://gordonizer.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message