This question already has answers here:
Run Spring-boot's main using IDE
(9 answers)
Closed 6 years ago.
Edit:
Here's the WebApplication file:
#SpringBootApplication
#EnableAsync
#EnableAutoConfiguration
public class WebApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(WebApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebApplication.class);
}
}
I am using IntelliJ(15.0.2) to run a spring boot project,
It is working properly when I execute java -jar spring-boot-sample.war
Unfortunately it failed to run by IDE and complained Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
The error details are as follows:
[2016-07-25 12:32:46.979] boot - 5719 ERROR [restartedMain] --- SpringApplication: Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)
at com.rentacoder.WebApplication.main(WebApplication.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:185)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 13 more
[2016-07-25 12:32:47.014] boot - 5719 INFO [restartedMain] --- ClasspathLoggingApplicationListener: Application failed to start with classpath: [file:/Users/hzhang/work/workplace/IdeaProjects/RHS/target/classes/]
Below is the dependencies settings in the POM file:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
Did I miss something in POM settings?
As a quick workaround, you can add a jar configuration that uses the resulting jar from target folder.
In this way you can start the application normally or in debug mode.
As a drawback for this approach: you won't have the hotswap available and you will see the changes only after a maven build. But in this case I usually add in the add jar run configuration window in before section a maven goal with "clean package -DskipTests" so each time I press run I will have the latest changes available.
This is a quickfix; the problem can be solved in other ways - I done it some times ago but I can't remember exactly what was the problematic dependency - you need to dig a little in Spring source code with some debugging around the methods from which the exception jumps.
How did you set the Configuration on IntelliJ? Since it's a WAR file, you'd need to have a web server container. Your pom has spring-boot-starter-tomcat, so you'll need to create a Tomcat Server configuration. This is a paid feature in IntelliJ, so you probably can't do it with the community edition.
A work-around is to create a Remote Debugging on your war file:
http://blog.trifork.com/2014/07/14/how-to-remotely-debug-application-running-on-tomcat-from-within-intellij-idea/
Related
So I am creating a new spring boot project and wanted to play around with spring-boot-starter-actuator. However I am facing issues when starting the application.
Pom Snippet:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<spring-boot.version>2.2.0.RELEASE</spring-boot.version>
spring-boots on my classpath:
Error while starting the application:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration.bindEntityManagerFactoryToRegistry(HibernateMetricsAutoConfiguration.java:68)
The following method did not exist:
io.micrometer.core.instrument.binder.jpa.HibernateMetrics.<init>(Lorg/hibernate/SessionFactory;Ljava/lang/String;Ljava/lang/Iterable;)V
The method's class, io.micrometer.core.instrument.binder.jpa.HibernateMetrics, is available from the following locations:
jar:file:/C:/Users/rahul/.m2/repository/io/micrometer/micrometer-core/1.0.2/micrometer-core-1.0.2.jar!/io/micrometer/core/instrument/binder/jpa/HibernateMetrics.class
It was loaded from the following location:
file:/C:/Users/rahul/.m2/repository/io/micrometer/micrometer-core/1.0.2/micrometer-core-1.0.2.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of io.micrometer.core.instrument.binder.jpa.HibernateMetrics
At this point the exception happens:
However there is only one constructor of HibernateMetrics which looks like this:
public HibernateMetrics(EntityManagerFactory entityManagerFactory, String entityManagerFactoryName, Iterable<Tag> tags) {
this.tags = Tags.concat(tags, "entityManagerFactory", entityManagerFactoryName);
this.stats = hasStatisticsEnabled(entityManagerFactory) ? getStatistics(entityManagerFactory) : null;
}
From the dependency analyzer, one could see that there are not multiple versions of micrometer-core:
I also tried with spring-boot-starter-actuator version of 2.2.0.RELEASE but that has the same issue.
I am not sure what am I missing here, any help will be really appreciated.
Assuming that you'll connect a spring-boot-actuator application to a JMX console. ( "because it's not a web application")
I've used Spring Initializr based on your pom dependencies and a CommandLineRunner example. Github example: https://github.com/thiagochagas/actuator-example
Adjusts:
I've removed the "spring-boot-starter" dependency :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
I've used a Thread.sleep(30000L) in the DemoApplication class to simplify the example.
Install and Run the Application:
./mvnw clean install
java -jar target/demo-0.0.1-SNAPSHOT.jar
Open the jconsole:
$JAVA_HOME/bin/jconsole
While your application is running it should be on the jconsole.
Select your "demo-0.0.1-SNAPSHOT.jar" to analyze:
If this message is shown, select the option "Insecure Connection":
Analysis of the running application:
I have spring test-case as shown below when I run it is not starting the Netty server and provides following exception.
Caused by: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155)
Below is my test case:
#RunWith(SpringRunner.class)
#SpringBootTest(classes = SpringWebFluxDemoApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class CustomPriceControllerTest {
#Autowired
private ApplicationContext context;
private WebTestClient testClient;
#Before
public void init() {
testClient = WebTestClient.bindToApplicationContext(context).configureClient().baseUrl("http://localhost:8080").responseTimeout(Duration.ofSeconds(30)).build();
}
#Test
public void broadcastVoltageConsumption() {
this.testClient.get().uri("/api/getCustomPrice")
.accept(MediaType.APPLICATION_STREAM_JSON)
.exchange()
.expectBodyList(Custom.class)
.consumeWith((customResults) -> {
List<Custom> list = CustomResults.getResponseBody();
Assert.assertTrue(list != null && list.size() > 0);
});
}
}
My pom.xml has excluded the dependency for tomcat to enable Netty. My Spring boot class works perfectly fine. It boots Netty server.
Update - pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
<exclusions>
<!-- Exclude the Tomcat dependency -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Had to add javax.servlet-api because I was facing issues with javax.servlet-api missing.
Update - 2
Removing the javax.servlet dependency from pom.xml solves the issue.
While when I try to run my main application it starts the Netty server normally. What is missing in this configuration? Can anyone help on this?
You wanted the webserver to be powered by Netty, but the exception you are getting is Servlet Specific
Since Netty is not servlet based technology, it seems you that somewhere (gradle/maven/#Configuration) you are mixing them,
so , just remove all references to Servlet dependencies and re try
If any dependency needs a servlet, it will force Jetty to come up and netty will never start in that case.
Whenever you see webflux is starting Jetty and not netty, you should run following command and then search who is including Jetty as dependency then you will find the answer.
./gradlew dependencies
In your case, you are including servlet dependency directly which is causing that issue.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>test</scope>
</dependency>
I had the same issue. I just remove this dependency (which have servlet dependency):
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
I am stuck with running JUnit tests. If I start my application with SpringApplication.class or with spring-boot:run - everything is ok. But when I am runnin JUnit tests - I am facing the error:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 69 more
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:229)
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:174)
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:42)
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat.dataSource(DataSourceConfiguration.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 70 more
I am sure that the error was not appearing before, but now I am stuck.
application.properties:
# Database
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/fileServer
spring.datasource.username=root
spring.datasource.password=
# JPA
spring.jpa.show_sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!--<scope>runtime</scope>-->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Test.class:
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(classes = {FileServerApplication.class})
public class FileServiceTest {
#Autowired
private FileService fileService;
#Autowired
private PathAppender pathAppender;
#Test
public void testCreateAndDeleteFile() {
String filename = "test.txt";
fileService.create(filename, FileType.FILE);
File file = new File(pathAppender.getUserDirectory() + filename);
assertTrue(file.exists());
fileService.delete(filename);
assertFalse(file.exists());
}
I've tried to play with mysql-connector scope but that does not take any effect.
I have a spring-xd processor module which has a dependecy to a project using spring-data-jpa:
pom.xml of the xd-processor module:
<dependencies>
<dependency>
<groupId>org.test.common</groupId>
<artifactId>org.test.common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
pom.xml of org.test.common:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
If I run the integration test everything works fine. But the deployment to xd-singlenode (1.2.0.RELEASE) fails with the following error:
2015-06-21T20:50:35+0200 1.2.0.RELEASE ERROR DeploymentsPathChildrenCache-0 boot.SpringApplication - Application startup failed
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:58) ~[spring-boot-autoconfigure-1.2.3.RELEASE.jar:1.2.3.RELEASE]
...
Caused by: java.lang.IllegalArgumentException: #ConditionalOnMissingBean annotations must specify at least one bean (type, name or annotation)
...
You can checkout the full sample on github.
What am I doing wrong? Any help would be appreciated.
try below solution
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>1.2.6.RELEASE</version>
click here to know more
I am currently writing an API backend using Spring which I want to deploy on to a production server using Spring Boot.
If I run the backend in Eclipse compiling to a war (specified in Maven), and using Tomcat 7, it runs without a problem.
However as I want to deploy to the server I am using Spring Boot.
Application.java
package com.ninjasquare.server;
import java.util.Arrays;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
#SpringBootApplication
public class Application {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
System.out.println("NinjaSquare server up and running with Spring Boot!");
System.out.println("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}
}
}
pom.xml
<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.ninjasquare</groupId>
<artifactId>NinjaSquareServer</artifactId>
<!-- Server Deployment Change Required: 1. Change war to jar -->
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<!-- Spring Boot related config -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.3.RELEASE</version>
</parent>
<properties>
<java-version>1.7</java-version>
<!-- Note: By default Spring Boot uses Tomcat 8. We set this so we can use Tomcat 7. -->
<!-- <tomcat.version>7.0.59</tomcat.version> -->
<!-- <org.springframework-version>4.1.6.RELEASE</org.springframework-version> -->
<org.springframework-version>3.1.1.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
<jersey.version>1.8</jersey.version>
<org.springframework.data.version>2.2.0.RELEASE</org.springframework.data.version>
<org.springframework.spring-test>2.5</org.springframework.spring-test>
<log4j.version>1.2.15</log4j.version>
<javax.inject.version>1</javax.inject.version>
<javax.servlet.version>3.0.1</javax.servlet.version>
<javax.servlet.jsp.version>2.1</javax.servlet.jsp.version>
<javax.servlet.jstl.version>1.2</javax.servlet.jstl.version>
<spring-social-facebook-version>1.1.1.RELEASE</spring-social-facebook-version>
<junit.version>4.4</junit.version>
<cglib.version>2.2.2</cglib.version>
<org.hibernate.version>4.3.1.Final</org.hibernate.version>
<com.github.jsimone.version>7.0.22.3</com.github.jsimone.version>
<org.neo4j.app.version>1.8.2</org.neo4j.app.version>
<spring-data-neo4j.version>2.0.1.RELEASE</spring-data-neo4j.version>
<maven-eclipse-plugin.version>2.9</maven-eclipse-plugin.version>
<org.apache.maven.plugins.version>2.5.1</org.apache.maven.plugins.version>
<org.codehaus.mojo>1.2.1</org.codehaus.mojo>
<org.apache.maven.plugins.maven-dependency-plugin>2.4</org.apache.maven.plugins.maven-dependency-plugin>
<org.apache.maven.plugins.maven-surefire-plugin>2.6</org.apache.maven.plugins.maven-surefire-plugin>
</properties>
<dependencies>
<!-- Server Deployment Change Required: 2. Include our custom JAR. For now, patch this code on the server manually.
Note: This JAR needs to be installed with maven install:install-file on the server -->
<!--
<dependency>
<groupId>com.ninjasquare.common</groupId>
<artifactId>ninjasquarecommon</artifactId>
<version>0.01</version>
</dependency>
-->
<!-- Spring Boot dependency -->
<!-- Import dependency management from Spring Boot -->
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.2.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Was this code missing before? -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
</dependency>
<!-- Jackson/Jersey deps -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${jersey.version}</version>
</dependency>
<!-- SDN -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<!-- <version>${org.springframework.data.version}</version> -->
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<!-- <version>${org.springframework.spring-test}</version> -->
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<!-- <version>${org.springframework-version}</version> -->
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<!-- <version>${org.springframework-version}</version> -->
</dependency>
<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<!-- <version>${org.aspectj-version}</version> -->
</dependency>
<!-- Logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<!-- <version>${log4j.version}</version> -->
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- #Inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>${javax.inject.version}</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<!-- <version>${javax.servlet.version}</version> -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>${javax.servlet.jsp.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<!-- <version>${javax.servlet.jstl.version}</version> -->
</dependency>
<!-- Import Spring Social libraries -->
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-facebook</artifactId>
<!-- <version>${spring-social-facebook-version}</version> -->
</dependency>
<!-- additional libraries required by neo/spring... -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<!-- <version>${junit.version}</version> -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<!-- <version>${org.hibernate.version}</version> -->
</dependency>
<!-- execute immediately support... -->
<dependency>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>${com.github.jsimone.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<version>${jersey.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<version>${org.neo4j.app.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<classifier>static-web</classifier>
<version>${org.neo4j.app.version}</version>
</dependency>
<!--
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j-rest</artifactId>
<version>${spring-data-neo4j.version}</version>
</dependency> -->
<dependency>
<groupId>org.simpleframework</groupId>
<artifactId>simple-xml</artifactId>
<version>2.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Plugin for Spring Boot Maven -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<!-- <version>${maven-eclipse-plugin.version}</version> -->
<configuration>
<additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
<additionalBuildcommands>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
</additionalBuildcommands>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- <version>${org.apache.maven.plugins.version}</version> -->
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<!-- <version>${org.codehaus.mojo}</version> -->
<configuration>
<mainClass>org.test.int1.Main</mainClass>
</configuration>
</plugin>
<!-- enable execution environment... -->
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${org.apache.maven.plugins.maven-dependency-plugin}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>${com.github.jsimone.version}</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin> -->
<!-- get Spring, Maven & JUnit test working... -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- <version>${org.apache.maven.plugins.maven-surefire-plugin}</version> -->
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${org.apache.maven.plugins.maven-surefire-plugin}</version>
</dependency>
</dependencies>
<configuration>
<includes>
<include>**/testcases/*.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I copy the whole project over to my linux server, and I run maven package, the code compiles without a problem. When I then run the generated jar file with java -jar [name of file] I get the following error:
09:17:26.946 [main] ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474) ~[spring-context-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) [spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) [spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) [spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) [spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at com.ninjasquare.server.Application.main(Application.java:13) [NinjaSquareServer-0.0.1-SNAPSHOT.jar!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_75]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_75]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_75]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_75]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) [NinjaSquareServer-0.0.1-SNAPSHOT.jar!/:0.0.1-SNAPSHOT]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_75]
Caused by: java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner$Tomcat8TldSkipSetter.setSkipPattern(SkipPatternJarScanner.java:106) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.setPatternToTomcat8SkipFilter(SkipPatternJarScanner.java:61) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.<init>(SkipPatternJarScanner.java:56) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.apply(SkipPatternJarScanner.java:87) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.prepareContext(TomcatEmbeddedServletContainerFactory.java:168) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:154) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
... 13 common frames omitted
I think the issue is because I don't have the right versions of Spring/Spring Boot running (perhaps it's trying to use an incorrect version of Tomcat so the method doesn't exist?)
Update 2015-04-06: I tried kucing_terbang's suggestion of using spring boot v1.1.10 but now get the error as follows:
[Stacktrace deleted, as out of space for stackoverflow question, refer to stacktrace of v1.1.12.RELEASE below]
Update 2015-04-07: I then tried with v1.1.12.RELEASE which gave similar errors:
07:41:29.917 [main] INFO o.s.b.f.a.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
07:41:29.949 [main] WARN o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:124) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476) ~[spring-context-4.0.9.RELEASE.jar!/:4.0.9.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:952) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at com.ninjasquare.server.Application.main(Application.java:13) [NinjaSquareServer-0.0.1-SNAPSHOT.jar!/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_75]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_75]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_75]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_75]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) [NinjaSquareServer-0.0.1-SNAPSHOT.jar!/:na]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_75]
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:174) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:147) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:121) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
... 13 common frames omitted
07:41:29.952 [main] ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:124) ~[spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476) ~[spring-context-4.0.9.RELEASE.jar!/:4.0.9.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109) ~[spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:952) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941) [spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at com.ninjasquare.server.Application.main(Application.java:13) [NinjaSquareServer-0.0.1-SNAPSHOT.jar!/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_75]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_75]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_75]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_75]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) [NinjaSquareServer-0.0.1-SNAPSHOT.jar!/:na]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_75]
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:174) ~[spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:147) ~[spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:121) ~[spring-boot-1.1.12.RELEASE.jar!/:1.1.12.RELEASE]
... 13 common frames omitted
I then tried a mvn clean and mvn package again, which gave me the following error on compile:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/dengke/test_garden/NinjaSquareServer-DS-ServerDeploymentPOC-2015-04-04/src/main/java/com/ninjasquare/server/Application.java:[6,46] cannot find symbol
symbol: class SpringBootApplication
location: package org.springframework.boot.autoconfigure
[ERROR] /home/dengke/test_garden/NinjaSquareServer-DS-ServerDeploymentPOC-2015-04-04/src/main/java/com/ninjasquare/server/Application.java:[9,2] cannot find symbol
symbol: class SpringBootApplication
[ERROR] /home/dengke/test_garden/NinjaSquareServer-DS-ServerDeploymentPOC-2015-04-04/src/main/java/com/ninjasquare/server/Application.java:[6,46] cannot find symbol
symbol: class SpringBootApplication
location: package org.springframework.boot.autoconfigure
[ERROR] /home/dengke/test_garden/NinjaSquareServer-DS-ServerDeploymentPOC-2015-04-04/src/main/java/com/ninjasquare/server/Application.java:[9,2] cannot find symbol
symbol: class SpringBootApplication
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.839s
[INFO] Finished at: Tue Apr 07 07:31:41 BST 2015
[INFO] Final Memory: 24M/63M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project NinjaSquareServer: Compilation failure: Compilation failure:
[ERROR] /home/dengke/test_garden/NinjaSquareServer-DS-ServerDeploymentPOC-2015-04-04/src/main/java/com/ninjasquare/server/Application.java:[6,46] cannot find symbol
[ERROR] symbol: class SpringBootApplication
[ERROR] location: package org.springframework.boot.autoconfigure
[ERROR] /home/dengke/test_garden/NinjaSquareServer-DS-ServerDeploymentPOC-2015-04-04/src/main/java/com/ninjasquare/server/Application.java:[9,2] cannot find symbol
[ERROR] symbol: class SpringBootApplication
[ERROR] /home/dengke/test_garden/NinjaSquareServer-DS-ServerDeploymentPOC-2015-04-04/src/main/java/com/ninjasquare/server/Application.java:[6,46] cannot find symbol
[ERROR] symbol: class SpringBootApplication
[ERROR] location: package org.springframework.boot.autoconfigure
[ERROR] /home/dengke/test_garden/NinjaSquareServer-DS-ServerDeploymentPOC-2015-04-04/src/main/java/com/ninjasquare/server/Application.java:[9,2] cannot find symbol
[ERROR] symbol: class SpringBootApplication
[ERROR] -> [Help 1]
However if I using v1.2.3.RELEASE I don't get the compile error, and if I then change to v1.1.12.RELEASE and run mvn package without a clean, I don't get the error either (but I get the error when running the jar as before).
Perhaps this is indicative of a deeper issue?
Any help with this issue would be much appreciated.
Thanks!
I had the exact same issue with Spring boot and the embedded tomcat server.
How I fixed it
After many hours of hit and trial, running and re-running I found that I had initially added local tomcat server to my project which was conflicting with the embedded tomcat server that Spring Boot provides. After removing the Tomcat Server from the projects build path running Spring Boot was like a charm.
Just right click the project
Build Path --> Configure Build Path --> Libraries(Tab)
and remove your Tomcat server runtime if you have added one by mistake. You should be good to go now.
I tried to run your code in my local pc and there was an error similar like what happened in your place. And, these are the steps that I did to remove those error.
Update the spring boot version
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.12.RELEASE</version>
</parent>
Update your main class as #SpringBootApplication annotation only exists after spring boot version 1.2.0
#Configuration
#EnableAutoConfiguration
#ComponentScan
public class Application {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
System.out.println("NinjaSquare server up and running with Spring Boot!");
System.out.println("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}
}
}
Remove the "webapp-runner" dependency from pom.xml as this library also has class org.apache.catalina.core.StandardContext which conflicted with the one from embedded tomcat library.
<dependency>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>${com.github.jsimone.version}</version>
<scope>provided</scope>
</dependency>
Yes, remove those lines ;)
Run the application and then, profit ?
I had this error happen to me because I created a Maven project using the webapp archetype.
Recreating the project as a simple Maven project solved this issue.
I got the error because I copied some jar files from tomcat's lib folder to jdk's lib folder.So it have an incompatible version of Tomcat on the classpath. I solved this issue after reinstalling jdk.
I had my error solved by changing the Apache Tomcat Version 9 to Version 8.5 that was not supported by Spring Boot 1.5
Update the spring boot version
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.12.RELEASE</version>
</parent>
I faced this issue when i tried to use an inhouse library which was built with a higher version of Springboot 2.2.x, whereas my code was using 2.1.x. I had upgraded to 2.2.x and the problem vanished. Ideally this happens when there are two versions of tomcat libraries in your classpath, you have find out the needed springboot version and upgrade/downgrade to fix the exception.