Not able to start the Spring-Boot sample


I was trying out spring-boot samples. This is specifically the example spring-boot-sample-tomcat, that I have been trying to run.

As instructed, I have run mvn package and it is successful. But when running the jar java -jar target/spring-boot-sample-tomcat-0.5.0.BUILD-SNAPSHOT.jar, I am getting the below exception.

Please confirm if there is any jars which need to be put in the classpath. Or what to do to make it run.

Link to the pom.xml which is being used.

Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(
        at java.lang.Class.getDeclaredMethod(
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContextListener
        at Method)
        at org.springframework.boot.loader.LaunchedURLClassLoader.findClass(
        at java.lang.ClassLoader.loadClass(
        at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(
        at java.lang.ClassLoader.loadClassInternal(
        ... 5 more
By : Kunal Jha


I just executed:

$ git fetch upstream
$ git merge upstream/master
Already up-to-date.
$ cd spring-boot-samples/spring-boot-sample-tomcat/
$ mvn clean package 
By : gregturn

This video can help you solving your question :)
By: admin