Hello Noel, mmm, perhaps you could consider to use spring-boot for this. It provides a nice out-of-the-box embedded tomcat: https://spring.io/blog/2014/03/07/deploying-spring-boot-applications
Hope it helps, Luis 2018-08-03 7:06 GMT+02:00 noel joseph <noelvinu1...@gmail.com>: > Hey Chris, > > This is my 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(); > > } > } > > and this is 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> > > > I am not making use of a web.xml file. > This codes running perfectly on eclipse when run, depolying a tomcat server > as expected. > But when i convert into a jar and run it as a jnlp file i get the error... > > org.apache.catalina.LifecycleException: A child container failed during > start > at > org.apache.catalina.core.ContainerBase.startInternal( > ContainerBase.java:947) > at > org.apache.catalina.core.StandardEngine.startInternal( > StandardEngine.java:262) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) > at > org.apache.catalina.core.StandardService.startInternal( > StandardService.java:422) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) > at > org.apache.catalina.core.StandardServer.startInternal( > StandardServer.java:793) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) > at org.apache.catalina.startup.Tomcat.start(Tomcat.java:344) > at com.TomCat.EmbTC.App.main(App.java:23) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) > at java.lang.reflect.Method.invoke(Unknown Source) > at com.sun.javaws.Launcher.executeApplication(Unknown Source) > at com.sun.javaws.Launcher.executeMainClass(Unknown Source) > at com.sun.javaws.Launcher.doLaunchApp(Unknown Source) > at com.sun.javaws.Launcher.run(Unknown Source) > at java.lang.Thread.run(Unknown Source) > > Please let me know what's the problem with my code. > > Thanks, > Noel > -- "Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better." - Samuel Beckett