3

I have an app that's entirely configured by annotation - no web.xml - that I want to run in embedded Tomcat from Eclipse.

I can find lots of examples that rely on specifying a WEB-INF/classes dir, but I would rather run it entirely from the Eclipse classpath.

Here is my launcher:

public static void main(String[] args) throws Exception {
    Tomcat tomcat = new Tomcat();
    tomcat.setPort(8080);

    tomcat.setBaseDir("<work dir>");
    Context ctx = tomcat.addWebapp("/myapp", "<app base>");
    StandardJarScanner scan = (StandardJarScanner) ctx.getJarScanner();
    scan.setScanClassPath(true);
    scan.setScanBootstrapClassPath(false); // just guessing here

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

}

The app starts up - I can get the static content, but the annotation-configured elements are not picked up.

I'm using the tomcat-7-embed distribution.

Is this possible to do?

Dmitri
  • 8,999
  • 5
  • 36
  • 43
  • 1
    See this answer: http://stackoverflow.com/questions/11669507 – auntyellow Nov 26 '14 at 06:21
  • Possible duplicate of [Embedded tomcat 7 servlet 3.0 annotations not working](https://stackoverflow.com/questions/11669507/embedded-tomcat-7-servlet-3-0-annotations-not-working) – Vadzim Jun 19 '18 at 20:01

0 Answers0