6

this is my first spring-boot project and i have problem with tomcat. Server don't wan't to start. Glass fish is not used in the project, the more I am surprised by this message. The project was created in Maven. I have sitting about this problem many hours and I can't find the problem. Enybody can help me ?

2019-12-11 16:21:30.775  WARN 10436 --- [           main]         o.a.tomcat.util.scan.StandardJarScanner  : Failed to scan [file:/C:/Users/maxwell/.m2/repository/org/glassfish/hk2/hk2/2.6.1/hk2-utils.jar] from classloader hierarchy

java.io.IOException: java.lang.reflect.InvocationTargetException
  at org.apache.tomcat.util.compat.Jre9Compat.jarFileNewInstance(Jre9Compat.java:236) ~[tomcat-embed-core-9.0.29.jar:9.0.29]

This is the my pom.xml file :

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org    /xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>maxwell</groupId>
    <artifactId>appdemo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>appdemo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
        </dependency>
        <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-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-taglibs -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-rest -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>


        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>providet</scope> 
        </dependency>

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
        </dependency>

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

        <!-- Tests -->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
dpr
  • 10,591
  • 3
  • 41
  • 71
  • Does this help? https://stackoverflow.com/questions/55481466/how-to-disable-tomcat-manifest-scanning-with-spring-boot – Smile Dec 12 '19 at 09:46
  • The Glassfish jar is part of Jersey. You seem to be using three different web frameworks for your app, Jersey (spring-boot-starter-jersey), Spring MVC (spring-boot-starter-web), and Spring WebFlux (spring-boot-starter-webflux). A typical application will only use one of these. Some may use Jersey and Spring MVC. You cannot combine WebFlux with the others as you can't mix reactive (WebFlux) with blocking (Spring MVC and Jersey). – Andy Wilkinson Dec 12 '19 at 10:52
  • Andy Wilkinson - you have right, I remove (spring-boot-starter-webflux) but problem all the time is this same. – programbeginer0235 Dec 12 '19 at 11:38

4 Answers4

3

i have also faced this problem so we can't use concurrently spring-boot-starter-web and spring-boot-starter-jersey because glassfish is part of jersey so just remove any one dependency from both of them in my case i removed starter-jersey

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-jersey</artifactId>
</dependency>

finally problem has been gone please try it

1

You should add the packaging to war at the pom.xml: <packaging>war</packaging>

Charliocat
  • 25
  • 9
1

It seems something wrong with your dependencies : can you check this typo

tomcat-embed-jasper dependency

providet

Other question why you have two dependencies if you are using tomcat one will be fine.

   <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>


        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>providet</scope> 
        </dependency>

check that example pom

spring boot web dependency is enough it already includes tomcat. You don't need to explicitly define tomcat dependency

  <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
i.karayel
  • 4,377
  • 2
  • 23
  • 27
  • I transform pom.xml in many difrend ways. This is his final version but problem is this same: examle: deleted tomcat dependncy or providet but problem is not resolve – programbeginer0235 Dec 12 '19 at 12:14
  • tomcat was just one example. There are some other dependencies you have take care of. you have many duplicated dependencies Ex: `spring-boot-starter-data-jdbc` and `spring-boot-starter-jdbc` you have to make your pom more clear. You have to add which one exactly needed. – i.karayel Dec 12 '19 at 15:20
  • also remove ` javax.servlet javax.servlet-api provided ` if not needed – i.karayel Dec 12 '19 at 15:22
0

If it is a new project i would try to run a standard project generated on: https://start.spring.io/. This way you can be sure the project should be runnable and any failure is to blame on anything other than the project or IDE. If that does not run i would reinstall Tomcat.

Quadrivics
  • 181
  • 2
  • 10