1

I'm rather new to the whole embedded tomcat setup. I'm working on a project that embeds tomcat in an application which I further wish to deploy as a java web start file. So I get this one error which requires me to check logging and having no previous experience I have absolutely no clue how to. If any of you'll could help me out it would be amazing. I'm using eclipse photon with inbuilt maven.

Thanks, Noel

My application code...

package com.TomCat.EmbTC;

import java.io.File;
import javax.servlet.ServletException;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;

public class App {
public static void main(String[] args) throws LifecycleException, 
InterruptedException,
ServletException {
String docBase = "src/main/webapp/";

Tomcat tomcat = new Tomcat();
String webPort = System.getenv("PORT");
    if(webPort == null || webPort.isEmpty()) {
        webPort = "8111";
    }
    tomcat.setPort(Integer.valueOf(webPort));

tomcat.addWebapp("/", new File(docBase).getAbsolutePath());
System.out.println("configuring app with basedir: " + new File("./" + 
docBase).getAbsolutePath());

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

My pom.xml file...

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.TomCat</groupId>
<artifactId>EmbTC</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>EmbTC Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <tomcat.version>8.5.5</tomcat.version>
</properties>

<dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>3.8.1</version>
  <scope>test</scope>
</dependency>   

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>        
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-core</artifactId>
        <version>${tomcat.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jasper</artifactId>
        <version>${tomcat.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jasper-el</artifactId>
        <version>${tomcat.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jsp-api</artifactId>
        <version>${tomcat.version}</version>
    </dependency>
</dependencies>
<build>
 <finalName>EmbTC</finalName>
</build>
</project>
NoJo
  • 41
  • 1
  • 7

0 Answers0