Created
December 18, 2009 20:22
-
-
Save claymccoy/259737 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OS X 10.6.2, Java 1.6.0_17, tomcat 6.0.18 | |
// Trying to setup embedded tomcat. Initialization goes well according to the log. | |
// The Spring config runs, and everythign starts up. No errors. | |
// But I get 404s when browsing to the site. It's as if it can't find my jsp's. | |
// it is a Maven project with a Maven file structure, <approot> is a placeholder that is not in the actual code | |
webAppPath = new File("<approot>/WEB/src/main/webapp"); // parent location of WEB-INF/web.xml | |
warPath = new File("<approot>/WEB/target"); // parent location of the war | |
port = port; | |
path = "/App"; | |
// using the above values to start the server | |
// create server | |
final Embedded embedded = new Embedded(); | |
embedded.setCatalinaHome(catalinaHome); | |
// create engine | |
final Engine engine = embedded.createEngine(); | |
engine.setName("localEngine"); | |
// create host | |
final Host localHost = embedded.createHost("localHost", warPath.getAbsolutePath()); | |
engine.addChild(localHost); | |
engine.setDefaultHost(localHost.getName()); | |
// create context | |
final Context rootContext = embedded.createContext(path, webAppPath.getAbsolutePath()); | |
rootContext.setParentClassLoader(Thread.currentThread().getContextClassLoader()); | |
localHost.addChild(rootContext); | |
embedded.addEngine(engine); | |
// create http connector | |
final Connector httpConnector = embedded.createConnector((InetAddress) null, port, false); | |
embedded.addConnector(httpConnector); | |
// start server | |
embedded.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment