Hi Sergey,
I'll wait for the fix. I cannot move the path annotation from the object
to the service since it is possible that the object involve has a whole
set of other fields. I also tried the following:
//an extra method
@GET
@Path("/search/")
@WebMethod
public MyObjects getObjects(){
//using a list wrapper as advised in the user's guide
return new MyObjects(new MyObject());
}
if I invoke http://localhost:8080/cxf/Objects/search/ , "getObject" gets
invoked.
Gabo
Sergey Beryozkin wrote:
Hi Gabo
What is happening is that with
Accept=[image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, */*]
the wildcard is the less specific accept type which is checked last,
when selecting between multiple matching methods.
I think what is happening is that when the first specific accept value
is tried, the getObject() method is discarded is it inherits text/xml
but the subresource method is matched due to the fact the actual
method selection is done at a later stage.
Actually, I think there's a flaw in this algorithm (in CXF JAXRS that
is), in that all accept types should be tried for all the methods,
even if the forst accept type has produced a candidate, in which case
*/* will ensure that the getObject() is selected too and it will be
picked up first on the basis that it's a resource method.
I'll get it fixed for 2.2, but in meantine please move /field1 from
MyObject.getField1() to ObjectService.getObjectProperty() and it
should fix the problem...
Thanks, Sergey
Hi All,
I was testing the web service I have created and it works without a
hitch when using HttpClient as ... well client. However, if I use
I.E. to check (haven't tested fire fox or any browser yet), I
encounter the following error:
javax.ws.rs.WebApplicationException
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.findTargetMethod(JAXRSUtils.java:295)
at
org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:161)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:67)
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:226)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:89)
at
org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:99)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:305)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:138)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:163)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:145)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Then I receive a runtime exception client side. What I find weird is
that a method was properly invoked. More specifically, the
subresource locator was used. There are two methods defined and
annotated as follows:
@Consumes("*/*")
@Produces("text/xml")
@Path("/Objects")
public class ObjectService{
@GET
@Path("/")
@WebMethod
public Object getObject(
@QueryParam("id")
@WebParam(name="id")
long id) {
//this is the method that I was invoking... supposedly
logger.info("get Object received: " + id);//Note this
return new MyObject();
}
@Path("/")
@WebMethod(exclude=true)
public Object getObjectProperty(
@QueryParam("id")
@WebParam(name="id")
long id) {
//this got invoked ... but should not have been
logger.info("get Object Property received: " + id);//Note this
return getObject(id);
}
}
@XmlType(name="MyObject")
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlRootElement(name="MyObject")
public class MyObject {
@GET
@Path("/field1")
public String getField1() {
return "field1";
}
public void setField1() {
}
}
The debug log shows the following:
2009-02-18 07:38:17,640 | [INFO ][80-1] | get Object Property
received: 1
2009-02-18 07:38:17,640 | [INFO ][80-1] | get Object received: 1
I am assuming it is having a problem finding the subresource since
technically, it shouldn't even be the method being invoked. URL being
used is:
http://localhost:8080/cxf/Objects/?id=1
I am not sure if it helps but maybe the extra headers affects this?
These are not received when HttpClient is used.
accept-language=[en-us], user-agent=[Mozilla/4.0 (compatible; MSIE
7.0; Windows NT 5.1)], accept-encoding=[gzip, deflate], ua-cpu=[x86],
Accept=[image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, */*]
I am using the following:
tomcat 6.0.13
java 1.6
cxf 2.2-snapshot (Jan 27)
Thanks in advance.
Gabo
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.237 / Virus Database: 270.10.25/1957 - Release Date: 02/17/09 07:07:00