user3458271
user3458271

Reputation: 660

SpringBoot Application not getting started because of servlet-api

hello all sorry for my English first. I am trying to startup my springboot app but it is not getting started because of servlet-api 3.1 and older version conflict but i don't know which dependency is getting conflicted for this, hope some can help me. Below is my pom file details:

<dependencies>
<dependency>  
<groupId>javax.servlet</groupId>  
<artifactId>javax.servlet-api</artifactId>  
<version>3.1.0</version>  
<scope>provided</scope>
</dependency> 

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.derby</groupId>
        <artifactId>derby</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>

Here are spring dependencies which i removed i am using springboot 2.0.4 and spring 5.

    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>${jjwt.version}</version>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.4.3</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>2.4.3</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>2.4.3</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>r05</version>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3</version>
    </dependency>

    <dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz</artifactId>
        <version>2.1.7</version>
         <exclusions>
            <exclusion>
                <groupId>javax.servlet</groupId>
                 <artifactId>servlet-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3</version>
         <exclusions>
            <exclusion>
                <groupId>javax.servlet</groupId>
              <artifactId>servlet-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.9.2</version>
    </dependency>


    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.5</version>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-csv</artifactId>
        <version>1.0</version>
    </dependency>

    <dependency>
      <groupId>commons-logging</groupId>
         <artifactId>commons-logging</artifactId>
       <version>1.2</version>
      <exclusions>
            <exclusion>
                <groupId>javax.servlet</groupId>
                  <artifactId>servlet-api</artifactId>
            </exclusion>
        </exclusions>
       </dependency>

    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20090211</version>
    </dependency>

    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.11.0</version>
    </dependency>


    <dependency>
        <groupId>net.sf.jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>6.2.1</version>
         <exclusions>  
    <exclusion>  
        <groupId>javax.servlet</groupId>  
        <artifactId>servlet-api</artifactId>  
    </exclusion>  
</exclusions>  
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.10.1</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>2.4.3</version>
         <exclusions>  
    <exclusion>  
        <groupId>javax.servlet</groupId>  
        <artifactId>servlet-api</artifactId>  
    </exclusion>  
     </exclusions>  
    </dependency>
    <dependency>
        <groupId>org.ocpsoft.rewrite</groupId>
        <artifactId>rewrite-servlet</artifactId>
        <version>2.0.12.Final</version> <!-- or latest version -->
    </dependency>

    <dependency>
        <groupId>net.sf.opencsv</groupId>
        <artifactId>opencsv</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>com.google.apis</groupId>
        <artifactId>google-api-services-bigquery</artifactId>
        <version>v2-rev265-1.21.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.6</version>
    </dependency>

    <dependency>
      <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
           <version>1.2.17</version>
    </dependency>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
         <version>1.9</version>
    </dependency>
    <dependency>
       <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
         <version>3.1</version>
     </dependency>

    <dependency>
      <groupId>org.apache.camel</groupId>
       <artifactId>camel-servlet-starter</artifactId>
       <version>${camel.version}</version>
    </dependency>
    <dependency>
     <groupId>org.apache.camel</groupId>
     <artifactId>camel-jackson-starter</artifactId>
     <version>${camel.version}</version>
   </dependency>
    <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-swagger-java-starter</artifactId>
    <version>${camel.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring-boot-starter</artifactId>
    <version>${camel.version}</version>
   </dependency>    


     <dependency>
        <groupId>pentaho-reporting-engine</groupId>
        <artifactId>pentaho-reporting-engine-classic-core</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho</groupId>
        <artifactId>pentaho-database-model</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-reporting-engine</groupId>
        <artifactId>pentaho-reporting-engine-classic-extensions</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-reporting-engine</groupId>
        <artifactId>pentaho-reporting-engine-legacy-charts</artifactId>
        <version>7.0.0.0-25</version>
    </dependency> 
    <dependency>
        <groupId>jfree</groupId>
        <artifactId>jfreechart</artifactId>
        <version>1.0.13</version>
    </dependency>
    <dependency>
        <groupId>jfree</groupId>
        <artifactId>jcommon</artifactId>
        <version>1.0.16</version>
    </dependency>
    <dependency>
        <groupId>bsf</groupId>
        <artifactId>bsf</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>bsh</groupId>
        <artifactId>bsh</artifactId>
        <version>1.3.0</version>
    </dependency>
     <dependency>
        <groupId>pentaho-library</groupId>
        <artifactId>libbase</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-library</groupId>
        <artifactId>libdocbundle</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-library</groupId>
        <artifactId>libfonts</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-library</groupId>
        <artifactId>libformat</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-library</groupId>
        <artifactId>libformula</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-library</groupId>
        <artifactId>libloader</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-library</groupId>
        <artifactId>libpixie</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-library</groupId>
        <artifactId>librepository</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-library</groupId>
        <artifactId>libserializer</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-library</groupId>
        <artifactId>libxml</artifactId>
        <version>7.0.0.0-25</version>
    </dependency>
    <dependency>
        <groupId>pentaho-library</groupId>
        <artifactId>libswing</artifactId>
        <version>7.0.0.0-25</version>
    </dependency> 

    <dependency>
    <groupId>pentaho-kettle</groupId>
    <artifactId>kettle-core</artifactId>
    <version>7.0.0.0-25</version>
    <exclusions>  
    <exclusion> 
     <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  </exclusion>
    <exclusion>  
        <groupId>javax.servlet</groupId>  
        <artifactId>servlet-api</artifactId>  
    </exclusion>  

    </exclusions>
</dependency>
<dependency>
    <groupId>pentaho-kettle</groupId>
    <artifactId>kettle-engine</artifactId>
    <version>7.0.0.0-25</version>
     <exclusions>  
      <exclusion> 
     <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  </exclusion>
    <exclusion>  
        <groupId>javax.servlet</groupId>  
        <artifactId>servlet-api</artifactId>  
       </exclusion>  
       </exclusions>
    </dependency>
    <dependency>
    <groupId>pentaho-kettle</groupId>
    <artifactId>kettle-ui-swt</artifactId>
    <version>7.0.0.0-25</version>
    <exclusions>  
      <exclusion> 
     <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  </exclusion>
    <exclusion>  
        <groupId>javax.servlet</groupId>  
        <artifactId>servlet-api</artifactId>  
    </exclusion>  
    </exclusions>
</dependency>

    <!-- Pivot4J dependencies -->
    <dependency>
        <groupId>org.pivot4j</groupId>
        <artifactId>pivot4j-core</artifactId>
        <version>0.9</version>
    </dependency>

    <dependency>
        <groupId>org.freemarker</groupId>
        <artifactId>freemarker</artifactId>
        <version>2.3.20</version>
    </dependency>

    <dependency>
        <groupId>org.olap4j</groupId>
        <artifactId>olap4j</artifactId>
        <version>1.1.0</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.13</version>
    </dependency>
    <dependency>
        <groupId>org.bitbucket.b_c</groupId>
        <artifactId>jose4j</artifactId>
        <version>0.4.4</version>
    </dependency>

    <dependency>
        <groupId>commons-dbutils</groupId>
        <artifactId>commons-dbutils</artifactId>
        <version>1.6</version>
    </dependency>


      </dependencies>
    <repositories>
    <repository>
        <id>codelds</id>
        <url>https://code.lds.org/nexus/content/groups/main-repo</url>
    </repository>

    <repository>
        <id>googleapis</id>
        <url>https://google-api-client-libraries.appspot.com/mavenrepo</url>
    </repository>
    <repository>
        <id>pentaho-releases</id>
        <url>http://nexus.pentaho.org/content/groups/omni</url>

    </repository>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
     </repositories>


     <pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
    </pluginRepositories>

This is my error message which is coming:

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

Upvotes: 3

Views: 4785

Answers (3)

de-jcup
de-jcup

Reputation: 1865

Situation

I had an similar issue with my server application using Spring Boot 2.2.6.RELEASE, but it was not the fault of Spring boot, but my usage of Wiremock for testing in combination with starting my application inside an IDE:

java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getHttpServletMapping()Ljavax/servlet/http/HttpServletMapping;
    at org.apache.catalina.core.ApplicationHttpRequest.setRequest(ApplicationHttpRequest.java:708)
    at org.apache.catalina.core.ApplicationHttpRequest.<init>(ApplicationHttpRequest.java:114)
    ...
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

My application works even with those exceptions, but for testing and debugging I do not want to have those distractions and would prefer to avoid them.

Details

WireMock (e.g. 2.26.3) uses internally Jetty 9. But Jetty does not include internally Servlet API 4 but 3 and there seems to be not much progress, even for jetty 10/11 etc. - see https://github.com/eclipse/jetty.project/issues/4578

IDE start

So when starting an IDE which does not separate automatically between runtime dependencies and test dependencies, you will have Jetty included Servlet 3 API in your classpath!

Server start by jar

In my integration tests where my application was started with runtime dependencies only, I did not have any of those exceptions, because having no jetty dependencies.

Solution

So in my case I got three possibilities to solve the problem for IDE starts:

  • change classpath ordering in IDE launch configuration
  • separate my dependencies so project used for server start does no have dependencies also in IDE, or
  • switch Spring Boot Web start dependency from tomcat to jetty ...

Upvotes: 1

elier
elier

Reputation: 459

Like @user1695936 said: The problem is that mondrian includes an older version of servlet-ap (v2.4) that does not have the method getVirtualServerName()

Check for dependencies with javax.servlet with this:

mvn dependency:tree -Dverbose -Dincludes=javax.servlet

pentaho:mondrian:jar:8.3.0.0-371:compile
       |  +- javax.servlet:servlet-api:jar:2.4:compile
       |  \- javax.servlet:jsp-api:jar:2.0:compile

and exclude the old versions like the example below:

<dependency>
    <groupId>pentaho-kettle</groupId>
    <artifactId>kettle-engine</artifactId>
    <version>${pentaho-kettle.version}</version>
    <exclusions>
        <exclusion>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Upvotes: 0

jorgernan
jorgernan

Reputation: 11

I had a similar problem (Sprint Boot 1.5 and Kettle 8) and I found out the problem/conflict is with kettle-core and kettle-engine.

I excluded slf4j and servlet in those dependencies:

<!-- Pentaho Kettle -->
<dependency>
    <groupId>pentaho-kettle</groupId>
    <artifactId>kettle-core</artifactId>
    <version>${pentaho-kettle.version}</version>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>pentaho-kettle</groupId>
    <artifactId>kettle-engine</artifactId>
    <version>${pentaho-kettle.version}</version>
    <exclusions>
        <exclusion>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Upvotes: 1

Related Questions