java - Embeded Tomcat with webapp directory within the classpath/jar -


Then I have a Java application that is being packaged as a war and then posted on Tomcat, but Now I have this setup, then it runs directly from a jar file using embedded jt:

  class JettyServer ServerTrait {val server = new server () val connector = new ServerConnector (server) Connector.setPort (BigSenseServer .config.options ("httpPort") toInt) server.setConnectors (Array (connector)) Val Reference = New ServletContextHandler () context.setContextPath (BigSenseServer.webRoot) context.addServlet (New MasterServlet (). EtClass, "/ *") Context.addEventListener (New InitLoggingListener ()) context.addEventListener (new DBUpdateListener ()) val fileContents = New WebAppContext () fileContext.setContextPath (BigSenseServer.contentRoot) fileContext.setResourceBase (BigSenseServer.getClass.getResource ( "/ Io / bigsense /web").ExternalForm) Val Handlers = New Handlerclip () Handlers.SetHandal (Server.start server.join} Override def stopServer () {server.stop}}  

( Server). Ex>

Webstrot / bigsense / api and contentRoot is / is static. In this configuration, stable files like CSS and JavaScript are served from / io / bigsense / web package (SRT in SRT / main / stored in resources). In my original, there was reference-root / bigsense and servlet was mapped to api / *, so all static content could be served directly from / bigsense / {js, css, whatever}.

How can I understand JT to do the same thing, but the current setup listed above works fine and I adjust all my templates to get all the templates from the same configured object (Which is a backend in a property file)

I also want to create an embedded Tomcat implementation and I have read many guides, but they all want a real webpage base directory. I can not find any examples that map to a sublet directory without the webport base or take the webpage base from classpath (in a jar) rather than the actual physical directory. I have tried things like the following:

edit The servlet working with the following has got me now I just need ServletContextListneres and a way of server files from jar :

TomcatServer ServerTrait {val tomcat = new tomcat () tomcat.setPort (BigSenseServer.config.options ("httpport") .toInt) Val tmp = new file (System.getProperty (" Java.io.tmpdir ")) Val ctx = tomcat.addContext (BigSenseServer.webRoot, tmp.getAbsolutePath) Tommack.EdServlet (ctx," bigsense ", new MasterServlet ()) ctx.addServletMapping (" / * "," bigsense " ) Override def start startter () = {tomcat.start () to Mcat.getServer (). Await ()} Override def stopServer () = tomcat.stop}

So I have a similar setup for the Jetties for the main servlet. I did not get any work on Context Object to add two ServletContextListner objects. I should be able to serve my static context with jar on contentRoot (/ static).


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -