My application does not start in Spring-Tools Suite

Asked

Viewed 2,953 times

2

I created a Maven project in Spring-Tools Suite when I started this error appears:

Exception in thread "main" java.lang.IllegalStateException: Failed to read Class-Path attribute from manifest of jar file:/C:/Users/Manoel/.m2/repository/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar
    at org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromClassPathOfJarManifestIfPossible(ChangeableUrls.java:102)
    at org.springframework.boot.devtools.restart.ChangeableUrls.fromUrlClassLoader(ChangeableUrls.java:88)
    at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:93)
    at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getInitialUrls(DefaultRestartInitializer.java:56)
    at org.springframework.boot.devtools.restart.Restarter.<init>(Restarter.java:139)
    at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:539)
    at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartedEvent(RestartApplicationListener.java:68)
    at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:45)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
    at org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:67)
    at org.springframework.boot.SpringApplicationRunListeners.started(SpringApplicationRunListeners.java:48)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1187)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1176)
    at com.algaworks.vinhos.AwVinhosApplication.main(AwVinhosApplication.java:10)
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access$1400(Unknown Source)
    at java.util.zip.ZipFile$ZipFileInputStream.read(Unknown Source)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(Unknown Source)
    at java.util.zip.InflaterInputStream.read(Unknown Source)
    at sun.misc.IOUtils.readFully(Unknown Source)
    at java.util.jar.JarFile.getBytes(Unknown Source)
    at java.util.jar.JarFile.getManifestFromReference(Unknown Source)
    at java.util.jar.JarFile.getManifest(Unknown Source)
    at org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromClassPathOfJarManifestIfPossible(ChangeableUrls.java:99)
    ... 16 more

Follows the class AwVinhosApplication

package com.algaworks.vinhos;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication 
public class AwVinhosApplication {

    public static void main(String[] args) {
        SpringApplication.run(AwVinhosApplication.class, args);
    } 
}   
  • It looks like a corrupted jar. Are you using Maven? Maybe it’s a good idea to delete the account from the folder ~/.m2/repository/* (see: that reply from Soen)

  • @Anthony. I’m using the Maven, I’m not finding this folder

  • 1

    This folder ". m2" is hidden you have to enable in windows view to show. They are in C:/Users/User/. m2

  • 3

    Open your file manager (e.g., Windows Explorer or Nautilus) and navigate to your user’s folder (e. g., C:\User\JoseLemo). The briefcase .m2 may be invisible but you can navigate to it anyway by typing the path (e. g., C:\User\JoseLemo\.m2). Try deleting the contents of the folder repository and build the project (mvn clean install) again.

  • Thank you very much. It all worked out :D

2 answers

5


Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)

It usually means that one or more jars are corrupted.

Maven by default downloads and stores these jars in the folder ~/.m2/repository/*. To resolve the issue delete the contents of the folder and run mvn clean install again.

Obs: In Windows the folder .m2 by default becomes invisible. To find it, assuming default settings in Maven, open your file manager and navigate to your user’s folder (e. g., C:\User\MeuUsuario). Even if the folder .m2 is not visible you can navigate to it by typing the path (e. g., C:\User\MeuUsuario\.m2\repository).


Source: Soen - Maven invalid LOC header (bad Signature)

  • I have the same error, I did everything as you said but when running the command "mvn clean install" appears -bash: mvn: command not found. I am a MAC user.

  • Oi Fernando. Recent versions of macOS do not come with Maven pre-installed. STS uses an embedded version by default. Assuming your project uses Maven, the options are to install Maven or use STS itself to rebuild the project.

0

I had this same problem with this Algawoks project. I solved by changing the version of Hibernate in pom.xml was thus after the amendments. org.springframework.boot spring-boot-Starter-Parent 1.5.3.RELEASE

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>

io.jsonwebtoken jjwt 0.7.0 org.springframework.boot spring-boot-Starter-data-jpa org.springframework.boot spring-boot-Starter-Thymeleaf org.postgresql postgresql

</dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
            <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.