2012-01-22 51 views
1

我和我的團隊正在嘗試設置一個Spring項目,並希望實施REST服務。但是當我嘗試將它部署到tomcat 7時,出現錯誤。這裏是輸出:如何正確配置這個Spring項目?

Jan 22, 2012 9:39:34 PM 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: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 
Jan 22, 2012 9:39:34 PM org.apache.tomcat.util.digester.SetPropertiesRule begin 
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:niths' did not find a matching property. 
Jan 22, 2012 9:39:34 PM org.apache.coyote.AbstractProtocol init 
INFO: Initializing ProtocolHandler ["http-bio-8080"] 
Jan 22, 2012 9:39:34 PM org.apache.coyote.AbstractProtocol init 
INFO: Initializing ProtocolHandler ["ajp-bio-8009"] 
Jan 22, 2012 9:39:34 PM org.apache.catalina.startup.Catalina load 
INFO: Initialization processed in 497 ms 
Jan 22, 2012 9:39:34 PM org.apache.catalina.core.StandardService startInternal 
INFO: Starting service Catalina 
Jan 22, 2012 9:39:34 PM org.apache.catalina.core.StandardEngine startInternal 
INFO: Starting Servlet Engine: Apache Tomcat/7.0.25 
Jan 22, 2012 9:39:34 PM org.apache.catalina.startup.ContextConfig webConfig 
SEVERE: Unable to determine URL for WEB-INF/classes 
javax.naming.NameNotFoundException: Resource /WEB-INF/classes not found 
    at org.apache.naming.resources.BaseDirContext.listBindings(BaseDirContext.java:733) 
    at org.apache.naming.resources.ProxyDirContext.listBindings(ProxyDirContext.java:546) 
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1197) 
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:825) 
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:300) 
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5161) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1568) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1558) 
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:166) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 
    at java.lang.Thread.run(Thread.java:722) 

Jan 22, 2012 9:39:37 PM org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplicationInitializer types detected on classpath 
Jan 22, 2012 9:39:37 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["http-bio-8080"] 
Jan 22, 2012 9:39:37 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["ajp-bio-8009"] 
Jan 22, 2012 9:39:37 PM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 3208 ms 

我試過谷歌搜索javax.naming.NameNotFoundException: Resource /WEB-INF/classes not found沒有運氣。我猜測該項目根本沒有部署。

該項目託管在this GitHub repo

我添加了一個非常簡單的方法來測試我的應用程序:getBaz(),我猜將在localhost:8080/niths/rest/baz被調用。

由於這是我的第一個Spring項目,我很難弄清楚缺少什麼,因此,如果有熟練的Spring專家會指出什麼是問題,我會很感激!

+1

您是如何將它部署到Tomcat中的,只需將.war文件放入?我使用maven碼頭插件來運行它 - org.mortbay.jetty jetty-maven-plugin在pom.xml和mvn中jetty:run - 並且它似乎加載正常。 –

+0

謝謝!這部署了應用程序,你是否有機會讓所謂的REST服務起作用? – whirlwin

回答

2

從你的pom.xml文件,看來你從生成戰爭排除類和庫:

<warSourceExcludes>WEB-INF/classes/**,WEB-INF/lib/**</warSourceExcludes> 

通過刪除這一行再試一次。

+0

即使在完全刪除項目,重新下載項目並再次嘗試之後,它仍會顯示「javax.naming.NameNotFoundException:Resource/WEB-INF/classes not found」。 – whirlwin

+0

您正在觀察的錯誤似乎是Tomcat 7.0.25 [問題52511](https://issues.apache.org/bugzilla/show_bug.cgi?id=52511)中的一個問題。通過[這個答案]找到(http://stackoverflow.com/a/9261392/12039)。 – Kariem