On Tue, Jun 16, 2009 at 09:56:39AM +0100, Sergey Beryozkin wrote:
> Not sure why but the message formatting is broken
> Here's another attempt :
>
> ClassPathXmlApplicationContext ctx =
> new ClassPathXmlApplicationContext(new String[]
> {"/org/apache/cxf/jaxrs/spring/servers.xml"});
>
> // 'simple' is the id of the jaxrs server bean
> JAXRSServerFactoryBean sfb = (JAXRSServerFactoryBean)ctx.getBean("simple");
> sfb.create();
>
> or may be you just can get all the beans from the context and call create()
> on those which are assignable to JAXRSServerFactoryBean
>
> give a try please
>
> Cheers, SergeyHello, Sergey! Thank you for the reply, however looks like I am still missing something. I created the sample application, which has the following beans.xml in the classpath: ======================================================================================================= <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> <!-- do not use import statements if CXFServlet init parameters link to this beans.xml --> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <jaxrs:server id="customerService" address="http://localhost:9000/"> <jaxrs:serviceBeans> <ref bean="customerBean" /> </jaxrs:serviceBeans> </jaxrs:server> <bean id="customerBean" class="test.service.CustomerService" /> </beans> ======================================================================================================= And I am using the following simple class to start the things up: ======================================================================================================= package test; import org.apache.cxf.endpoint.Server; import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; import org.springframework.context.support.ClassPathXmlApplicationContext; public class App { public static void main(String[] args) throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext( "/beans.xml"); JAXRSServerFactoryBean sfb = (JAXRSServerFactoryBean) ctx .getBean("customerService"); Server server = sfb.create(); Thread.sleep(Long.MAX_VALUE); } } ======================================================================================================= And at this point the service seems to start up: ======================================================================================================= 16.06.2009 18:38:58 org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.context.support.classpathxmlapplicationcont...@eb017e: display name [org.springframework.context.support.classpathxmlapplicationcont...@eb017e]; startup date [Tue Jun 16 18:38:58 EEST 2009]; root of context hierarchy 16.06.2009 18:38:59 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [beans.xml] 16.06.2009 18:38:59 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml] 16.06.2009 18:39:00 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-jaxrs-binding.xml] 16.06.2009 18:39:00 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml] 16.06.2009 18:39:00 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [org.springframework.context.support.classpathxmlapplicationcont...@eb017e]: org.springframework.beans.factory.support.defaultlistablebeanfact...@14520eb 16.06.2009 18:39:00 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.defaultlistablebeanfact...@14520eb: defining beans [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.jaxrs.JAXRSBindingFactory,org.apache.cxf.transport.servlet.ServletTransportFactory,customerService,customerBean]; root of factory hierarchy 16.06.2009 18:39:01 org.apache.cxf.endpoint.ServerImpl initDestination INFO: Setting the server's publish address to be http://localhost:9000/ 16.06.2009 18:39:01 org.apache.cxf.endpoint.ServerImpl initDestination INFO: Setting the server's publish address to be http://localhost:9000/ ======================================================================================================= However there is nothing being listening on the port 9000, and when trying to connect to this URL with the browser - the connection refused is reported. What am I doing in the wrong way? Thank you in advance! -- Eugene N Dzhurinsky
pgpUhlT8Iuxnq.pgp
Description: PGP signature
