Hi,
In this case what happens is that no MessageBodyReader (provider capable of
getting the input stream data and turning them into Emitter object) has been
found, thus it's a null and it's an application level error. That said, I need
to check what the spec says about it, perhaps an exception shouild be raised
earlier...
What is an Emmiter class ? Is it annotated with JAXB annotatations such as
@XmlRootElement ?
Does GET works for you, that is can you retrieve an individual Emitter from a
browser ?
If Emitters are not JAXB-aware then you'd need to register a custom Emitter
provider, which would know how to serialize/deserialize them. Alertantive you
might want to use JAXP Source and deal with XML locally...
Actually, I've written it all and just realized that your annotations are not
correct :
> @POST
> @Path("/emitters/")
> public void addEmitter(@UriParam("emitter")Emitter emitter) {
One can annotate with @UriParam only those parameters which are supposed to be
substituted as template variables found in your @Path, for ex :
@PUT
@Path("/emitters/{id}")
public void addEmitter(@UriParam("id") String id, Emitter emitter) {
}
So in your case doing just
@POST
@Path("/emitters")
public void addEmitter(Emitter emitter) {
}
should work fine, provided your Emitter is JAXB-aware :-)
Give it a try please,
Cheers, Sergey
----- Original Message -----
From: "daveor" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, March 05, 2008 12:37 PM
Subject: Re: CXF REST problems
>
> Hi, and thanks for your reply. I have tried your suggestion, I changed the
> @QueryParam to @UriParam and now I get a different error. Here's the updated
> method:
>
> @POST
> @Path("/emitters")
> public void addEmitter(@UriParam("emitter")Emitter emitter) {
> LOG.warn("Adding an emitter");
> LOG.warn("ID is " + emitter.getId()); <----- NullPointerException on
> this line
> LOG.warn("Name is " + emitter.getName());
> emitterDAO.save(emitter);
> }
>
>
> This is the NullPointerException exception:
>
> FINE: Invoking handleMessage on interceptor
> [EMAIL PROTECTED]
> 05-Mar-2008 12:25:05 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
> FINE: Application has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault
> at
> org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:107)
> at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:95)
> at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:62)
> 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:92)
> 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)
> Caused by: java.lang.NullPointerException
> at
> com.westglobal.mscape.registry.EmitterResource.addEmitter(EmitterResource.java:50)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:124)
> at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:82)
> ... 27 more
>
> All other code/content is as per my previous message.
>
> Thanks again!
>
> daveor
> --
> View this message in context:
> http://www.nabble.com/CXF-REST-problems-tp15848325p15849017.html
> Sent from the cxf-user mailing list archive at Nabble.com.
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland