在一个maven工程中,有时执行mvn打包,部署,编译等命令,例如mvn clean install -DskipTests -U等命令时,会报类似(error in opening zip file)的Exception,例如在我的其中一个项目中,就报了如下的两个Exception

第一个Exception:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
3.2:compile (default-compile) on project validator-rest: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] 错误:读取 c:\maven-repo\swang\ebox\org\hibernate\hibernate-entitymanage
r\4.2.4.Final\hibernate-entitymanager-4.2.4.Final.jar 时出错;error in opening z
ip file
[ERROR] 1 错误
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on
project validator-rest: Compilation failure
Failure executing javac, but could not parse the error:
错误:读取 c:\maven-repo\swang\ebox\org\hibernate\hibernate-entitymanager\4.2.4.
Final\hibernate-entitymanager-4.2.4.Final.jar 时出错;error in opening zip file
1 错误

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
Failure
executing javac, but could not parse the error:错误:读取
c:\maven-repo\swang\ebox\org\hibernate\hibernate-entitymanager\4.2.4.Final\hibernate-entitymanager-4.2.4.Final.jar
时出错;error in opening zip file1 错误 at
org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompiler
Mojo.java:656)

at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209) ... 19 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :validator-rest

解决方案:在maven的pom 文件中,加入如下的dependency,就解决了该问题:

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>

第二个Exception:

[WARNING] POM for 'javax.jms:jms:pom:1.1:compile' is invalid.

Its dependencies (if any) will NOT be available to the current build.
[WARNING] POM for 'com.sun.jdmk:jmxtools:pom:1.2.1:compile' is invalid.

Its dependencies (if any) will NOT be available to the current build.
[WARNING] POM for 'com.sun.jmx:jmxri:pom:1.2.1:compile' is invalid.

...

Failure executing javac, but could not parse theerror:
错误:读取 F:\.m2\repository\javax\jms\jms\1.1\jms-1.1.jar 时出错;errorinopeningzipfile
错误:读取 F:\.m2\repository\com\sun\jdmk\jmxtools\1.2.1\jmxtools-1.2.1.jar 时出错;errorinopeningzipfile
错误:读取 F:\.m2\repository\com\sun\jmx\jmxri\1.2.1\jmxri-1.2.1.jar 时出错;errorinopeingzipfile
3 错误

这个问题的解决方案还是修改pom.xml,将 log4j 的版本从1.2.15改成1.2.14。

总结:该类问题一般都是因为jar包的冲突,或者jar包的依赖引起来的,所以碰到这类Error时,可以从这个方向入手。

原文:http://www.c内s容d违n禁123.com/html/blogs/20130829/61031.htm

最新文章

  1. Git 账户认证的一些问题
  2. Myeclipse Templates详解(一) —— Java模板基础
  3. jeasyui datagrid 使用记
  4. duilib -- Label控件的bug(转载)
  5. TreeView控件
  6. Linux共享内存
  7. 动手写一个快速集成网易新闻,腾讯视频,头条首页的ScrollPageView,显示滚动视图
  8. 贪吃蛇AI
  9. dell服务器各类raid 和磁盘在阵列卡上的实验
  10. Kali-linux安装之后的简单设置--转载
  11. Java面试准备之探究集合
  12. gem install报错
  13. Python 3.6.3 利用 Dlib 19.7 和 opencv 实现人脸68点定位 进行人脸识别
  14. 3款网页jQuery抽奖实例演示
  15. java调用第三方的webservice应用实例
  16. 构建你自己的论坛,基于windows服务器的xampp+discuz论坛
  17. 清理parallels desktop 卸载后的图标残留
  18. 微信小程序 --- for循环渲染
  19. HTTP报文语法/HTTP组成
  20. UITextView 光标定位

热门文章

  1. Sqlite 教程
  2. 新建module---获取带宽信息
  3. jquery验证前端页面
  4. IBM Security AppScan Standard WEB扫描工具
  5. Centos7下zabbix部署(五)定义报警媒介-微信
  6. iOS手势UIGestureRecognizer的使用失效问题
  7. (3)Oracle提供的.net连接驱动
  8. 洛谷——P1147 连续自然数和
  9. Bean装配--xml
  10. Chrome的开发必备小技巧