spring boot embedded tomcat doesn't start with jcifs smb library - spring-boot

I have a standalone java application which uses jcifs library for doing SMB operations. The standalone application uses spring boot. This application works fine and is able to meet the requirements.
I have to convert this standalone application to a restful service. I thus used spring boot starter with embedded tomcat. The converted application compiles fine but when I start the application, the embedded tomcat doesn't start and gives below error.
I have narrowed the problem to inclusion of jcifs library. when I remove it the embedded tomcat starts fine and when I include it then get the below error.
The jcifs dependency is as follows:
compile group: 'jcifs', name: 'jcifs', version: '1.3.17'
Please let me know what could be the problem or any any pointers. I am running against a very tight timeline and thus any help/pointers will be very much appreciated.
The error is:
2017-10-09 22:50:50.189 INFO 1780 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.5
2017-10-09 22:50:50.470 ERROR 1780 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase : A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_144]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_144]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890) [tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) [tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) [tomcat-embed-core-8.5.5.jar:8.5.5]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_144]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.5.jar:8.5.5]
... 6 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [Pipeline[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5099) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
... 6 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.authenticator.NonLoginAuthenticator[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:170) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
... 8 common frames omitted
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1122) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
... 10 common frames omitted
Below is the gradle file. I am using gradle 2.10.0 version.
buildscript {
repositories {
mavenCentral()
maven { url "http://repo1.maven.org/maven2" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2.1"
}
}
// Apply the java plugin to add support for Java
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply plugin: "org.sonarqube"
apply plugin: 'jacoco'
jar {
baseName = 'connectorservice'
version = '0.1.0'
manifest {
attributes 'Main-Class': 'com.uu.ff.connectorservice.main.Application'
}
}
repositories {
mavenCentral()
maven { url "http://repo1.maven.org/maven2" }
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
// In this section you declare the dependencies for your production and test code
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-aop')
compile('org.springframework:spring-aspects')
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile group: 'org.apache.commons', name: 'commons-vfs2', version: '2.1'
compile group: 'de.odysseus.staxon', name: 'staxon', version: '1.3'
testCompile("junit:junit")
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.6.4'
testCompile group: 'org.powermock', name: 'powermock-api-mockito', version: '1.6.4'
compile('org.springframework.boot:spring-boot-starter-test')
compile group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4'
compile group: 'jcifs', name: 'jcifs', version: '1.3.17'
}

You just have do exclude the "servlet-api" dependency from jcifs library, it is conflicting with tomcat default servlet api.
In maven it would be something like:
<dependency>
<groupId>org.codelibs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.18.2</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
The exclusion serves well also when using spring-integration-smb library.

Related

Spring Boot 1 and Gradle: ClassNotFoundException SpringApplicationBuilder

I've got a Gradle configuration for a Spring Boot 1.5 application. It runs fine in Spring Tool Suite, but gradlew build creates a jar file with no jar files in the BOOT-INF folder. This of course prevents the successful execution of the jar file:
java -jar build\libs\myapp-0.0.1-SNAPSHOT.jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
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.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/builder/SpringApplicationBuilder
at myapp.boot.Application.runWithContextHierarchy(Application.java:50)
at myapp.boot.Application.main(Application.java:33)
... 8 more
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.builder.SpringApplicationBuilder
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 10 more
build.gradle excerpt:
plugins {
id 'org.springframework.boot' version '1.5.22.RELEASE'
id 'java'
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.boot:spring-boot-starter-jdbc')
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
...
}
Turns out that Spring Boot 1 isn't able to work with implementation dependencies, but with (deprecated) compile dependencies.
Working build.gradle dependencies:
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
....
}

Failed to execute junit5 tests with dependency management with spring boot gradle plugin

In my project based on gradle and kotlin I have some sub module. Build configugration for it module (build.gradle.kts):
plugins {
java
kotlin("jvm")
id("org.springframework.boot") version "2.1.5.RELEASE"
id("io.spring.dependency-management") version "1.0.7.RELEASE"
}
dependencies {
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31")
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31")
testCompile("org.jetbrains.kotlin:kotlin-stdlib:1.3.31")
testCompile("org.jetbrains.kotlin:kotlin-reflect:1.3.31")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.4.2")
}
I try to run some simple test in this module
Simple class:
class Hello {
fun hello(): String {
return "hello"
}
}
Simple test for it:
class HelloTest {
#Test
fun test() {
Assertions.assertEquals(Hello().hello(), "hello")
}
}
When i'm trying to run test i get error:
Jun 12, 2019 2:58:31 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'junit-jupiter' failed to execute tests
java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(Ljava/lang/String;)Lorg/junit/platform/commons/function/Try;
at org.junit.jupiter.engine.support.OpenTest4JAndJUnit4AwareThrowableCollector.createAbortedExecutionPredicate(OpenTest4JAndJUnit4AwareThrowableCollector.java:40)
at org.junit.jupiter.engine.support.OpenTest4JAndJUnit4AwareThrowableCollector.<clinit>(OpenTest4JAndJUnit4AwareThrowableCollector.java:30)
at org.junit.jupiter.engine.support.JupiterThrowableCollectorFactory.createThrowableCollector(JupiterThrowableCollectorFactory.java:34)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:68)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:102)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:82)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:78)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
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.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.stop(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:132)
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.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:rest:test'.
> No tests found for given includes: [ua.company.app.Hello](filter.includeTestsMatching)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
4 actionable tasks: 2 executed, 2 up-to-date
No tests found for given includes: [ua.company.app.Hello](filter.includeTestsMatching)
But if remove id("io.spring.dependency-management") version "1.0.7.RELEASE" from my build config and will use version of spring boot like this compile("org.springframework.boot:spring-boot-starter-web:2.1.5.RELEASE") test runs correctly.
Spring dependency management brokes my junit5 tests. Please can anyone explain why this is happening and how to solve the problem? Thanks!
It would appear that adding Spring Dependency Management changes some of the transitive dependencies for your junit-jupiter dependencies.
Your declared junit version (5.4.2) depends on junit-platform-commons 1.4.2, but when you add Spring Dependency Management it is changing the commons version from 1.4.2 to 1.3.2. This is why you are receiving the NoSuchMethodError since that method was added in version four!
Here's two solutions I can think of:
1) (I recommend this) Drop your declared junit version and let Spring Dependency Management handle everything for junit:
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntime("org.junit.jupiter:junit-jupiter-engine")
2) Declare the transitive dependency versions for junit (this would allow you to carry on using version 5.4.2 if this is a must-have)
testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.2")
testImplementation("org.junit.platform:junit-platform-commons:1.4.2")
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.4.2")
testRuntime("org.junit.platform:junit-platform-engine:1.4.2")

Where in SpringHow in Spring Boot do I solve a "java.lang.NoClassDefFoundError: org/springframework/data/mapping/context/MappingContext"?

I"m using Java 8 and Spring Boot. Trying to build a simple REST application that sits on a MongoDB. I have this in my Gradle build file
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb:2.1.5.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-web:2.1.5.RELEASE'
implementation 'org.springframework.boot:spring-boot-dependencies:2.1.5.RELEASE'
}
but when I go to start my app I get an error about not being able to find a class, "org/springframework/data/mapping/context/MappingContext":
localhost:todoapp-backend davea$ java -jar ./build/libs/spring-data-mongodb-example-1.0.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/data/mapping/context/MappingContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethod(Class.java:2128)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:47)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.ClassNotFoundException: org.springframework.data.mapping.context.MappingContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
What other dependency I'm I supposed to include to get the missing class found?
You should use Springboot Gradle plugin. It will solve all your dependecies issues .
plugins {
id 'java
id 'org.springframework.boot' version '2.1.5.RELEASE'
}
apply plugin: 'io.spring.dependency-management'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-web'
}

Google Api Calendar and Spring Boot not working because of dependencies

I am trying to use the Google Api for Calendar (https://developers.google.com/calendar/quickstart/java) but, when I include the dependencies in my spring boot project I get an error.
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.28.jar:8.5.28]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) ~[tomcat-embed-core-8.5.28.jar:8.5.28]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.28.jar:8.5.28]
... 15 common frames omitted
It looks like it is related to the fact that google api uses Jetty.
These are my build.gradle dependencies:
dependencies {
compile "com.google.api-client:google-api-client:1.23.0"
compile 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
compile 'com.google.apis:google-api-services-calendar:v3-rev305-1.23.0'
compile 'javax.persistence:javax.persistence-api:2.2'
compile 'javax.inject:javax.inject:1'
compile 'javax.validation:validation-api:2.0.1.Final'
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'com.h2database:h2'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
gradleLint.ignore('unused-dependency') {
compileOnly 'org.projectlombok:lombok:1.16.20'
}
}

Tomcat - A child container failed during start - After converting maven to gradle

I converted my project from maven to gradle.
After converting while startup my tomcat server I am getting the following error log.
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Tabserve-Superadmin]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122) at
java.util.concurrent.FutureTask.get(FutureTask.java:192) at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1120)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) Caused by:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Tabserve-Superadmin]]
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
... 6 more Caused by: java.lang.NoSuchMethodError:
javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
at
org.apache.tomcat.websocket.server.WsServerContainer.(WsServerContainer.java:147)
at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131) at
org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47) at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5573)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 6 more
Nov 01, 2016 2:37:10 PM org.apache.catalina.core.ContainerBase
startInternal SEVERE: A child container failed during start
java.util.concurrent.ExecutionException:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost]] at
java.util.concurrent.FutureTask.report(FutureTask.java:122) at
java.util.concurrent.FutureTask.get(FutureTask.java:192) at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1120)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:444)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:756)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.startup.Catalina.start(Catalina.java:693) 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294) at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428) Caused
by: org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost]] at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) Caused by:
org.apache.catalina.LifecycleException: A child container failed
during start at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1128)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 6 more
Nov 01, 2016 2:37:10 PM org.apache.catalina.startup.Catalina start
SEVERE: The required Server component failed to start so Tomcat is
unable to start. org.apache.catalina.LifecycleException: Failed to
start component [StandardServer[8005]] at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.startup.Catalina.start(Catalina.java:693) 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294) at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428) Caused
by: org.apache.catalina.LifecycleException: Failed to start component
[StandardService[Catalina]] at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:756)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 7 more Caused by: org.apache.catalina.LifecycleException: Failed
to start component [StandardEngine[Catalina]] at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:444)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 9 more Caused by: org.apache.catalina.LifecycleException: A child
container failed during start at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1128)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 11 more
These are my dependencies
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
war {
baseName = 'MyApp'
version = '0.0.1'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'lib')
compile project(':Model_v102')
compile("org.springframework:spring-core:3.1.0.RELEASE")
compile("org.springframework:spring-context-support:3.1.0.RELEASE")
compile("org.springframework:spring-beans:3.1.0.RELEASE")
compile("org.springframework:spring-context:3.1.0.RELEASE")
compile("org.springframework:spring-tx:3.1.0.RELEASE")
compile("org.springframework:spring-jdbc:3.1.0.RELEASE")
compile("org.springframework:spring-orm:3.1.0.RELEASE")
compile("org.springframework:spring-web:3.1.0.RELEASE")
compile("org.springframework:spring-jms:3.1.0.RELEASE")
compile("dom4j:dom4j:1.1")
compile("cglib:cglib:2.1_3")
compile("com.google.code.gson:gson:1.7.1")
compile("org.projectlombok:lombok:1.12.4")
compile("org.apache.commons:commons-io:1.3.2")
compile("commons-fileupload:commons-fileupload:1.2.2")
compile('commons-codec:commons-codec:1.7')
compile("org.jasypt:jasypt:1.7.1")
compile("net.sf.ehcache:ehcache-core:2.5.2")
compile("commons-lang:commons-lang:2.6")
compile("org.slf4j:slf4j-api:1.6.1")
compile("javassist:javassist:3.12.0.GA")
compile("com.sun.faces:jsf-api:2.1.7")
compile("com.sun.faces:jsf-impl:2.1.7")
compile("javax:javaee-api:6.0")
compile("org.hibernate:hibernate-validator:4.3.0.Final")
compile("org.hibernate:hibernate-core:3.5.1-Final")
compile("org.hibernate:hibernate-annotations:3.5.1-Final")
compile("mysql:mysql-connector-java:5.1.15")
compile("org.primefaces:primefaces:3.5")
compile("joda-time:joda-time:2.1")
compile("c3p0:c3p0:0.9.1.1")
//compile("javax.servlet:jstl:1.2")
compile("com.caucho:resin-hessian:4.0.1")
compile("org.apache.poi:poi:3.7")
compile("com.itextpdf:itextpdf:5.0.6")
compile("net.sf.jasperreports:jasperreports:6.1.0")
compile("org.quartz-scheduler:quartz:2.1.1")
compile("log4j:log4j:1.2.15")
//providedCompile("org.apache.tomcat:tomcat-catalina:7.0.29")
testCompile("junit:junit")
}
The root cause is:
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String
This method has been added in Servlet 3.1. Are you sure you are deploying to the correct Tomcat version?
As #chkal said it looks like a different version of servlet-api is on the classpath. Try comparing the following from command line
mvn dependency:tree (from the old maven build)
gradle dependencies (from the gradle build)
I'm guessing the servlet-api version is different in maven vs gradle build. Maven will use a "nearest definition wins" strategy to resolve multiple versions of an artifact whereas gradle will use the latest version. Note that you can customise the way that gradle resolves dependencies.

Resources