45

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

<?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.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\4.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\2.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\3.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\1.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\1.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\4.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

Ashot Karakhanyan
  • 2,804
  • 3
  • 23
  • 28
user2963481
  • 2,003
  • 6
  • 19
  • 20

12 Answers12

88

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:

  • 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
    
Vinay Rao
  • 1,284
  • 9
  • 13
  • 6
    just deleting the one problematic descendant child folder in the `.m2` repo and forcing an `Update Project` (in my case with `Force update snapshots`) did the trick – Andreas Covidiot Jul 02 '15 at 08:58
  • 2
    Thanks to you I solved a similar (invalid LOC header) problem by deleting all subfolders of "repository\org\springframework\data\spring-data-jpa\.." and then running "mvn clean install -U" afterwards. However I still had to include and export Maven Dependencies into Eclipse Build Path – patrics Apr 07 '16 at 07:00
  • I logged in just to say give the thumbs up for this advice. It worked for me. Thanks – Othello May 17 '20 at 18:32
7

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.

Somum
  • 2,382
  • 26
  • 15
6

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

Follow the Steps:

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

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

Step 2:Restart Your Eclipse.

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

Step 4:Run as Maven Clean.

Step 5:Run as Maven Install.

Step 6: Clean Project.

Step 7 : Run Your Project.

I Hope you Find your Solution Here..

Thanks..

Ketul patel
  • 321
  • 4
  • 9
5

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

4

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

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).

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.

Makarand
  • 183
  • 11
3

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...

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).

Good luck!

Community
  • 1
  • 1
Witold Kaczurba
  • 9,845
  • 3
  • 58
  • 67
2

I was getting the same error while running the mvn clean install command

[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.

0

Another option is to instead of deleting the repo add a new one, update Maven settings file - <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.

blue-sky
  • 51,962
  • 152
  • 427
  • 752
0

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

0

Nagivate to your 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.

It worked for me.

Boris_Ndong
  • 247
  • 2
  • 4
0

In the above case delete the commons-logging-1.1.1.jar from .m2/repository/ folder and then just run maven-install, It will definitely be successful.

BlackOcean
  • 28
  • 3
0

You have to remove all jars from your .m2 repository and run maven project again: if you have war already so you have to delete all jars and download again.

  • Delete contents from .m2\repository. from your directory

    mvn clean install
    
Bheem Singh
  • 607
  • 7
  • 13