On Tuesday, November 08, 2011 10:02 AM, "Jon Barber" <jon.bar...@acm.org> wrote: > Apologies for the delayed reply. Comments in line below. > > On Monday, October 31, 2011 10:28 PM, "Sergey Beryozkin" > <sberyoz...@gmail.com> wrote: > > Hi > > > > On 27/10/11 16:28, Jon Barber wrote: > > > Hi List, > > > > > > I've managed to get CXF DOSGi 1.2 working with JSON responses following > > > the discussions I found on this list. However, I've hit a problem when I > > > try to use the OSGi HTTP Service via the > > > org.apache.cxf.ws.httpservice.context property. > > > > > > So I've adapted the greeter rest sample from the distribution and added > > > the following properties to the services : > > > > > > > > > props.put("service.exported.interfaces", "*"); > > > props.put("service.exported.configs", "org.apache.cxf.rs"); > > > props.put("service.exported.intents", "HTTP"); > > > > > > props.put("org.apache.cxf.rs.provider","org.apache.cxf.jaxrs.provider.AegisElementProvider,org.apache.cxf.jaxrs.provider.AegisJSONProvider"); > > > > > > Then for the first case I register an address for the service to use, > > > e.g. > > > > > > > > > props.put("org.apache.cxf.rs.address","http://localhost:8282/greeter2"); > > > > > > This works like a charm : curl > > > http://localhost:8282/greeter2/greeter/greeting/fred > > > {"ns1.GreeterInfo":{"@xsi.type":"ns1:GreeterInfo","ns1.greetings":{"ns1.GreetingPhrase":[{"@xsi.type":"ns1:GreetingPhrase","ns1.name":"fred","ns1.phrase":"Hello"},{"@xsi.type":"ns1:GreetingPhrase","ns1.name":"fred","ns1.phrase":"Hoi"},{"@xsi.type":"ns1:GreetingPhrase","ns1.name":"fred","ns1.phrase":"Hola"},{"@xsi.type":"ns1:GreetingPhrase","ns1.name":"fred","ns1.phrase":"Bonjour"}]}}} > > > > > > > > > > > > However, it blows up when I try and register with a context instead of > > > an address. So that last property above is replaced with this : > > > > > > props.put("org.apache.cxf.rs.httpservice.context","/greeter2"); > > > > > > Now when I issue the curl command I get this exception in Felix : > > > > > > 27-Oct-2011 16:11:08 > > > org.apache.cxf.dosgi.dsw.handlers.SecurityDelegatingHttpContext > > > handleSecurity > > > INFO: No filter registered. > > > Delegating from GreeterServiceImpl2 to GreeterServiceImpl > > > Invoking: greetMe(fred) > > > java.lang.ExceptionInInitializerError > > > at > > > > > > org.apache.cxf.aegis.AegisContext.createRootTypeCreator(AegisContext.java:119) > > > at > > > > > > org.apache.cxf.aegis.AegisContext.createTypeCreator(AegisContext.java:108) > > > at > > > > > > org.apache.cxf.aegis.AegisContext.initialize(AegisContext.java:150) > > > at > > > > > > org.apache.cxf.jaxrs.provider.AbstractAegisProvider.getClassContext(AbstractAegisProvider.java:123) > > > at > > > > > > org.apache.cxf.jaxrs.provider.AbstractAegisProvider.getAegisContext(AbstractAegisProvider.java:80) > > > at > > > > > > org.apache.cxf.jaxrs.provider.AegisElementProvider.writeTo(AegisElementProvider.java:74) > > > at > > > > > > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:248) > > > at > > > > > > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:139) > > > at > > > > > > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:78) > > > at > > > > > > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243) > > > at > > > > > > org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:78) > > > at > > > > > > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243) > > > at > > > > > > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:110) > > > at > > > > > > org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98) > > > at > > > > > > org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:423) > > > at > > > > > > org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:139) > > > at > > > > > > org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:142) > > > at > > > > > > org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179) > > > at > > > > > > org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:108) > > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) > > > at > > > > > > org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159) > > > at > > > > > > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) > > > at > > > > > > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362) > > > at > > > > > > org.ops4j.pax.web.service.internal.HttpServiceServletHandler.handle(HttpServiceServletHandler.java:66) > > > at > > > > > > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) > > > at > > > > > > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729) > > > at > > > > > > org.ops4j.pax.web.service.internal.HttpServiceContext.handle(HttpServiceContext.java:108) > > > at > > > > > > org.ops4j.pax.web.service.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:64) > > > at > > > > > > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) > > > at org.mortbay.jetty.Server.handle(Server.java:324) > > > at > > > > > > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) > > > at > > > > > > org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829) > > > at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513) > > > at > > > org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) > > > at > > > org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) > > > at > > > > > > org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395) > > > at > > > > > > org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488) > > > Caused by: java.lang.IllegalArgumentException: No SchemaFactory that > > > implements the schema language specified by: > > > http://www.w3.org/2001/XMLSchema could be loaded > > > at javax.xml.validation.SchemaFactory.newInstance(Unknown > > > Source) > > > at > > > > > > org.apache.cxf.aegis.type.XMLTypeCreator.<clinit>(XMLTypeCreator.java:118) > > > > > > This is using Java 1.6.0_27, CXF DOSGi 1.2 and Felix 3.2.2. I configured > > > felix as per the conf in the cxf distribution with the addition of the > > > jettison jar and my modified greeter bundle - config is viewable at > > > http://pastebin.com/m8Qa8pLw > > > > I vaguely recall seeing something like that before. > > Does it happen with Aegis only, when requesting JSON or XMl or both ? > > Can you please try JAXB ? > > OK, I'll try and find out how I use JAXB in place of Aegis. Could you > provide a pointer to some docs etc ? >
OK, so I set the "org.apache.cxf.ws.databinding" property to "jaxb" and I still get exactly the same stack trace. > > > > > > > > I can work around this, in that if I set the address to be the same as > > > the OSGi HTTP service is already using then that works fine, > > > > Can you clarify it please ? > > So I mean that if the HTTP service is configured to listen to port 9000 > then if I set the property like this : > > props.put("org.apache.cxf.rs.address","http://localhost:9000/greeter2"); > > then that works fine. > > However, I'd rather not do that (set an absolute address) as we have > different configurations for our different environments. > > > > > Cheers, Sergey > > > > > but I'd > > > rather not do that as we would need to remember to change the property > > > if we ever change the port to be consistent. > > > > > > Any help would be gratefully received. > > > > > > Thanks, > > > > > > Jon. > > > > >