Skip to content

Instantly share code, notes, and snippets.

@marko-asplund
Created July 19, 2013 07:57
Show Gist options
  • Save marko-asplund/6037479 to your computer and use it in GitHub Desktop.
Save marko-asplund/6037479 to your computer and use it in GitHub Desktop.
Using Jersey 2 Spring integration prototype with Jetty 9 embedded (without servlet 3.0 annotation support)
package fi.markoa.proto.jersey2.jetty;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class JettyWebApp {
public static void main(String ... args) throws Exception {
Server server = new Server(8090);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/app1");
webapp.setWar("/foo/bar/jersey/examples/helloworld-spring/target/helloworld-spring.war");
server.setHandler(webapp);
server.start();
server.join();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<module-name>helloworld-spring</module-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>jerseyServlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.glassfish.jersey.server.spring,org.glassfish.jersey.examples.helloworld.spring</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>jerseyServlet</servlet-name>
<url-pattern>/myapp/*</url-pattern>
</servlet-mapping>
</web-app>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment