0

I have a scalatra based app with embedded jetty.

My final output structure is /lib /bin /etc and webapp is located under etc.

When launching the webapp there is the line which sets the resourceBase - what is this supposed to be set to in this case?

val context = new WebAppContext()
context setContextPath "/"
context.setResourceBase(???)
LK__
  • 6,515
  • 5
  • 34
  • 53

1 Answers1

0

When you use a WebAppContext as your chosen ContextHandler in Jetty, you are constrained under all of the requirements for a WebApp.

Namely:

  • ${resourceBase}/WEB-INF/classes/ is the primary source of classes
  • ${resourceBase}/WEB-INF/lib/*.jar is the secondary source of classes and webapp configuration
  • ${resourceBase}/WEB-INF/web.xml is the webapp descriptor (optional in Servlet spec 3.0+)
  • ${resourceBase}/ is the lookup point for various methods in javax.servlet.ServletContext such as:
    • String getRealPath(String path)
    • URL getResource(String path)
    • InputStream getResourceAsStream(String path)
    • Set<String> getResources(String path)
  • Requested resources that don't match any of your servlets or filters, will then be handled by the DefaultServlet, which might serve static resources (such as *.html, *.css, *.js) from the specified ${resourceBase}

This just to name a few of the reasons to properly define your resourceBase.

Good Luck,

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136