jboss にデプロイされている CXF Web サービスに Spring Bean が挿入されない理由がわかりません。シナリオは次のとおりです。
インターフェイスを実装する複数の Service クラスがあります
これが実装#1です
@Service("retrieveService")
@Scope("prototype")
@Transactional(propagation=Propagation.REQUIRED)
public class RetrieveService extends BaseService implements IEuclidService
{
@Resource
private EntrLoanRepository entrLoanRepository;
@Override
public RetrieveResponse serve(RequestMessage request)
{
entrLoanRepository.findByEntrLoanId();
}
}
これが実装#2です
@Service("disableService")
@Scope("prototype")
@Transactional(propagation=Propagation.REQUIRED)
public class DisableService extends BaseService implements IEuclidService
{
@Resource
private EntrLoanRepository entrLoanRepository;
@Override
public RetrieveResponse serve(RequestMessage request)
{
EntrLoan entrLoan = new EntrLoan();
entrLoan.setEndDate( new Date());
entrLoanRepository.save(entrLoan);
}
}
私は自分の cxf Web サービスを持っています。これには、Spring (サービス) Bean が注入されることを期待しています。
@javax.jws.WebService
public class Euclid implements IEuclid {
private IEuclidService euclidService
public MyResponse myMethod(MyRequest req)
{
<!-- How do I inject an instance of RetrieveService here ???-->
euclidService.serve();
}
}
私はこれをやってみました:
euclidService = ctx.getBean("retrieveService", RetrieveService.class);
しかし、エラーメッセージが表示されます:
com.sgb.euclid.contracts.RetrieveEnterpriseLnIdRequest@31d908
***1 EuclidService is NULL
*****Instantiating Spring Bean
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'retrieveService' must be of type [com.sgb.euclid.ws.service.RetrieveService], but was actually of type [$Proxy98]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:360)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1102)
at com.sgb.euclid.ws.web.Euclid.retrieve(Euclid.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.as.webservices.deployers.WSComponentInstanceAssociationInterceptor.processInvocation(WSComponentInstanceAssociationInterceptor.java:49)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
at org.jboss.as.webservices.invocation.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:111)
at org.jboss.wsf.stack.cxf.JBossWSInvoker.performInvocation(JBossWSInvoker.java:149)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:178)
at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:64)
at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:129)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:236)
at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:88)
at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:156)
at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:87)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:221)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:141)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:135)
at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:140)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:652)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:919)
at java.lang.Thread.run(Thread.java:662)
「type [$Proxy98]」が何なのかよくわかりません。ログを検索しましたが、どこから来ているのかわかりません。これは春に関係していると思いますか?? いずれにせよ、Bean が beans.xml で定義されているのではなく、注釈が付けられていることを念頭に置いて、Spring Bean をインスタンス化できないという私が間違っていることは何ですか。
何かが足りない気がしますが、指を置くことはできません。
jboss にデプロイしているため、構成 xml は、オンラインで見ている例とは少し異なります。ここに私の jboss-cxf.xml があります:
<jaxws:endpoint id="POJOEndpoint"
implementor="com.sgb.euclid.ws.web.Euclid"
wsdlLocation="WEB-INF/wsdl/EnterpriseLoanIdentifier.wsdl"
address="http://localhost:8080/euclid-ws">
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
<jaxws:invoker>
<bean class="org.jboss.wsf.stack.cxf.InvokerJSE" />
</jaxws:invoker>
</jaxws:endpoint>
そして、ここに applicationContext-ws.xml があります。
<import resource="applicationContext-core.xml" />
<import resource="applicationContext-jpa.xml" />
<!-- setting up packages to scan for components -->
<context:component-scan base-package="com.sgb.euclid.ws.service" />
<tx:annotation-driven
transaction-manager="transactionManager" />
対応する web.xml は次のとおりです。
<!-- setting up spring configuration to instantiate the spring container -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:META-INF/spring/applicationContext-ws.xml</param-value>
</context-param>
<servlet>
<servlet-name>euclid</servlet-name>
<servlet-class>com.sgb.euclid.ws.web.Euclid</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>euclid</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
私は自分の間違いが何であるかを理解できません。どんな助けでも大歓迎です....