Yeah, I'm seeing the same thing, the cxf systests seem to work but mine still error out. I've narrowed it down a bit more to the geronimo servlet spec jar being needed but still seems strange, maybe something to do with instantiating the REST endpoint via camel rather than directly; I'll play around with it some more. Thanks for looking into it.

-Chris

On 01/17/2014 04:05 PM, Sergey Beryozkin wrote:
Hi


On 17/01/14 15:01, Christopher Arnold wrote:
I'm running into a curious dependency issue running unit tests using CXF
endpoints. My test sets up a basic REST service using the local
transport (i.e. local://myservice) via Camel and then attempts to use it
via a proxy generated by JAXRSClientFactory. My pom includes camel-cxf,
cxf-rt-frontend-jaxrs, and cxf-rt-transports-local. The oddity is that
when the service only handles "native" java objects (e.g. String)
everything works fine, but if it's handling JAXB bound objects it errors
out with:

javax.ws.rs.InternalServerErrorException
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
     at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

     at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
     at
org.apache.cxf.jaxrs.client.AbstractClient.convertToWebApplicationException(AbstractClient.java:462)

     at
org.apache.cxf.jaxrs.client.ClientProxyImpl.checkResponse(ClientProxyImpl.java:307)

     at
org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:673)

     at
org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:639)

     at
org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:215)

     at com.sun.proxy.$Proxy22.getBook(Unknown Source)
     at
com.company.test.DataBindingTest.dataBindingTest(DataBindingTest.java:28)
     <snip surefire/maven stack...>

unless I add cxf-rt-transports-http-jetty to my pom's dependencies. Also
enabled TRACE logging on org.apache.cxf.* but no messages indicating why
the server is erroring out.  Any idea why it requires the jetty
transport to function property?

Details: CXF 2.7.8, Camel 2.12.2, Java 1.7.0_45
Full unit test for reference:

public class DataBindingTest extends CamelTestSupport {

     private LibraryBean libBean = new LibraryBean();

     @Test
     public void dataBindingTest() throws Exception {
         LibraryService client =
JAXRSClientFactory.create("local://rest", LibraryService.class);

         Book bookResp = client.getBook("1984");
         Book expect = null;
         for (Book b : libBean.books) {
             if (b.getName().equals("1984")) {
                 expect = b;
                 break;
             }
         }
         assertEquals(expect, bookResp);
     }

     @Override
     protected CamelContext createCamelContext() throws Exception {
         CamelContext cc = super.createCamelContext();
         cc.addComponent("activemq",
activeMQComponent("vm://localhost?broker.persistent=false"));
         return cc;
     }

     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jr = super.createRegistry();
         jr.bind("libraryBean", libBean);
         return jr;
     }

     @Override
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
             public void configure() {

from("cxfrs://local://rest?resourceClasses=com.company.test.rest.LibraryService&"
+
                         "bindingStyle=SimpleConsumer")
                     .setExchangePattern(ExchangePattern.InOut)

.to("log:com.ptc.esb.test.library?level=INFO&showAll=true")
                     .to("activemq:queue:library");


                 from("activemq:queue:library")
                     .setExchangePattern(ExchangePattern.InOut)

.to("log:com.company.test.library?level=INFO&showAll=true")
                     .choice()

.when(header("operationName").isEqualTo("getBook"))
.to("bean:libraryBean?method=getBook")

.when(header("operationName").isEqualTo("getBooks"))
.to("bean:libraryBean?method=getBooks")
                     .endChoice()

.to("log:com.company.test.library?level=INFO&showAll=true");
             }
         };
     }

}

I've run JAXRSLocalTransportTest (in CXF trunk/systests/jaxrs), removing the http-jetty transport dependency and it all worked OK,

You can try it with "mvn -Dtest=JAXRSLocalTransportTest" in systests/jaxrs,

mvn install -Pfastinstall

will quickly build the trunk...

Cheers. Sergey



Thanks,
-Chris


.


Reply via email to