0

I am trying use google sheet API. I was able to connect to my google sheet as a standalone code base. I was trying to run the same with spring boot application. I created a war file along with spring boot integrated. When I run

java -jar myApp.war

It fails with the below error,

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:137) ~[spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
        at com.nielsen.google.myna.App.main(App.java:17) [classes!/:1]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_144]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_144]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_144]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [myna-1.war:1]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [myna-1.war:1]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [myna-1.war:1]
        at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59) [myna-1.war:1]
Caused by: java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V

I have the below 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/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.api.google</groupId>
 <artifactId>myApp</artifactId>
 <version>1</version>
 <packaging>war</packaging>

 <name>myApp</name>
 <description>api test</description>

 <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 </properties>

 <parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>1.5.9.RELEASE</version>
 </parent>

 <dependencies>
  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
  </dependency>
  <dependency>
   <groupId>com.google.apis</groupId>
   <artifactId>google-api-services-calendar</artifactId>
   <version>v3-rev281-1.23.0</version>
  </dependency>
  <dependency>
   <groupId>com.google.apis</groupId>
   <artifactId>google-api-services-sheets</artifactId>
   <version>v4-rev498-1.23.0</version>
  </dependency>
  <dependency>
   <groupId>com.google.oauth-client</groupId>
   <artifactId>google-oauth-client</artifactId>
   <version>1.23.0</version>
  </dependency>
  <dependency>
   <groupId>com.google.oauth-client</groupId>
   <artifactId>google-oauth-client-java6</artifactId>
   <version>1.23.0</version>
  </dependency>
  <dependency>
   <groupId>com.google.oauth-client</groupId>
   <artifactId>google-oauth-client-jetty</artifactId>
   <version>1.23.0</version>
   <!-- <exclusions>
    <exclusion>
     <artifactId>org.mortbay.jetty</artifactId>
     <groupId>jetty</groupId>
    </exclusion>
    <exclusion>
     <artifactId>org.mortbay.jetty</artifactId>
     <groupId>servlet-api</groupId>
    </exclusion>
   </exclusions> -->
  </dependency>
  <dependency>
   <groupId>org.json</groupId>
   <artifactId>json</artifactId>
   <version>20171018</version>
  </dependency>
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>3.8.1</version>
   <scope>test</scope>
  </dependency>
 </dependencies>
 <build>
  <plugins>
   <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
   </plugin>
  </plugins>
 </build>

</project>

It looks like some conflict between embedded tomcat server but i couldn't resolve this.

Arun
  • 609
  • 2
  • 12
  • 33
  • 1
    https://github.com/paulc4/microservices-demo/issues/12. to run it as java application, you should package it as "jar", not "war". war file is used to deploy to tomcat server or other web server, not for java application. – Surely Jan 14 '18 at 06:29
  • yes it worked. @Surely Thank you! for your quick response. Let me try to deploy the war in tomcat and test. – Arun Jan 17 '18 at 15:16

0 Answers0