Hi there, I've been looking through the user group and I haven't been able to find an answer to my problem so I thought I'd send a post and see if anyone can help me.
I downloaded the 20080228 and the 20080303 snapshots. What I describe below are problems that I have found in both. First problem that I've noticed is that I can't find the @UriTemplate annotation. It's not in the jsr311-api-0.5.jar file where all of the other JSR annotations can be found. So, I had a look at the JSR spec, and the @Path annotation seemed appropriate so I used that instead. Is that correct? Second problem is that I implemented a service using the @Path annotation and I'm getting a null pointer exception as described below. I am using spring configuration, so here's my spring config file: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> <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="registryEndpoint" address="/"> <jaxrs:serviceBeans> <ref bean="emitterResource"/> </jaxrs:serviceBeans> </jaxrs:server> </beans> Here's the resource file: @Path("/emitterResource") public class EmitterResource { @Path("/getEmitters") public Collection<Emitter> getEmitters() { return emitterDAO.getAllEmitters(); } @Path("/emitters/{emitterId}") public Emitter getEmitter(@QueryParam("emitterId") int id) { //public Emitter getEmitter(@WebParam(name = "emitterId") int id) { LOG.debug("looking for emitter id " + id); return emitterDAO.get(id); } @Path("/emitters") public void addEmitter(@QueryParam("emitter")Emitter emitter) { LOG.warn("Adding an emitter"); LOG.warn("ID is " + emitter.getId()); LOG.warn("Name is " + emitter.getName()); emitterDAO.save(emitter); } When I try to add @HttpMethod annotations above the @Path annotations I get the error "The annotation @HttpMethod is disallowed for this location" The Emitter class is just a POJO with an Id and a Name. Here's a snippet of my client code (I'm using apache commons HttpClient) : Emitter e = new Emitter(); e.setId(12345); e.setName("Test Name"); PostMethod post = new PostMethod("http://localhost:8080/emitterResource/emitters"); StringWriter stringWriter = new StringWriter(); jaxbMarshaller.marshal(registryObject, stringWriter); StringRequestEntity requestEntity = new StringRequestEntity(stringWriter.toString(), "text/xml", "ISO-8859-1"); post.setRequestEntity(requestEntity); HttpClient httpClient = new HttpClient(); int result = httpClient.executeMethod(post); System.out.println("Response code " + result); System.out.println(post.getResponseBodyAsString()); post.releaseConnection(); I'm deploying the server in tomcat 5.5 successfully (no errors), but when I run the client, I'm getting the following exception: 05-Mar-2008 11:08:39 org.apache.cxf.phase.PhaseInterceptorChain doIntercept FINE: Invoking handleMessage on interceptor [EMAIL PROTECTED] 05-Mar-2008 11:08:39 org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor handleMessage FINE: Request path is: /emitterResource/emitters/ 05-Mar-2008 11:08:39 org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor handleMessage FINE: Request HTTP method is: POST 05-Mar-2008 11:08:39 org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor handleMessage FINE: Request contentType is: text/xml; charset=ISO-8859-1 05-Mar-2008 11:08:39 org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor handleMessage FINE: Accept contentType is: */* 05-Mar-2008 11:08:39 org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor handleMessage INFO: Found operation: getEmitter 05-Mar-2008 11:08:39 org.apache.cxf.phase.PhaseInterceptorChain doIntercept INFO: Interceptor has thrown exception, unwinding now java.lang.NumberFormatException: null at java.lang.Integer.parseInt(Integer.java:415) at java.lang.Integer.valueOf(Integer.java:553) at org.apache.cxf.common.util.PrimitiveUtils.read(PrimitiveUtils.java:60) at org.apache.cxf.jaxrs.JAXRSUtils.readQueryString(JAXRSUtils.java:295) at org.apache.cxf.jaxrs.JAXRSUtils.processParameter(JAXRSUtils.java:277) at org.apache.cxf.jaxrs.JAXRSUtils.processParameters(JAXRSUtils.java:241) at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:112) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:113) at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:170) at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:148) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210) 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:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685) at java.lang.Thread.run(Thread.java:619) Just for completeness, I've captured what's being sent on the wire, and here it is: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><emitter xmlns="http://registry.mscape.westglobal.com"><id>12345</id><name>Test Emitter</name></emitter> Can anyone help me please, I'm completely stuck. thanks, daveor -- View this message in context: http://www.nabble.com/CXF-REST-problems-tp15848325p15848325.html Sent from the cxf-user mailing list archive at Nabble.com.
