maven 使用jetty启动项目报错 Duplicate fragment name:

原创
2014/08/28 22:41
阅读数 3.3K
java.lang.IllegalStateException: Duplicate fragment name: spring_web for jar:file:/Users/zhoukai/.m2/repository/org/springframework/spring-web/3.2.2.RELEASE/spring-web-3.2.2.RELEASE.jar!/META-INF/web-fragment.xml and jar:file:/Users/zhoukai/develp/temp/webinf/WEB-INF/lib/spring-web-3.2.2.RELEASE.jar!/META-INF/web-fragment.xml
	at org.eclipse.jetty.webapp.MetaData.addFragment(MetaData.java:244)
	at org.eclipse.jetty.webapp.FragmentConfiguration.findWebFragments(FragmentConfiguration.java:72)
	at org.eclipse.jetty.webapp.FragmentConfiguration.preConfigure(FragmentConfiguration.java:39)
	at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:465)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:495)
	at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:180)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
	at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:226)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:164)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
	at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:226)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
	at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:93)
	at org.eclipse.jetty.server.Server.doStart(Server.java:243)
	at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
	at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:447)
	at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:387)
	at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:586)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	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.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
	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:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:46)

看似这个问题是包冲突,不过确实是包冲突了..原因是我在maven项目引用了其他war文件,在启动的时候可以看到

[INFO] Adding overlay: jar:file:/Users/zhoukai/.m2/repository/joker/good/custom/ExceptionHandler-Model/0.0.1/ExceptionHandler-Model-0.0.1.war!/

[INFO] Copying WEB-INF/lib jar:file:/Users/zhoukai/.m2/repository/joker/good/custom/ExceptionHandler-Model/0.0.1/ExceptionHandler-Model-0.0.1.war!/WEB-INF/lib/ to /Users/zhoukai/develp/temp/webinf/WEB-INF/lib

[INFO] Copying WEB-INF/classes from [file:/Users/zhoukai/Documents/myWorkspace/Permission-Model/src/main/webapp/WEB-INF/classes/, jar:file:/Users/zhoukai/.m2/repository/joker/good/custom/ExceptionHandler-Model/0.0.1/ExceptionHandler-Model-0.0.1.war!/WEB-INF/classes/] to /Users/zhoukai/develp/temp/webinf/WEB-INF/classes

在使用Overlay整合两个war的时候会将lib copy到jetty的临时文件夹下.所以导致启动的时候jar冲突了

解决方案:

jetty-maven-plugin插件配置上 <webAppConfig>下增加

<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>标签就好了

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部