2012-11-15 59 views
2

我有一個Maven項目,我在Eclipse中使用Tomcat 7進行調試。 問題是,當我在pom.xml文件中做了最小的改變時,例如更改Maven插件的版本或添加配置屬性,服務器無法正常啓動。我改變的並不重要。 當我使用「調試爲」啓動服務器時,Apache Click和Shiro不再啓動,訪問本地主機導致Tomcat發出404消息。 有趣的是,即使我撤銷了更改,問題仍然存在。唯一有用的是GIT - >替換爲整個項目的命令。Eclipse:Maven - >更新項目導致Eclipse - > Tomcat 7開始問題

編輯:我發現,即使我沒有改變任何東西在pom.xml中,只是運行Maven - >更新項目我有問題。

這裏是改變前的日誌文件時一切正常:

Nov 15, 2012 10:28:10 AM org.apache.catalina.core.AprLifecycleListener init 
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Java\jdk1.7.0\jre\bin;C:/Program Files/Java/jdk1.7.0/bin/../jre/bin/client;C:/Program Files/Java/jdk1.7.0/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0/bin/../jre/lib/i386;C:\Program Files\Java\jdk1.7.0\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\apache-maven-3.0.4\bin;C:\Program Files\Java\jdk1.7.0\bin;C:\Program Files\Eclipse JEE Indigo;;. 
Nov 15, 2012 10:28:12 AM org.apache.tomcat.util.digester.SetPropertiesRule begin 
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:testproject' did not find a matching property. 
Nov 15, 2012 10:28:12 AM org.apache.coyote.AbstractProtocolHandler init 
INFO: Initializing ProtocolHandler ["http-bio-8080"] 
Nov 15, 2012 10:28:12 AM org.apache.coyote.AbstractProtocolHandler init 
INFO: Initializing ProtocolHandler ["ajp-bio-8009"] 
Nov 15, 2012 10:28:12 AM org.apache.catalina.startup.Catalina load 
INFO: Initialization processed in 2201 ms 
Nov 15, 2012 10:28:12 AM org.apache.catalina.core.StandardService startInternal 
INFO: Starting service Catalina 
Nov 15, 2012 10:28:12 AM org.apache.catalina.core.StandardEngine startInternal 
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12 
Nov 15, 2012 10:28:13 AM org.apache.catalina.loader.WebappClassLoader validateJarFile 
INFO: validateJarFile(D:\Data\Programming\Eclipse Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\testproject\WEB-INF\lib\servlet-api-1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class 
Nov 15, 2012 10:28:13 AM org.apache.catalina.loader.WebappClassLoader validateJarFile 
INFO: validateJarFile(D:\Data\Programming\Eclipse Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\testproject\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class 
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
SLF4J: Defaulting to no-operation (NOP) logger implementation 
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
Nov 15, 2012 10:28:13 AM org.apache.catalina.core.ApplicationContext log 
INFO: Initializing Shiro environment 
[Click] [info ] *** Initializing Click 2.3.0 in development mode *** 
[Click] [info ] initialized LogService: org.apache.click.service.ConsoleLogService 
[Click] [info ] found jar: file:/D:/Data/Programming/Eclipse%20Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/testproject/WEB-INF/lib/click-nodeps-2.3.0.jar 
[Click] [info ] Click 2.3.0 initialized in development mode 
Nov 15, 2012 10:28:14 AM org.apache.coyote.AbstractProtocolHandler start 
INFO: Starting ProtocolHandler ["http-bio-8080"] 
Nov 15, 2012 10:28:14 AM org.apache.coyote.AbstractProtocolHandler start 
INFO: Starting ProtocolHandler ["ajp-bio-8009"] 
Nov 15, 2012 10:28:14 AM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 2076 ms 
[Click] [info ] handleRequest: /index.htm - 57 ms 

這是變化最小的POM文件之後日誌:

Nov 15, 2012 10:25:23 AM org.apache.catalina.core.AprLifecycleListener init 
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Java\jdk1.7.0\jre\bin;C:/Program Files/Java/jdk1.7.0/bin/../jre/bin/client;C:/Program Files/Java/jdk1.7.0/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0/bin/../jre/lib/i386;C:\Program Files\Java\jdk1.7.0\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\apache-maven-3.0.4\bin;C:\Program Files\Java\jdk1.7.0\bin;C:\Program Files\Eclipse JEE Indigo;;. 
Nov 15, 2012 10:25:24 AM org.apache.tomcat.util.digester.SetPropertiesRule begin 
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:testproject' did not find a matching property. 
Nov 15, 2012 10:25:24 AM org.apache.coyote.AbstractProtocolHandler init 
INFO: Initializing ProtocolHandler ["http-bio-8080"] 
Nov 15, 2012 10:25:24 AM org.apache.coyote.AbstractProtocolHandler init 
INFO: Initializing ProtocolHandler ["ajp-bio-8009"] 
Nov 15, 2012 10:25:24 AM org.apache.catalina.startup.Catalina load 
INFO: Initialization processed in 570 ms 
Nov 15, 2012 10:25:24 AM org.apache.catalina.core.StandardService startInternal 
INFO: Starting service Catalina 
Nov 15, 2012 10:25:24 AM org.apache.catalina.core.StandardEngine startInternal 
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12 
Nov 15, 2012 10:25:39 AM org.apache.coyote.AbstractProtocolHandler start 
INFO: Starting ProtocolHandler ["http-bio-8080"] 
Nov 15, 2012 10:25:39 AM org.apache.coyote.AbstractProtocolHandler start 
INFO: Starting ProtocolHandler ["ajp-bio-8009"] 
Nov 15, 2012 10:25:39 AM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 14905 ms 

可有人給我解釋一下這裏發生了什麼?我很感謝任何提示!

+0

你可以在兩個版本上執行差異嗎? –

+0

什麼是差異?當我運行Maven - > Update Project時,我發現問題在於Maven覆蓋了一些配置。請參閱http://stackoverflow.com/questions/13397202/eclipse-change-webapp-folder-in-maven-pom-xml-file – gizmodus

+0

在計算中,diff是一個文件比較實用程序,用於輸出兩個文件之間的差異。它通常用於顯示文件的一個版本和同一文件的以前版本之間的變化(來源:http://en.wikipedia.org/wiki/Diff)。使用它你會看到配置文件被改變了。 –

回答

0

我在Maven中使用Tomcat6,並且在Eclipse上有類似的問題。 有時候看起來像Tomcat,並且完全不用我配置的項目。

當這件事情發生時,我嘗試這個步驟,總是測試如果其中一個已經解決了我的問題。

  1. 的Maven - >項目更新
  2. F5以上的項目(ussualy工作在這一點上)
  3. 清潔Tomcat的
  4. 清理項目(項目>清潔)
  5. 刪除項目(右按鈕在服務器上>添加和刪除),保存並再次添加。

這是怎麼回事server.xml?它是你的項目一個Web應用程序?

不幸的是,我不知道爲什麼會出現這種問題,但它看起來更像是Tomcat的緩存問題,然後是Maven。無論如何,這是一個每天都需要我很多時間的問題。