You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Brad O'Hearne <br...@neurofire.com> on 2007/07/17 01:44:48 UTC

Cannot run more than one RESTful service

Hello,

I am having problems running more than one RESTful service, loaded via 
Spring. Without going into the nasties of how this was determined, with 
the help of a developer, it was determined that the present means of 
configuring a RESTful service with Spring was as follows (in my 
beans.xml file):

   <bean id="userService"
       class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
       init-method="create">
       <property name="serviceClass"
           value="com.brad.user.IUserService" />
       <property name="serviceBean">
           <bean class="com.brad.user.UserService" />
       </property>
       <property name="address" value="/UserService" />
       <property name="bindingId"
           value="http://apache.org/cxf/binding/http" />
       <property name="serviceFactory" ref="JaxWsServiceFactoryBean" />
   </bean>

This service, when configured as the only service in my beans.xml file, 
loads and is invoked successfully. But when I add a second service to my 
beans.xml, as follows:

   <bean id="sponsorService"
       class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
       init-method="create">
       <property name="serviceClass"
           value="com.brad.sponsor.ISponsorService" />
       <property name="serviceBean">
           <bean class="com.brad.sponsor.SponsorService" />
       </property>
       <property name="address" value="/SponsorService" />
       <property name="bindingId"
           value="http://apache.org/cxf/binding/http" />
       <property name="serviceFactory" ref="JaxWsServiceFactoryBean" />
   </bean>

When I deploy and start my server, on load I get no errors. But I also 
do not see this second service produce output in the server logs like 
the first one does. The first service, I see this in the logs:

INFO: Creating Service {http://user.brad.com/}IUserServiceService from 
class com.brad.user.IUserService

But I do not see this for my second (ISponsorService) service. When I 
try to invoke *either* service, CXF crashes. The stack trace is below. 
Does anyone have any idea how to configure and successfully run more 
than one RESTful service using Spring? Thanks in advance for help!!!

Brad

Stack trace, when trying to invoke the authenticate method on 
IUserService, that is known to work, with data known to work, when 2 
services are configured (this does not happen when only one service has 
been configured).

INFO: URIParameterInterceptor handle message on path [/authenticate] 
with content-type [application/xml]
Jul 16, 2007 4:11:03 PM org.apache.cxf.phase.PhaseInterceptorChain 
doIntercept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: object is not an instance of declaring 
class
    at 
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:88)
    at 
org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:82)
    at 
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:56)
    at 
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56)
    at 
org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
    at 
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:87)
    at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:206)
    at 
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:67)
    at 
org.apache.cxf.transport.servlet.ServletDestination.doMessage(ServletDestination.java:100)
    at 
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:224)
    at 
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:103)
    at 
org.apache.cxf.transport.servlet.CXFServlet.invoke(CXFServlet.java:261)
    at 
org.apache.cxf.transport.servlet.CXFServlet.doPost(CXFServlet.java:239)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:270)
    at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:191)
    at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:227)
    at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:211)
    at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:817)
    at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:623)
    at 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:444)
    at java.lang.Thread.run(Thread.java:595)




Brad


Re: Cannot run more than one RESTful service

Posted by Brad O'Hearne <br...@neurofire.com>.
Dan,

You are 100% correct. This solved the problem!  Thanks!

Brad

Dan Diephouse wrote:
> Hi Brad,
>
> The JaxWsServiceFactoryBean is not resusable across various services. Try
> embedding it inside your service definition:
>
> <property name="serviceFactory">
>  <bean class="....JaxWsServiceFactory">
> ...
> </bean>
> </property>
>
> Let me know if that helps!
>
> - Dan
>
> On 7/16/07, Brad O'Hearne <br...@neurofire.com> wrote:
>>
>> Hello,
>>
>> I am having problems running more than one RESTful service, loaded via
>> Spring. Without going into the nasties of how this was determined, with
>> the help of a developer, it was determined that the present means of
>> configuring a RESTful service with Spring was as follows (in my
>> beans.xml file):
>>
>>    <bean id="userService"
>>        class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
>>        init-method="create">
>>        <property name="serviceClass"
>>            value="com.brad.user.IUserService" />
>>        <property name="serviceBean">
>>            <bean class="com.brad.user.UserService" />
>>        </property>
>>        <property name="address" value="/UserService" />
>>        <property name="bindingId"
>>            value="http://apache.org/cxf/binding/http" />
>>        <property name="serviceFactory" ref="JaxWsServiceFactoryBean" />
>>    </bean>
>>
>> This service, when configured as the only service in my beans.xml file,
>> loads and is invoked successfully. But when I add a second service to my
>> beans.xml, as follows:
>>
>>    <bean id="sponsorService"
>>        class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
>>        init-method="create">
>>        <property name="serviceClass"
>>            value="com.brad.sponsor.ISponsorService" />
>>        <property name="serviceBean">
>>            <bean class="com.brad.sponsor.SponsorService" />
>>        </property>
>>        <property name="address" value="/SponsorService" />
>>        <property name="bindingId"
>>            value="http://apache.org/cxf/binding/http" />
>>        <property name="serviceFactory" ref="JaxWsServiceFactoryBean" />
>>    </bean>
>>
>> When I deploy and start my server, on load I get no errors. But I also
>> do not see this second service produce output in the server logs like
>> the first one does. The first service, I see this in the logs:
>>
>> INFO: Creating Service {http://user.brad.com/}IUserServiceService from
>> class com.brad.user.IUserService
>>
>> But I do not see this for my second (ISponsorService) service. When I
>> try to invoke *either* service, CXF crashes. The stack trace is below.
>> Does anyone have any idea how to configure and successfully run more
>> than one RESTful service using Spring? Thanks in advance for help!!!
>>
>> Brad
>>
>> Stack trace, when trying to invoke the authenticate method on
>> IUserService, that is known to work, with data known to work, when 2
>> services are configured (this does not happen when only one service has
>> been configured).
>>
>> INFO: URIParameterInterceptor handle message on path [/authenticate]
>> with content-type [application/xml]
>> Jul 16, 2007 4:11:03 PM org.apache.cxf.phase.PhaseInterceptorChain
>> doIntercept
>> INFO: Interceptor has thrown exception, unwinding now
>> org.apache.cxf.interceptor.Fault: object is not an instance of declaring
>> class
>>     at
>> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java 
>>
>> :88)
>>     at
>> org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:82) 
>>
>>     at
>> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java 
>>
>> :56)
>>     at
>> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(
>> ServiceInvokerInterceptor.java:56)
>>     at
>> org.apache.cxf.workqueue.SynchronousExecutor.execute(
>> SynchronousExecutor.java:37)
>>     at
>> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(
>> ServiceInvokerInterceptor.java:87)
>>     at
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
>> PhaseInterceptorChain.java:206)
>>     at
>> org.apache.cxf.transport.ChainInitiationObserver.onMessage(
>> ChainInitiationObserver.java:67)
>>     at
>> org.apache.cxf.transport.servlet.ServletDestination.doMessage(
>> ServletDestination.java:100)
>>     at
>> org.apache.cxf.transport.servlet.ServletController.invokeDestination(
>> ServletController.java:224)
>>     at
>> org.apache.cxf.transport.servlet.ServletController.invoke(
>> ServletController.java:103)
>>     at
>> org.apache.cxf.transport.servlet.CXFServlet.invoke(CXFServlet.java:261)
>>     at
>> org.apache.cxf.transport.servlet.CXFServlet.doPost(CXFServlet.java:239)
>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>     at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>> ApplicationFilterChain.java:270)
>>     at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(
>> ApplicationFilterChain.java:191)
>>     at
>> org.apache.catalina.core.StandardWrapperValve.invoke(
>> StandardWrapperValve.java:227)
>>     at
>> org.apache.catalina.core.StandardContextValve.invoke(
>> StandardContextValve.java:174)
>>     at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
>> :127)
>>     at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
>> :104)
>>     at
>> org.apache.catalina.core.StandardEngineValve.invoke(
>> StandardEngineValve.java:108)
>>     at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java
>> :211)
>>     at
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:817) 
>>
>>     at
>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
>> Http11Protocol.java:623)
>>     at
>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:444)
>>     at java.lang.Thread.run(Thread.java:595)
>>
>>
>>
>>
>> Brad
>>
>>
>
>


Re: Cannot run more than one RESTful service

Posted by Dan Diephouse <da...@envoisolutions.com>.
Hi Brad,

The JaxWsServiceFactoryBean is not resusable across various services. Try
embedding it inside your service definition:

<property name="serviceFactory">
  <bean class="....JaxWsServiceFactory">
...
</bean>
</property>

Let me know if that helps!

- Dan

On 7/16/07, Brad O'Hearne <br...@neurofire.com> wrote:
>
> Hello,
>
> I am having problems running more than one RESTful service, loaded via
> Spring. Without going into the nasties of how this was determined, with
> the help of a developer, it was determined that the present means of
> configuring a RESTful service with Spring was as follows (in my
> beans.xml file):
>
>    <bean id="userService"
>        class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
>        init-method="create">
>        <property name="serviceClass"
>            value="com.brad.user.IUserService" />
>        <property name="serviceBean">
>            <bean class="com.brad.user.UserService" />
>        </property>
>        <property name="address" value="/UserService" />
>        <property name="bindingId"
>            value="http://apache.org/cxf/binding/http" />
>        <property name="serviceFactory" ref="JaxWsServiceFactoryBean" />
>    </bean>
>
> This service, when configured as the only service in my beans.xml file,
> loads and is invoked successfully. But when I add a second service to my
> beans.xml, as follows:
>
>    <bean id="sponsorService"
>        class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
>        init-method="create">
>        <property name="serviceClass"
>            value="com.brad.sponsor.ISponsorService" />
>        <property name="serviceBean">
>            <bean class="com.brad.sponsor.SponsorService" />
>        </property>
>        <property name="address" value="/SponsorService" />
>        <property name="bindingId"
>            value="http://apache.org/cxf/binding/http" />
>        <property name="serviceFactory" ref="JaxWsServiceFactoryBean" />
>    </bean>
>
> When I deploy and start my server, on load I get no errors. But I also
> do not see this second service produce output in the server logs like
> the first one does. The first service, I see this in the logs:
>
> INFO: Creating Service {http://user.brad.com/}IUserServiceService from
> class com.brad.user.IUserService
>
> But I do not see this for my second (ISponsorService) service. When I
> try to invoke *either* service, CXF crashes. The stack trace is below.
> Does anyone have any idea how to configure and successfully run more
> than one RESTful service using Spring? Thanks in advance for help!!!
>
> Brad
>
> Stack trace, when trying to invoke the authenticate method on
> IUserService, that is known to work, with data known to work, when 2
> services are configured (this does not happen when only one service has
> been configured).
>
> INFO: URIParameterInterceptor handle message on path [/authenticate]
> with content-type [application/xml]
> Jul 16, 2007 4:11:03 PM org.apache.cxf.phase.PhaseInterceptorChain
> doIntercept
> INFO: Interceptor has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: object is not an instance of declaring
> class
>     at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java
> :88)
>     at
> org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:82)
>     at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java
> :56)
>     at
> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(
> ServiceInvokerInterceptor.java:56)
>     at
> org.apache.cxf.workqueue.SynchronousExecutor.execute(
> SynchronousExecutor.java:37)
>     at
> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(
> ServiceInvokerInterceptor.java:87)
>     at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> PhaseInterceptorChain.java:206)
>     at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(
> ChainInitiationObserver.java:67)
>     at
> org.apache.cxf.transport.servlet.ServletDestination.doMessage(
> ServletDestination.java:100)
>     at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(
> ServletController.java:224)
>     at
> org.apache.cxf.transport.servlet.ServletController.invoke(
> ServletController.java:103)
>     at
> org.apache.cxf.transport.servlet.CXFServlet.invoke(CXFServlet.java:261)
>     at
> org.apache.cxf.transport.servlet.CXFServlet.doPost(CXFServlet.java:239)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>     at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:270)
>     at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:191)
>     at
> org.apache.catalina.core.StandardWrapperValve.invoke(
> StandardWrapperValve.java:227)
>     at
> org.apache.catalina.core.StandardContextValve.invoke(
> StandardContextValve.java:174)
>     at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
> :127)
>     at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
> :104)
>     at
> org.apache.catalina.core.StandardEngineValve.invoke(
> StandardEngineValve.java:108)
>     at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java
> :211)
>     at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:817)
>     at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
> Http11Protocol.java:623)
>     at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:444)
>     at java.lang.Thread.run(Thread.java:595)
>
>
>
>
> Brad
>
>


-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog