0

I have few jars related to some internal project which i am using in my project. These are being installed in the local maven repository using the maven install command as they are not available on any repository.

But, when i try to build the application, it fails with error:

error: error reading D:\proj\.m2\repository\com\affecto\bolib-web\0.1.6\bolib-web-0.1.6.jar
error in opening zip file

Error trace:

[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

error: error reading D:\proj\.m2\repository\com\affecto\bolib-web\0.1.6\bolib-
web-0.1.6.jar; error in opening zip file
error: error reading D:\proj\.m2\repository\com\microsoft\sqljdbc\2005\sqljdbc
-2005.jar; error in opening zip file

[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.BuildFailureException: Compilation failure
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:715)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:556)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:535)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:6
0)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation fail
ure
        at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompiler
Mojo.java:516)
        at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:694)
        ... 17 more
Link to full build log:
https://gist.github.com/avchavan/01eb6e46e00dc86708d0

Dependency fragment:

<dependency>
        <groupId>com.affecto</groupId>
        <artifactId>bolib-web</artifactId>
        <version>0.1.6</version>
    </dependency>

I have tried deleting the entire .m2 but still the same. The jar file opens properly and i can see the contents of it. So that doesn't look like an issue to me. Also, there are no html pages inside the jar (java files only). When i open the jar i can see that the jar was made using maven as its carrying a pom file. What could be the problem here?

Thanks.

avinash chavan
  • 729
  • 2
  • 11
  • 27
  • Have you looked at this? [Maven : error in opening zip file when running maven](http://stackoverflow.com/questions/7600028/maven-error-in-opening-zip-file-when-running-maven) – Ascalonian Jan 22 '15 at 13:30
  • Why the file is placed directly in the "repository" dir. Normally it's placed somewhere like .m2\repository\com\google\code\gson\gson\2.3\gson-2.3.jar – StanislavL Jan 22 '15 at 13:37
  • The maven path does look incorrect as there is usually organization/version/artifact path. Try running `mvn -X`. Also how did you **install** the jar. Did you run `mvn install`? Or did you just copy the jar (which will not work). – Adam Gent Jan 22 '15 at 13:41
  • @StanislavL its already inside .m2 folder (D:\proj\.m2\repository\com\affecto\bolib-web\0.1.6\bolib-web-0.1.6.jar). – avinash chavan Jan 22 '15 at 13:41
  • @AdamGent yes, used mvn install (mvn install:install-file -DgroupId=com.affecto -DartifactId=bolib-web -Dversion=0.1.6 -Dpackaging=jar -Dfile=D:/BOProj/JavaLibFiles/bolib-web-0.1.6.jar). Edited the path in the question. – avinash chavan Jan 22 '15 at 13:43
  • Can't it be access rights problem? E.g. you have no permission to access the dir from the build. – StanislavL Jan 22 '15 at 13:46
  • @avinashchavan so is the path in your written question incorrect? If you install bolib-web it would reside in something like `D:\projects\.m2\com\affecto\bolib-web` and not `projb.jar` path you have in your question. Second show us the `` xml fragment you have referring to bolib. – Adam Gent Jan 22 '15 at 13:48
  • @AdamGent I have updated the path in my question. and fragment added in question itself now for everyone. – avinash chavan Jan 22 '15 at 13:49
  • @avinashchavan yes now run mvn -X install or mvn -X compile so that we can see the actual IOException. Paste the exception (the output) in your question. – Adam Gent Jan 22 '15 at 13:51
  • @AdamGent added error trace to question. used mvn clean install -X command. – avinash chavan Jan 22 '15 at 13:54
  • @StanislavL i dont feel that should be the problem. as there are other libraries which i have installed in the same way. – avinash chavan Jan 22 '15 at 13:56
  • what happened if you generate manually bolib-web-0.1.6.jar directly from you IDE and replace the existing one manually in D:\proj\.m2\repository\com\affecto\bolib-web\0.1.6\? – vincent Jan 22 '15 at 13:56
  • @avinashchavan You may have to paste the entire output somewhere as I need to see if mvn logs the IOException (which would happen before the build fails). Considering the output might be incredibly long please paste the output on gist.github.com or pastebin and then provide a link. – Adam Gent Jan 22 '15 at 13:58
  • @vincent I do not have the code for that. only jar is available. which was part of the war file which is working in production setup (jar is copied from there itself). – avinash chavan Jan 22 '15 at 13:59
  • @AdamGent added link to build log in question (https://gist.github.com/avchavan/01eb6e46e00dc86708d0). – avinash chavan Jan 22 '15 at 14:12

1 Answers1

0

After looking at your maven output and not really finding much wrong I can really only conclude that this is either Windows file permission issue or a Windows file lock issue.

For Windows file permission:

I recommend you try running everything as "the" Administrator or remove/add permissions recursively to the .m2 so that all users can read and write just to see if that is the issue. (I believe and its been a while for me on windows but you right click on the Command Icon and select Run As Administrator).

For Windows file lock issues:

You could have a stale process still writing/reading that has a lock on the file. I have noticed this actually happens quite frequently on windows. The easiest solution is just to reboot but there are some programs to find and remove file locks.

Adam Gent
  • 47,843
  • 23
  • 153
  • 203