2012-04-23 127 views
0

我不明白我有时候得到这个nullpointer异常,当我在tomcat中启动web服务时。它需要3-4重新启动,然后这个例外已经消失..这是什么原因?我的堆栈跟踪是:REST web服务与apche骆驼和cxf:启动时出现NullPointerException

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/Beans.xml]; nested exception is java.lang.NullPointerException 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) 
    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:93) 
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) 
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397) 
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) 
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) 
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) 
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4323) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4780) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139) 
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988) 
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:771) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139) 
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988) 
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139) 
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:427) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139) 
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:649) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139) 
    at org.apache.catalina.startup.Catalina.start(Catalina.java:585) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) 
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415) 

我的XML文件是:

<jaxrs:server id="restContainer" address="/" staticSubresourceResolution="true"> <jaxrs:serviceBeans> 
<ref bean="FooBar" /> 
</jaxrs:serviceBeans> 
<jaxrs:providers> 
<bean class="org.apache.cxf.jaxrs.provider.JSONProvider"> 
<property name="dropRootElement" value="true" /> 
<property name="supportUnwrapped" value="true" /> 
</jaxrs:providers> 
<camelcxf:rsServer id="rsServer" address="/" serviceClass="com.camel.example.FooBar" /> <camel:camelContext id="camelContext-1"> 
<camel:route> 
<camel:from uri="cxfrs:bean:rsServer" /> 
<camel:to uri="http://localhost:8080/Google/rest/search" /> 
</camel:route> 
</camel:camelContext> 
+0

哪个JDK版本您使用的?什么操作系统?你使用的是什么版本的Tomcat,Spring和Camel? – 2012-04-24 03:43:44

+0

JDK-1.6;操作系统 - Windows 7;雄猫-7.0;春天 - 3.0;骆驼 - 2.9.0,CXF - 2.5.2 – Sikorski 2012-04-24 05:24:50

回答