Hi Bob, I've just added a check for the NPE in ServerResource. I'll look at your other issues after 2.0 M5.
Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com -----Message d'origine----- De : Bob Resendes [mailto:[email protected]] Envoyé : jeudi 17 septembre 2009 18:38 À : [email protected] Objet : NullPointerException in ServerResource::getAvailableVariants() (r 2.0 M4) I encountered the following exception (snippet): java.lang.NullPointerException at org.restlet.resource.ServerResource.getAvailableVariants(ServerResource.java :681) at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:5 56) at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java: 254) at org.restlet.resource.ServerResource.handle(ServerResource.java:930) ... while trying to implement the following "post" method (snippet): @Post("xml:xml") public Representation postXml() throws IOException { ...} Apparently, the following call in ServerResource::getAvailableVariants(): List<Metadata> allMetadata = getMetadataService() .getAllMetadata(annotationInfo.getValue()); returns null when the annotation is "xml:xml", but not just "xml". I didn't see anything in the bug database, but just wanted to make sure before reporting it. [The javadoc for the Post annotation actually has an example of "@Post("xml:xml") which I originally assumed was a convention for "@Post("<consumes>:<produces>")".] The other, related questions I have are: Q1 - What is the @Post annotation's value supposed to mean? I originally assumed was a convention for "@Post("<consumes>")", but it's acting like @Post("<produces>")[1]. If so, then it seems like I can't implement the following functionality via annotations only: @Post("html:html|xml|json") That is, I'd like to: - submit "form" data (e.g. application/x-www-form-urlencoded) from a client that accepts html, xml, or json - "route" the call to the method that can process form data - return xml|json|html based on a provided query parameter (e.g. <resource_url>?format=json) (which overrides any accept header preference) Q2 - is the JAX-RS support (which provides parallel functionality) ready for general use? I remember seeing a note somewhere that it wasn't ready (at least in release 2.0 M4). If it's ready then I'm assuming I could do something like (I'm sure I don't have the right annotation values, but you get the gist): @Post @Consumes("html") @Produces("xml|json|html") public Representation methodThatAcceptsFormDataButCanReturnHtmlOrJsonOrXmlBasedOnQueryParameter() { ... } Regards, Bob Notes: [1] I have the following code (snippet) @Post("xml") public Representation postXml() {...} @Post("html") public Representation postHtml() {...} If I post form data via a browser (which has an accept header that prefers HTML over XML) then postHtml() gets called. If I post form data via curl (which has accept header with "*/*") then postXml() gets called (because xml shows up first in the supported variants list and no format preference was stated). ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=23961 02 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2401070

