0

我不明白当我在 tomcat 中启动我的 web 服务时,有时会得到这个空指针异常。并且需要 3-4 次重新启动,然后这个异常就消失了。这是什么原因?我的堆栈跟踪是:

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>
4

1 回答 1

0

为什么不使用 cxfbeans?

看这个:

http://camelandjava.blogspot.com/2012/05/rest-service-in-camel-using-cxf-and.html

于 2012-05-15T01:28:24.537 回答