Java hibernate-commons-annotations-4.0.1.Final.jar; 无效的 LOC 标头(错误的签名)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23310474/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 21:48:33  来源:igfitidea点击:

hibernate-commons-annotations-4.0.1.Final.jar; invalid LOC header (bad signature)?

javahibernatemaven

提问by user2963481

I am new for Maven ..I am trying to create maven project for springMVC+Hiberante but I am getting lot of errors..can any one slove my problem please check my pom.xml for below

我是 Maven 的新手..我正在尝试为 springMVC+Hiberante 创建 maven 项目,但我遇到了很多错误..任何人都可以解决我的问题,请检查我的 pom.xml 以了解以下内容

<?xml version="1.0" encoding="UTF-8"?><project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>Spring3HibernateMaven</groupId>
    <artifactId>Spring3HibernateMaven</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <description></description>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>

                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>

            <!--  <plugin>
               <artifactId>maven-war-plugin</artifactId>
               <version>2.0</version>

             </plugin> -->
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.1.9.Final</version>
        </dependency>

        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.10</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>20030825.184428</version>
        </dependency>
        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>20030825.183949</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.6.4</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.4.0.GA</version>
        </dependency>

    </dependencies>
    <properties>
        <org.springframework.version>3.0.2.RELEASE</org.springframework.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

but I am getting the following errors

但我收到以下错误

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project Spring3HibernateMaven: Compilation failure: Compilation failure:
[ERROR] error: error reading C:\Users\Bhanu\.m2\repository\commons-logging\commons-logging.1.1\commons-logging-1.1.1.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Users\Bhanu\.m2\repository\org\hibernate\hibernate-core.1.9.Final\hibernate-core-4.1.9.Final.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Users\Bhanu\.m2\repository\antlr\antlr.7.7\antlr-2.7.7.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Users\Bhanu\.m2\repository\org\jboss\logging\jboss-logging.1.0.GA\jboss-logging-3.1.0.GA.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Users\Bhanu\.m2\repository\dom4j\dom4j.6.1\dom4j-1.6.1.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Users\Bhanu\.m2\repository\org\hibernate\javax\persistence\hibernate-jpa-2.0-api.0.1.Final\hibernate-jpa-2.0-api-1.0.1.Final.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Users\Bhanu\.m2\repository\org\hibernate\common\hibernate-commons-annotations.0.1.Final\hibernate-commons-annotations-4.0.1.Final.jar; invalid LOC header (bad signature)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Can Any one help me how to resolve my problem . I am using apache-maven-3.2.1 +Java1.6+ecpliseIndigo

任何人都可以帮助我如何解决我的问题。我正在使用apache-maven-3.2.1 +Java1.6+ecpliseIndigo

回答by Vinay Rao

This looks like a problem of corrupt jars being downloaded. I have seen this happen only when I use eclipse. Here's what I did to get rid of this problem:

这看起来像是下载损坏的 jars 的问题。我只在使用 eclipse 时才看到这种情况发生。这是我为解决此问题所做的工作:

  • Delete contents from C:\Users\Bhanu.m2\repository. Either everything or selectively - your choice.
  • Then use the command prompt to force download jars and build

    mvn clean install
    
  • 从 C:\Users\Bhanu.m2\repository 中删除内容。无论是一切还是有选择地 - 您的选择。
  • 然后使用命令提示符强制下载jars并构建

    mvn clean install
    

回答by blue-sky

Another option is to instead of deleting the repo add a new one, update Maven settings file - <localRepository>C:\\repos\\mycustomrepo</localRepository>

另一种选择是不删除 repo 添加一个新的 repo,而是更新 Maven 设置文件 - <localRepository>C:\\repos\\mycustomrepo</localRepository>

This can be useful if your working between on different unrelated projects - as was my case. @Vinay Rao answer pointed me in direction of creating a custom repo.

如果您在不同的不相关项目之间工作,这可能很有用 - 就像我的情况一样。@Vinay Rao 的回答为我指明了创建自定义存储库的方向。

回答by tarun kumar

I was getting the same problem.So I had update my maven library and it worked for me.

我遇到了同样的问题。所以我更新了我的 Maven 库,它对我有用。

回答by Somum

I will tell you what I did

我会告诉你我做了什么

I was getting the same error in common-logging so I went to C:\Users\admin.m2\repository\commons-logging and deleted the directory. The problem was solved next time I compiled.

我在 common-logging 中遇到了同样的错误,所以我去了 C:\Users\admin.m2\repository\commons-logging 并删除了该目录。下次编译的时候问题就解决了。

回答by Asif Iquebal Ajazi

I was getting the same error while running the mvn clean installcommand

我在运行mvn clean install命令时遇到了同样的错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project MongoModule: Compilation failure
[ERROR] error: error reading /home/radium/.m2/repository/org/mongodb/mongo-java-driver/3.2.2/mongo-java-driver-3.2.2.jar; invalid LOC header (bad signature)
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project MongoModule: Compilation failure
error: error reading /home/radium/.m2/repository/org/mongodb/mongo-java-driver/3.2.2/mongo-java-driver-3.2.2.jar; invalid LOC header (bad signature)

Then I deleted the mongo-java-driver-3.2.2.jar file from the maven repo and re run the maven build command, which forced the maven to re download the jar and successfully build the project.

然后我从maven repo中删除了mongo-java-driver-3.2.2.jar文件,重新运行maven build命令,强制maven重新下载jar,成功构建项目。

回答by Makarand

I know this is an old thread, but I have faced the same problem (albeit with a different jar file).

我知道这是一个旧线程,但我遇到了同样的问题(尽管使用了不同的 jar 文件)。

In eclipse, when a maven build fails because of corrupt LOC header, a warning is generated (in my case it was spring-tx-3.0.3.RELEASE.pom but could be any other maven dependancy).

在 Eclipse 中,当 maven 构建因 LOC 标头损坏而失败时,会生成警告(在我的情况下,它是 spring-tx-3.0.3.RELEASE.pom 但可能是任何其他 maven 依赖项)。

Go up in build stack-trace and figure out which JAR is failing, delete the corresponding repo folder from .m2 repositories and rebuild, that should do the trick.

进入构建堆栈跟踪并找出哪个 JAR 失败,从 .m2 存储库中删除相应的 repo 文件夹并重建,这应该可以解决问题。

回答by Ketul patel

It Throw Because your hibernate-commons-annotations-4.0.1.Final.jar is Invalid Or Corrupted.

它抛出是因为您的 hibernate-commons-annotations-4.0.1.Final.jar 无效或已损坏。

Follow the Steps:

按照步骤:

Note : .m2 Folder is Hidden by Default. UnHide the Folder.

注意:.m2 文件夹默认是隐藏的。取消隐藏文件夹。

Step 1:Delete all the Content in .m2/repository Folder.

步骤 1:删除 .m2/repository 文件夹中的所有内容。

Step 2:Restart Your Eclipse.

第 2 步:重新启动 Eclipse。

Step 3:Maven->Update Project .Checked- Force Update of Snapshots/Releases.

第 3 步:Maven->Update Project .Checked-强制更新快照/发布。

Step 4:Run as Maven Clean.

第 4 步:作为 Maven Clean 运行。

Step 5:Run as Maven Install.

第 5 步:作为 Maven 安装运行。

Step 6: Clean Project.

第 6 步:清理项目。

Step 7 : Run Your Project.

第 7 步:运行您的项目。

I Hope you Find your Solution Here..

我希望你在这里找到你的解决方案..

Thanks..

谢谢..

回答by Witold Kaczurba

It is important to remember that what is invalid is useless (e.g. corrupted), so:

重要的是要记住,无效的东西是无用的(例如已损坏),因此:

  • Delete all JARs that have invalid signature. invalid means invalid.
  • Update Maven project, clean, install.
  • If you still get invalid LOC header - change repo and your ISP...
  • 删除所有签名无效的 JAR。无效意味着无效。
  • 更新 Maven 项目,清理,安装。
  • 如果您仍然收到无效的 LOC 标头 - 更改 repo 和您的 ISP ...

I had similar problem and it had nothing to do with revisioning or Maven itself... The problem was corrupted JAR ( Eclipse with Maven plugin does not work with latest revisions, but works with older ones).

我有类似的问题,它与修订或 Maven 本身无关......问题是 JAR 损坏( 带有 Maven 插件的 Eclipse 不适用于最新版本,但适用于旧版本)。

Good luck!

祝你好运!

回答by Niklas Schlimm

The reason is a corrupt jar file. Use mvn dependency:purge-local-repositoryto delete und reload your dependencies in your local maven repository.

原因是 jar 文件损坏。使用mvn dependency:purge-local-repository删除UND重装你的依赖在你的本地仓库。

回答by Boris_Ndong

Nagivate to your C:\Users\user.m2\repository\projects\project1

导航到您的 C:\Users\user.m2\repository\projects\project1

Pick the corresponding project and delete it from your .m2. Then f you use maven do mvn clean install otherwise build it accordingly in the terminal. it will recreate those jar files for you Reinstall the ear or war file in server and it should deploy just fine now.

选择相应的项目并将其从您的 .m2 中删除。然后如果你使用 maven do mvn clean install 否则在终端中相应地构建它。它将为您重新创建那些 jar 文件在服务器中重新安装 ear 或 war 文件,现在应该可以正常部署了。

It worked for me.

它对我有用。