如果打包在* .war文件中,Switchyard服务不起作用

时间:2014-09-22 13:06:52

标签: java web-services jboss

据我所知,Switchyard项目可以作为war和jar部署。但对我来说,jar文件工作得很好,而战争却没有。 我做了什么: 1.通常做项目,界面和实施。 2.将switchyard.xml和beans.xml从src / main / META-INF移动到src / main / webapp / WEB-INF 3.将<artifactId>adapter</artifactId>添加到pom.xml 4.建立战争和部署。 文件已成功部署,但在通过Postman调用方法时出现以下错误。怎么解决?

Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.RequestScoped
    at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:590) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]
    at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:71) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]
    at my.projectadapter.sy.AdapterServiceImpl$Proxy$_$$_WeldClientProxy.getTest(AdapterServiceImpl$Proxy$_$$_WeldClientProxy.java) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_60]
    at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_60]
    at org.switchyard.component.bean.ServiceProxyHandler.handle(ServiceProxyHandler.java:163) [switchyard-component-bean-1.1.0.Final.jar:1.1.0.Final]
    at org.switchyard.component.bean.ServiceProxyHandler.handleMessage(ServiceProxyHandler.java:94) [switchyard-component-bean-1.1.0.Final.jar:1.1.0.Final]
    at org.switchyard.bus.camel.processors.ProviderProcessor.process(ProviderProcessor.java:29) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.switchyard.bus.camel.audit.FaultProcessor.process(FaultProcessor.java:46) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]
    at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:117) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:104) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:78) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.switchyard.bus.camel.audit.FaultProcessor.process(FaultProcessor.java:46) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]
    at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:122) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:360) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:331) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:227) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:331) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:153) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:106) [camel-core-2.10.0.jar:2.10.0]
    at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:92) [camel-core-2.10.0.jar:2.10.0]
    at org.switchyard.bus.camel.ExchangeDispatcher.dispatch(ExchangeDispatcher.java:87) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]
    at org.switchyard.bus.camel.CamelExchange.sendInternal(CamelExchange.java:234) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]
    at org.switchyard.bus.camel.CamelExchange.send(CamelExchange.java:171) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]
    at org.switchyard.component.resteasy.InboundHandler.invoke(InboundHandler.java:116) [switchyard-component-resteasy-1.1.0.Final.jar:1.1.0.Final]
    ... 29 more

1 个答案:

答案 0 :(得分:1)

我找到了答案 here。 问题在于CDI和JAX-RS注释。我所做的就是:在没有注释的情况下创建额外的接口,这些注释将在bean类中实现并修改bean类。此外,带注释的单独REST接口应反映在switchyard.xml文件中:

<resteasy:interfaces>your.interface.with.all.jax-rs.annotations</resteasy:interfaces>