2014-03-28 34 views
1

我已經閱讀了關於此問題的所有其他SO帖子,但沒有一個處理駱駝和applicationContext.xml。因爲我一直在試圖弄清楚這個問題已經超過了一個星期了,所以我的智慧已經結束了。無法通過eclipse找到XML模式命名空間的Spring NamespaceHandler [http://camel.apache.org/schema/spring]

問題:我可以通過Tomcat 6運行我的GWT應用程序。但只要我試圖通過使用Eclipse運行方式的Web應用程序來執行它,我收到此輸出到控制檯:

[WARN] Server class 'org.springframework.web.context.ContextLoaderListener' could not be found in the web app, but was found on the system classpath 
    [WARN] Adding classpath entry 'file:/C:/company/m2/repo/org/springframework/spring-web/2.5.6/spring-web-2.5.6.jar' to the web app classpath for this session 
[WARN] Server resource 'log4j.properties' could not be found in the web app, but was found on the system classpath 
    [WARN] Adding classpath entry 'file:/C:/company/projects/svn/reco/services/portal/trunk/portal-trunk/portal-um/src/test/resources/' to the web app classpath for this session 
[WARN] Server class 'com.company.session.PortalSessionListener' could not be found in the web app, but was found on the system classpath 
    [WARN] Adding classpath entry 'file:/C:/company/m2/repo/serviceUtil/serviceUtil/trunk/serviceUtil-trunk.jar' to the web app classpath for this session 
[WARN] Server class 'org.springframework.context.ApplicationContextException' could not be found in the web app, but was found on the system classpath 
    [WARN] Adding classpath entry 'file:/C:/company/m2/repo/org/springframework/spring-context/2.5.6/spring-context-2.5.6.jar' to the web app classpath for this session 
[WARN] Server class 'org.springframework.beans.FatalBeanException' could not be found in the web app, but was found on the system classpath 
    [WARN] Adding classpath entry 'file:/C:/company/m2/repo/org/springframework/spring-beans/2.5.6/spring-beans-2.5.6.jar' to the web app classpath for this session 
[WARN] Server class 'org.springframework.core.NestedRuntimeException' could not be found in the web app, but was found on the system classpath 
    [WARN] Adding classpath entry 'file:/C:/company/m2/repo/org/springframework/spring-core/2.5.6/spring-core-2.5.6.jar' to the web app classpath for this session 
[WARN] Server class 'org.apache.commons.collections.map.CaseInsensitiveMap' could not be found in the web app, but was found on the system classpath 
    [WARN] Adding classpath entry 'file:/C:/company/m2/repo/com/google/gwt/gwt-dev/2.4.0/gwt-dev-2.4.0.jar' to the web app classpath for this session 
Starting Jetty on port 8888 
    [WARN] Failed startup of context com.g[email protected]192232de{/,C:\company\projects\svn\reco\services\portal\trunk\portal-trunk\portal-entrypoint\target\portal-entrypoint-trunk} 
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://camel.apache.org/schema/spring] 
Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml] 

    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) 
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) 
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80) 
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:281) 
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1294) 
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287) 
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135) 
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310) 
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) 
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) 
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) 
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) 
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92) 
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) 
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) 
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) 
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) 
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) 
    at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:543) 
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:136) 
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220) 
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513) 
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448) 
    at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:468) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) 
    at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) 
    at org.mortbay.jetty.Server.doStart(Server.java:222) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672) 
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509) 
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068) 
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811) 
    at com.google.gwt.dev.DevMode.main(DevMode.java:311) 

我不知道本作的什麼也不做任何我的同事。我也不知道在這篇文章中包含哪些其他信息。

回答

0

忘記更新我的解決方案。原來,在我的項目屬性Google > Web Application下,War Directory:沒有正確指向我的WAR目錄。我將它改爲指向target/ROOT,現在一切正常。

0

它看起來像你的eclipse「作爲web應用程序運行」設置使用Jetty而不是tomcat,並以某種方式導致不同的類路徑配置。從它的外觀你可能會錯過碼頭上的一些罐子(駱駝相關)。

這通常發生在您不使用像maven這樣的依賴關係管理的情況下,即:您必須有意識地管理哪些路徑是/未包含在您的類路徑中的哪個環境。

更簡單的方法是在生產和開發中使用相同的容器,並通過在maven pom中聲明,確保您需要的附加jar包含在WEB-INF/lib中。

+0

我正在使用Maven。我真的不知道你的意思是「在生產和開發中使用同一個容器」我需要的所有東西都應該在pom中聲明,我的團隊中的其他開發人員這樣工作很好,所以它必須是我的東西設置,而不是pom。 – snowe

+0

順便說一下,我認爲http://camel.apache.org/schema/spring不是來自春駱駝罐,而是實際的駱駝罐。你有沒有仔細檢查過你在類路徑中是否真的有這個? – gerrytan

0

在開發模式下從Eclipse運行GWT應用程序時,它使用調試配置中定義的類路徑。這是您用於編譯的代碼以及您手動添加的其他任何jar或文件夾的構建路徑。另外,因爲它是一個web應用程序,它也將使用WEB-INF/lib文件夾中的任何jar。

當你得到的消息

[WARN]服務器類 「org.springframework.web.context.ContextLoaderListener」無法在Web應用程序來 發現,但在系統類路徑中發現[ WARN] 將類路徑條目 'file:/ C:/company/m2/repo/org/springframework/spring-web/2.5.6/spring-web-2.5.6.jar' 添加到Web應用程序類路徑中session

那麼這意味着代碼c不應該在WEB-INF/lib文件夾中找到,而是在調試配置定義的類路徑中找到。 GWT開發模式會將此jar添加到正在運行的Web應用程序類路徑中。

通常,這一切都可以正常工作,但是如果您的代碼依賴於使用某種類路徑搜索機制動態查找的類,則此過程不起作用。這就是發生了什麼 - 命名空間處理程序和相關模式將位於駱駝jar中,但這不在您的類路徑中。

答案很簡單 - 只需將包含名稱空間處理程序的jar添加到WEB-INF/lib文件夾即可。

我有這個問題很多 - 主要是與春天,但也是RSS庫羅馬。我的項目是使用Maven構建的並且用於管理這個我已經使用devmode配置文件來配置Maven,該配置文件包含我需要的所有運行時依賴項,並將目標將所有依賴項複製到WEB-INF/lib文件夾中。這意味着我可以管理Maven的所有依賴項 - 在共享項目時非常有用。

+0

在WEB-INF/lib文件夾中,camel-spring-2.0-M3.jar **爲**:( – snowe

+0

另外,我似乎有幾個WEB-INF文件夾,其中一個位於'portal-entrypoint/src/main/webapp/WEB-INF',但是沒有lib文件夾,然後在'portal-entrypoint/target/ROOT/WEB-INF'中有一個文件夾,並且該文件夾包含一個deploy和lib文件夾以及一個ton最後在'portal-entrypoint/target/portal-entrypoint-trunk/WEB-INF'上有一個,但只有類和部署文件夾,沒有lib文件夾,所有這些位置都包含一個'applicationContext。 xml'和'web.xml'文件 – snowe

+0

GWT Eclipse插件使用在'Project Properties> Google> Web Application'中配置的war目錄,你會發現它使用在dev模式下的WEB-INF/lib文件夾。這就是你需要放置包含命名空間處理程序和模式的jar的地方,Maven可能會有點複雜,請參閱http: //mojo.codehaus.org/gwt-maven-plugin/user-guide/war-folder.html。 – pauli

相關問題