Note that there are some explanatory texts on larger screens.

plurals
  1. POJetty isn't picking up my spring application
    primarykey
    data
    text
    <p>I have a Spring MVC application where I use hibernate, freemarker. It is setup as a multi-maven project. I am using IntelliJ ultimate.</p> <p>Jetty starts fine, but when I go to</p> <pre><code>http://localhost:8080/ </code></pre> <p>It simply outputs the folders of my project, and I can view my source code in the browser!</p> <p>Here is my setup currently:</p> <pre><code> final Server server = new Server(8080); ProtectionDomain domain = HttpServer.class.getProtectionDomain(); URL location = domain.getCodeSource().getLocation(); WebAppContext webAppContext = new WebAppContext(); webAppContext.setResourceBase(location.toExternalForm()); webAppContext.setDescriptor(location.toExternalForm() + "/WEB-INF/web.xml"); webAppContext.setContextPath("/"); webAppContext.setParentLoaderPriority(true); server.setHandler(webAppContext); server.start(); server.join(); </code></pre> <p>My project layout is a multi-maven project (using intelli J), the layout is like:</p> <pre><code>/myapp/src/main/java/main.java (this contains the above code to start jetty) /myapp/src/main/webapp /myapp/src/main/webapp/assets /myapp/src/main/webapp/WEB-INF /myapp/src/main/webapp/WEB-INF/web-context.xml (spring config file) /myapp/src/main/webapp/WEB-INF/web.xml /myapp/src/main/webapp/WEB-INF/views/ (parent folder for my freemarker template files) /myapp/src/main/webapp/WEB-INF/views/home/index.ftl </code></pre> <p>My web.xml is:</p> <pre><code>&lt;context-param&gt; &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt; &lt;param-value&gt;classpath*:log4j.properties&lt;/param-value&gt; &lt;/context-param&gt; &lt;servlet&gt; &lt;servlet-name&gt;myapp&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;WEB-INF/web-context.xml&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;myapp&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre> <p>When I run this in IntelliJ (11 ulimitate), I get the following output:</p> <pre><code>2012-08-15 19:17:11,611 [main] INFO org.eclipse.jetty.server.Server - jetty-7.6.2.v20120308 2012-08-15 19:17:11,886 [main] INFO org.eclipse.jetty.webapp.StandardDescriptorProcessor - NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet 2012-08-15 19:17:11,962 [main] INFO org.eclipse.jetty.server.handler.ContextHandler - started o.e.j.w.WebAppContext{/,file:/Users/me/projects/myapp/myapp-web/target/classes/} 2012-08-15 19:17:12,021 [main] INFO org.eclipse.jetty.server.AbstractConnector - Started SelectChannelConnector@0.0.0.0:8080 </code></pre> <p>This obviously isn't working because when I run it using tomcat w/intelliJ I get a huge output for things like hibernate, spring, etc.</p> <p>My pom.xml for the web module has:</p> <pre><code>.. &lt;packaging&gt;war&lt;/packaging&gt; .. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload