Java Code Examples for org.apache.catalina.core.StandardContext#addServletMapping()

The following examples show how to use org.apache.catalina.core.StandardContext#addServletMapping() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestHttpServlet.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Test
public void testBug53454() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    StandardContext ctx = (StandardContext)
        tomcat.addContext("", null);

    // Map the test Servlet
    LargeBodyServlet largeBodyServlet = new LargeBodyServlet();
    Tomcat.addServlet(ctx, "largeBodyServlet", largeBodyServlet);
    ctx.addServletMapping("/", "largeBodyServlet");

    tomcat.start();

    Map<String,List<String>> resHeaders=
            new HashMap<String, List<String>>();
    int rc = headUrl("http://localhost:" + getPort() + "/", new ByteChunk(),
           resHeaders);

    Assert.assertEquals(HttpServletResponse.SC_OK, rc);
    Assert.assertEquals(LargeBodyServlet.RESPONSE_LENGTH,
            resHeaders.get("Content-Length").get(0));
}
 
Example 2
Source File: TestNamingContext.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
private void doTestBug51744(boolean exceptionOnFailedWrite)
        throws Exception {
    Tomcat tomcat = getTomcatInstance();
    tomcat.enableNaming();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);
    
    ctx.setJndiExceptionOnFailedWrite(exceptionOnFailedWrite);

    // Map the test Servlet
    Bug51744Servlet bug51744Servlet = new Bug51744Servlet();
    Tomcat.addServlet(ctx, "bug51744Servlet", bug51744Servlet);
    ctx.addServletMapping("/", "bug51744Servlet");

    tomcat.start();

    ByteChunk bc = new ByteChunk();
    int rc = getUrl("http://localhost:" + getPort() + "/", bc, null);
    assertEquals(200, rc);
    assertTrue(bc.toString().contains(Bug51744Servlet.EXPECTED));
    if (exceptionOnFailedWrite) {
        assertTrue(bc.toString().contains(Bug51744Servlet.ERROR_MESSAGE));
    }
}
 
Example 3
Source File: TestNamingContext.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Test
public void testBeanFactory() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    tomcat.enableNaming();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);
    
    // Create the resource
    ContextResource cr = new ContextResource();
    cr.setName("bug50351");
    cr.setType("org.apache.naming.resources.TesterObject");
    cr.setProperty("factory", "org.apache.naming.factory.BeanFactory");
    cr.setProperty("foo", "value");
    ctx.getNamingResources().addResource(cr);
    
    // Map the test Servlet
    Bug50351Servlet bug50351Servlet = new Bug50351Servlet();
    Tomcat.addServlet(ctx, "bug50351Servlet", bug50351Servlet);
    ctx.addServletMapping("/", "bug50351Servlet");

    tomcat.start();

    ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
    assertEquals("value", bc.toString());
}
 
Example 4
Source File: TestNamingContext.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Test
public void testListBindings() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    tomcat.enableNaming();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);
    
    // Create the resource
    ContextResource cr = new ContextResource();
    cr.setName("list/foo");
    cr.setType("org.apache.naming.resources.TesterObject");
    cr.setProperty("factory", "org.apache.naming.resources.TesterFactory");
    ctx.getNamingResources().addResource(cr);
    
    // Map the test Servlet
    Bug23950Servlet bug23950Servlet = new Bug23950Servlet();
    Tomcat.addServlet(ctx, "bug23950Servlet", bug23950Servlet);
    ctx.addServletMapping("/", "bug23950Servlet");

    tomcat.start();

    ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
    assertEquals("org.apache.naming.resources.TesterObject", bc.toString());
}
 
Example 5
Source File: TestNamingContext.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Test
public void testListBindings() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    tomcat.enableNaming();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);
    
    // Create the resource
    ContextResource cr = new ContextResource();
    cr.setName("list/foo");
    cr.setType("org.apache.naming.resources.TesterObject");
    cr.setProperty("factory", "org.apache.naming.resources.TesterFactory");
    ctx.getNamingResources().addResource(cr);
    
    // Map the test Servlet
    Bug23950Servlet bug23950Servlet = new Bug23950Servlet();
    Tomcat.addServlet(ctx, "bug23950Servlet", bug23950Servlet);
    ctx.addServletMapping("/", "bug23950Servlet");

    tomcat.start();

    ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
    assertEquals("org.apache.naming.resources.TesterObject", bc.toString());
}
 
Example 6
Source File: TestNamingContext.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Test
public void testBeanFactory() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    tomcat.enableNaming();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);
    
    // Create the resource
    ContextResource cr = new ContextResource();
    cr.setName("bug50351");
    cr.setType("org.apache.naming.resources.TesterObject");
    cr.setProperty("factory", "org.apache.naming.factory.BeanFactory");
    cr.setProperty("foo", "value");
    ctx.getNamingResources().addResource(cr);
    
    // Map the test Servlet
    Bug50351Servlet bug50351Servlet = new Bug50351Servlet();
    Tomcat.addServlet(ctx, "bug50351Servlet", bug50351Servlet);
    ctx.addServletMapping("/", "bug50351Servlet");

    tomcat.start();

    ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
    assertEquals("value", bc.toString());
}
 
Example 7
Source File: TestNamingContext.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
private void doTestBug51744(boolean exceptionOnFailedWrite)
        throws Exception {
    Tomcat tomcat = getTomcatInstance();
    tomcat.enableNaming();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);
    
    ctx.setJndiExceptionOnFailedWrite(exceptionOnFailedWrite);

    // Map the test Servlet
    Bug51744Servlet bug51744Servlet = new Bug51744Servlet();
    Tomcat.addServlet(ctx, "bug51744Servlet", bug51744Servlet);
    ctx.addServletMapping("/", "bug51744Servlet");

    tomcat.start();

    ByteChunk bc = new ByteChunk();
    int rc = getUrl("http://localhost:" + getPort() + "/", bc, null);
    assertEquals(200, rc);
    assertTrue(bc.toString().contains(Bug51744Servlet.EXPECTED));
    if (exceptionOnFailedWrite) {
        assertTrue(bc.toString().contains(Bug51744Servlet.ERROR_MESSAGE));
    }
}
 
Example 8
Source File: TestHttpServlet.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Test
public void testBug53454() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    StandardContext ctx = (StandardContext)
        tomcat.addContext("", null);

    // Map the test Servlet
    LargeBodyServlet largeBodyServlet = new LargeBodyServlet();
    Tomcat.addServlet(ctx, "largeBodyServlet", largeBodyServlet);
    ctx.addServletMapping("/", "largeBodyServlet");

    tomcat.start();

    Map<String,List<String>> resHeaders=
            new HashMap<String, List<String>>();
    int rc = headUrl("http://localhost:" + getPort() + "/", new ByteChunk(),
           resHeaders);

    Assert.assertEquals(HttpServletResponse.SC_OK, rc);
    Assert.assertEquals(LargeBodyServlet.RESPONSE_LENGTH,
            resHeaders.get("Content-Length").get(0));
}
 
Example 9
Source File: TestNamingContext.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testBug52830() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    tomcat.enableNaming();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);

    // Create the resource
    ContextEnvironment env = new ContextEnvironment();
    env.setName("boolean");
    env.setType(Boolean.class.getName());
    env.setValue("true");
    ctx.getNamingResources().addEnvironment(env);

    // Map the test Servlet
    Bug52830Servlet bug52830Servlet = new Bug52830Servlet();
    Tomcat.addServlet(ctx, "bug52830Servlet", bug52830Servlet);
    ctx.addServletMapping("/", "bug52830Servlet");

    tomcat.start();

    ByteChunk bc = new ByteChunk();
    int rc = getUrl("http://localhost:" + getPort() + "/", bc, null);
    assertEquals(200, rc);
    assertTrue(bc.toString().contains("truetrue"));
}
 
Example 10
Source File: TestNamingContext.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public void doTestLookup(boolean useSingletonResource) throws Exception {
    Tomcat tomcat = getTomcatInstance();
    tomcat.enableNaming();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);
    
    // Create the resource
    ContextResource cr = new ContextResource();
    cr.setName("list/foo");
    cr.setType("org.apache.naming.resources.TesterObject");
    cr.setProperty("factory", "org.apache.naming.resources.TesterFactory");
    cr.setSingleton(useSingletonResource);
    ctx.getNamingResources().addResource(cr);
    
    // Map the test Servlet
    Bug49994Servlet bug49994Servlet = new Bug49994Servlet();
    Tomcat.addServlet(ctx, "bug49994Servlet", bug49994Servlet);
    ctx.addServletMapping("/", "bug49994Servlet");

    tomcat.start();

    ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
    
    String expected;
    if (useSingletonResource) {
        expected = "EQUAL";
    } else {
        expected = "NOTEQUAL";
    }
    assertEquals(expected, bc.toString());

}
 
Example 11
Source File: TestPersistentManagerIntegration.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateSessionAndPassivate() throws IOException, LifecycleException, ClassNotFoundException {

    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);
    ctx.setDistributable(true);

    Tomcat.addServlet(ctx, "DummyServlet", new DummyServlet());
    ctx.addServletMapping("/dummy", "DummyServlet");

    PersistentManager manager = new PersistentManager();
    TesterStore store = new TesterStore();

    manager.setStore(store);
    manager.setMaxIdleBackup(0);
    ctx.setManager(manager);
    ctx.addValve(new PersistentValve());
    tomcat.start();
    Assert.assertEquals("No active sessions", manager.getActiveSessions(), 0);
    Assert.assertTrue("No sessions managed", manager.getSessionIdsFull().isEmpty());
    String sessionId = getUrl(
            "http://localhost:" + getPort()
                    + "/dummy?no_create_session=false").toString();
    Assert.assertNotNull("Session is stored", store.load(sessionId));
    Assert.assertEquals("All sessions are passivated", manager.getActiveSessions(), 0);
    Assert.assertTrue("One session was created", !manager.getSessionIdsFull().isEmpty());
}
 
Example 12
Source File: TestPersistentManagerIntegration.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void noSessionCreate_57637() throws IOException, LifecycleException {

    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);
    ctx.setDistributable(true);

    Tomcat.addServlet(ctx, "DummyServlet", new DummyServlet());
    ctx.addServletMapping("/dummy", "DummyServlet");

    PersistentManager manager = new PersistentManager();
    TesterStore store = new TesterStore();

    manager.setStore(store);
    manager.setMaxIdleBackup(0);
    ctx.setManager(manager);
    ctx.addValve(new PersistentValve());
    tomcat.start();
    Assert.assertEquals(manager.getActiveSessions(), 0);
    Assert.assertTrue("No sessions managed", manager.getSessionIdsFull().isEmpty());
    Assert.assertEquals(
            "NO_SESSION",
            getUrl(
                    "http://localhost:" + getPort()
                            + "/dummy?no_create_session=true").toString());
    Assert.assertEquals(manager.getActiveSessions(), 0);
    Assert.assertTrue("No sessions where created", manager.getSessionIdsFull().isEmpty());
}
 
Example 13
Source File: SpringBootTomcatPlusIT.java    From uavstack with Apache License 2.0 5 votes vote down vote up
public void onDeployUAVApp(Object... args) {
    
    if(UAVServer.ServerVendor.SPRINGBOOT!=UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR)) {
        return;
    }
    
    Tomcat tomcat=(Tomcat) args[0];
    String mofRoot=(String) args[1];
    
    //add uavApp
    StandardContext context=new StandardContext();
    context.setName("com.creditease.uav");
    context.setPath("/com.creditease.uav");
    context.setDocBase(mofRoot + "/com.creditease.uav");
    context.addLifecycleListener(new Tomcat.FixContextListener());
    tomcat.getHost().addChild(context);
    
    //add default servlet
    Wrapper servlet = context.createWrapper();
    servlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
    servlet.setName("default");
    context.addChild(servlet);    
    servlet.setOverridable(true);
    context.addServletMapping("/", "default");
    
    //init webapp classloader
    context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader()));
    context.setDelegate(true);
    
    //after tomcat8, skip jarscan
    Object obj=ReflectionHelper.newInstance("org.apache.tomcat.util.scan.StandardJarScanner", Thread.currentThread().getContextClassLoader());
    if(obj!=null) {
        ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllFiles", new Class<?>[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader());
        ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanClassPath", new Class<?>[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader());
        ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllDirectories", new Class<?>[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader());            
        
        context.setJarScanner((JarScanner) obj);      
    }        
}
 
Example 14
Source File: TestHttpServlet.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that the same Content-Length is returned for both GET and HEAD
 * operations when a Servlet includes content from another Servlet
 */
@Test
public void testBug57602() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);

    Bug57602ServletOuter outer = new Bug57602ServletOuter();
    Tomcat.addServlet(ctx, "Bug57602ServletOuter", outer);
    ctx.addServletMapping("/outer", "Bug57602ServletOuter");

    Bug57602ServletInner inner = new Bug57602ServletInner();
    Tomcat.addServlet(ctx, "Bug57602ServletInner", inner);
    ctx.addServletMapping("/inner", "Bug57602ServletInner");

    tomcat.start();

    Map<String,List<String>> resHeaders= new HashMap<String,List<String>>();
    String path = "http://localhost:" + getPort() + "/outer";
    ByteChunk out = new ByteChunk();

    int rc = getUrl(path, out, resHeaders);
    Assert.assertEquals(HttpServletResponse.SC_OK, rc);
    String length = resHeaders.get("Content-Length").get(0);
    Assert.assertEquals(Long.parseLong(length), out.getLength());
    out.recycle();

    rc = headUrl(path, out, resHeaders);
    Assert.assertEquals(HttpServletResponse.SC_OK, rc);
    Assert.assertEquals(0, out.getLength());
    Assert.assertEquals(length, resHeaders.get("Content-Length").get(0));

    tomcat.stop();
}
 
Example 15
Source File: TestNamingContext.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testBug52830() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    tomcat.enableNaming();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);

    // Create the resource
    ContextEnvironment env = new ContextEnvironment();
    env.setName("boolean");
    env.setType(Boolean.class.getName());
    env.setValue("true");
    ctx.getNamingResources().addEnvironment(env);

    // Map the test Servlet
    Bug52830Servlet bug52830Servlet = new Bug52830Servlet();
    Tomcat.addServlet(ctx, "bug52830Servlet", bug52830Servlet);
    ctx.addServletMapping("/", "bug52830Servlet");

    tomcat.start();

    ByteChunk bc = new ByteChunk();
    int rc = getUrl("http://localhost:" + getPort() + "/", bc, null);
    assertEquals(200, rc);
    assertTrue(bc.toString().contains("truetrue"));
}
 
Example 16
Source File: TestNamingContext.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public void doTestLookup(boolean useSingletonResource) throws Exception {
    Tomcat tomcat = getTomcatInstance();
    tomcat.enableNaming();

    // No file system docBase required
    StandardContext ctx = (StandardContext) tomcat.addContext("", null);
    
    // Create the resource
    ContextResource cr = new ContextResource();
    cr.setName("list/foo");
    cr.setType("org.apache.naming.resources.TesterObject");
    cr.setProperty("factory", "org.apache.naming.resources.TesterFactory");
    cr.setSingleton(useSingletonResource);
    ctx.getNamingResources().addResource(cr);
    
    // Map the test Servlet
    Bug49994Servlet bug49994Servlet = new Bug49994Servlet();
    Tomcat.addServlet(ctx, "bug49994Servlet", bug49994Servlet);
    ctx.addServletMapping("/", "bug49994Servlet");

    tomcat.start();

    ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
    
    String expected;
    if (useSingletonResource) {
        expected = "EQUAL";
    } else {
        expected = "NOTEQUAL";
    }
    assertEquals(expected, bc.toString());

}
 
Example 17
Source File: TestPersistentManager.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateSessionAndPassivate() throws IOException, LifecycleException, ClassNotFoundException {

    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0-fragments-empty-absolute-ordering");
    StandardContext ctx = (StandardContext) tomcat.addContext("", appDir.getAbsolutePath());

    Tomcat.addServlet(ctx, "DummyServlet", new DummyServlet());
    ctx.addServletMapping("/dummy", "DummyServlet");

    PersistentManager manager = new PersistentManager();
    DummyStore store = new DummyStore();

    manager.setStore(store);
    manager.setMaxIdleBackup(0);
    manager.setDistributable(true);
    ctx.setManager(manager);
    ctx.addValve(new PersistentValve());
    tomcat.start();
    Assert.assertEquals("No active sessions", manager.getActiveSessions(), 0);
    Assert.assertTrue("No sessions managed", manager.getSessionIdsFull().isEmpty());
    String sessionId = getUrl(
            "http://localhost:" + getPort()
                    + "/dummy?no_create_session=false").toString();
    Assert.assertNotNull("Session is stored", store.load(sessionId));
    Assert.assertEquals("All sessions are passivated", manager.getActiveSessions(), 0);
    Assert.assertTrue("One session was created", !manager.getSessionIdsFull().isEmpty());
}
 
Example 18
Source File: TestPersistentManager.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void noSessionCreate_57637() throws IOException, LifecycleException {

    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0-fragments-empty-absolute-ordering");
    StandardContext ctx = (StandardContext) tomcat.addContext("", appDir.getAbsolutePath());

    Tomcat.addServlet(ctx, "DummyServlet", new DummyServlet());
    ctx.addServletMapping("/dummy", "DummyServlet");

    PersistentManager manager = new PersistentManager();
    DummyStore store = new DummyStore();

    manager.setStore(store);
    manager.setMaxIdleBackup(0);
    manager.setDistributable(true);
    ctx.setManager(manager);
    ctx.addValve(new PersistentValve());
    tomcat.start();
    Assert.assertEquals(manager.getActiveSessions(), 0);
    Assert.assertTrue("No sessions managed", manager.getSessionIdsFull().isEmpty());
    Assert.assertEquals(
            "NO_SESSION",
            getUrl(
                    "http://localhost:" + getPort()
                            + "/dummy?no_create_session=true").toString());
    Assert.assertEquals(manager.getActiveSessions(), 0);
    Assert.assertTrue("No sessions where created", manager.getSessionIdsFull().isEmpty());
}
 
Example 19
Source File: Main.java    From problematic-microservices with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static void main(String[] args) throws ServletException, LifecycleException {
	OpenTracingUtil.configureOpenTracing("RobotShop-Order-Service");
	String webappDirLocation = "src/main/webapp/";
	Tomcat tomcat = new Tomcat();

	String webPort = System.getenv("PORT");
	if (webPort == null || webPort.isEmpty()) {
		webPort = DEFAULT_PORT;
	}

	tomcat.setPort(Integer.valueOf(webPort));

	StandardContext ctx = (StandardContext) tomcat.addWebapp("", new File(webappDirLocation).getAbsolutePath());
	System.out.println("Basedir: " + new File("./" + webappDirLocation).getAbsolutePath());
	File additionWebInfClasses = new File("target/classes");
	WebResourceRoot resources = new StandardRoot(ctx);
	resources.addPreResources(
			new DirResourceSet(resources, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/"));
	ctx.setResources(resources);

	// Add servlet that will register Jersey REST resources
	Tomcat.addServlet(ctx, "jersey-container-servlet", resourceConfig());
	ctx.addServletMapping("/*", "jersey-container-servlet");

	tomcat.start();
	tomcat.getServer().await();
}
 
Example 20
Source File: Main.java    From problematic-microservices with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static void main(String[] args) throws ServletException, LifecycleException {
	OpenTracingUtil.configureOpenTracing("RobotShop-Customer-Service");
	
	String webappDirLocation = "src/main/webapp/";
	Tomcat tomcat = new Tomcat();

	String webPort = System.getenv("PORT");
	if (webPort == null || webPort.isEmpty()) {
		webPort = DEFAULT_PORT;
	}

	tomcat.setPort(Integer.valueOf(webPort));

	StandardContext ctx = (StandardContext) tomcat.addWebapp("", new File(webappDirLocation).getAbsolutePath());
	System.out.println("Basedir: " + new File("./" + webappDirLocation).getAbsolutePath());
	File additionWebInfClasses = new File("target/classes");
	WebResourceRoot resources = new StandardRoot(ctx);
	resources.addPreResources(
			new DirResourceSet(resources, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/"));
	ctx.setResources(resources);

	// Add servlet that will register Jersey REST resources
	Tomcat.addServlet(ctx, "jersey-container-servlet", resourceConfig());
	ctx.addServletMapping("/*", "jersey-container-servlet");

	tomcat.start();
	tomcat.getServer().await();
}