春にreasteasyとjax-rsを使用してRESTAPIを作成したいと思います。これを行うには、次の行が私のアプリケーションコンテキストの一部です。
<bean id="RESTeasyProviderFactory" class="org.springframework.web.context.support.ServletContextAttributeFactoryBean">
<property name="attributeName" value="org.jboss.resteasy.spi.ResteasyProviderFactory" />
</bean>
<bean id="RESTeasyRegistry" class="org.springframework.web.context.support.ServletContextAttributeFactoryBean">
<property name="attributeName" value="org.jboss.resteasy.spi.Registry" />
</bean>
<bean id="RESTeasyBeanPostProcessor" class="org.jboss.resteasy.plugins.spring.SpringBeanProcessor">
<constructor-arg>
<bean class="org.jboss.resteasy.core.AsynchronousDispatcher">
<constructor-arg ref="RESTeasyProviderFactory" />
</bean>
</constructor-arg>
<constructor-arg ref="RESTeasyRegistry" />
<constructor-arg ref="RESTeasyProviderFactory" />
</bean>
コンポーネントスキャン中に、これにより、最初のRESTインターフェイスBeanが見つかったときにコンポーネントスキャン中にnpeが発生しました。
Caused by: java.lang.NullPointerException
at org.jboss.resteasy.plugins.spring.SpringBeanProcessor$ResteasyBeanPostProcessor.getInjector(SpringBeanProcessor.java:133)
at org.jboss.resteasy.plugins.spring.SpringBeanProcessor$ResteasyBeanPostProcessor.postProcessAfterInitialization(SpringBeanProcessor.java:125)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1461)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 11 more
デバッガーは、resteasyregistryBeanとresteasyproviderfactoryBeanの両方がnullとして解決されることを示します。
誰かがこれがどのように起こり得るかを説明できますか?テストとして、レジストリとファクトリがプロパティとして設定されるようにxmlを変更しましたが、セッターが呼び出された場合でも、レジストリとファクトリはnullになります。
* EDIT2:春のデバッグログ*
ここでは、春のデバッグログの関連部分を示します。
2012-06-01 12:13:34,337 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'RESTeasyBeanPostProcessor'
2012-06-01 12:13:34,337 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'RESTeasyBeanPostProcessor'
2012-06-01 12:13:34,337 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'org.jboss.resteasy.core.AsynchronousDispatcher#e0380'
2012-06-01 12:13:34,340 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'RESTeasyProviderFactory'
2012-06-01 12:13:34,340 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'RESTeasyProviderFactory'
2012-06-01 12:13:34,340 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'RESTeasyProviderFactory' to allow for resolving potential circular references
2012-06-01 12:13:34,350 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'RESTeasyProviderFactory'
2012-06-01 12:13:34,386 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'org.jboss.resteasy.core.AsynchronousDispatcher#e0380'
2012-06-01 12:13:34,386 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'RESTeasyRegistry'
2012-06-01 12:13:34,386 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'RESTeasyRegistry'
2012-06-01 12:13:34,386 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'RESTeasyRegistry' to allow for resolving potential circular references
2012-06-01 12:13:34,386 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'RESTeasyRegistry'
2012-06-01 12:13:34,389 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'RESTeasyProviderFactory'
2012-06-01 12:13:34,393 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'RESTeasyBeanPostProcessor' to allow for resolving potential circular references
2012-06-01 12:13:34,393 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'RESTeasyBeanPostProcessor'