天天看點

Maven 2對于Jetty7的支援

Maven對于Jetty的插件在從6更新到7的時候有一個命名的變化,除了這個命名的變化,我發現這個插件運作Jetty還是有問題的。錯誤代碼如下:

C:\opensource\m2space\helloWebonJetty>mvn jetty:run
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building helloWebonJetty Maven Webapp
[INFO]    task-segment: [jetty:run]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing jetty:run
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\opensource\m2space\helloWebonJetty\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [jetty:run {execution: default-cli}]
[INFO] Configuring Jetty for project: helloWebonJetty Maven Webapp
[INFO] webAppSourceDirectory C:\opensource\m2space\helloWebonJetty\src\main\webapp does not exist. Defaulting to C:\opensource\m2space\hello
WebonJetty\src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = C:\opensource\m2space\helloWebonJetty\target\classes
[INFO] Context path = /
[INFO] Tmp directory = C:\opensource\m2space\helloWebonJetty\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = file:/C:/opensource/m2space/helloWebonJetty/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = C:\opensource\m2space\helloWebonJetty\src\main\webapp
[INFO] Starting jetty 7.1.6.v20100715 ...
2010-09-21 16:51:23.390:INFO::jetty-7.1.6.v20100715
2010-09-21 16:51:23.453:WARN::Failed startup of context [email protected]@159d510/,file:/C:/opensource/m2space/helloWebonJetty/src/
main/webapp/,file:/C:/opensource/m2space/helloWebonJetty/src/main/webapp/
java.net.URISyntaxException: Illegal character in path at index 18: file:/C:/Documents and Settings/e502316/.m2/repository/org/mortbay/jetty
/jetty-maven-plugin/7.1.6.v20100715/jetty-maven-plugin-7.1.6.v20100715.jar
        at java.net.URI$Parser.fail(URI.java:2809)
        at java.net.URI$Parser.checkChars(URI.java:2982)
        at java.net.URI$Parser.parseHierarchical(URI.java:3066)
        at java.net.URI$Parser.parse(URI.java:3014)
        at java.net.URI.<init>(URI.java:578)
        at java.net.URL.toURI(URL.java:918)
        at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure(WebInfConfiguration.java:81)
        at org.mortbay.jetty.plugin.MavenWebInfConfiguration.preConfigure(MavenWebInfConfiguration.java:145)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:378)
        at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:114)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:162)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:92)
        at org.eclipse.jetty.server.Server.doStart(Server.java:242)
        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:437)
        at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:377)
        at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:577)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.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:60)
        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.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)
2010-09-21 16:51:23.656:INFO::Started [email protected]:8080
[INFO] Started Jetty Server
[INFO] Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 3 seconds
[INFO] Finished at: Tue Sep 21 16:52:20 CST 2010
Terminate batch job (Y/N)? y

C:\opensource\m2space\helloWebonJetty>
           

這個web應用在Jetty6.1.25上是可以運作的。 

google了一下,原來是個bug,不過沒有被處理,是因為classpath中有空格。

看來我需要更改一下Maven的預設的庫的位置了。

修改庫的位置的方法如下:

http://blogs.plexibus.com/2008/03/11/how-to-change-your-local-maven-repository/

繼續閱讀