0
votes

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'

}
1
The solution provided by Ueslei Lima has worked exactly the way I wanted. Thanks a lot. I am not able to mark below reply as an answer.satishkk

1 Answers

4
votes

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.