phdmohans / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

Error in TwitPicConsumerExample #148

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When running the TwitPicConsumerExample, the following exception is written to 
the console:

GET 
http://odata.twitpic.com/Tags('starbucks')/Images?$orderby=Views%2Bdesc&$top=5
Accept: application/xml
User-Agent: odata4j.org
Exception in thread "main" java.lang.RuntimeException: 
java.lang.RuntimeException: Expected status 200, found 400:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code></code>
  <message xml:lang="en-US">Syntax error '+' at position 5.</message>
</error>
    at org.core4j.ReadOnlyIterator.hasNext(ReadOnlyIterator.java:50)
    at org.core4j.Enumerable$FuncIterator.hasNext(Enumerable.java:482)
    at org.core4j.Enumerable$FuncIterator.hasNext(Enumerable.java:482)
    at org.odata4j.examples.AbstractExample.reportEntities(AbstractExample.java:51)
    at org.odata4j.examples.consumer.TwitPicConsumerExample.run(TwitPicConsumerExample.java:21)
    at org.odata4j.examples.consumer.TwitPicConsumerExample.main(TwitPicConsumerExample.java:14)
Caused by: java.lang.RuntimeException: Expected status 200, found 400:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code></code>
  <message xml:lang="en-US">Syntax error '+' at position 5.</message>
</error>
    at org.odata4j.jersey.consumer.ODataJerseyClient.doRequest(ODataJerseyClient.java:225)
    at org.odata4j.jersey.consumer.ODataJerseyClient.getEntities(ODataJerseyClient.java:98)
    at org.odata4j.jersey.consumer.ConsumerQueryEntitiesRequest$EntryIterator.advance(ConsumerQueryEntitiesRequest.java:73)
    at org.core4j.ReadOnlyIterator.hasNext(ReadOnlyIterator.java:48)
    ... 5 more

Original issue reported on code.google.com by philipp.sebastian.thun on 19 Mar 2012 at 5:55

GoogleCodeExporter commented 9 years ago

Original comment by philipp.sebastian.thun on 20 Mar 2012 at 10:15

GoogleCodeExporter commented 9 years ago
This is working for me in tip, url sent is:
 GET http://odata.twitpic.com/Tags('starbucks')/Images?$orderby=Views+desc&$top=5

Not: Views%2Bdesc   (double encoded)

Original comment by john.spurlock on 25 Mar 2012 at 8:14

GoogleCodeExporter commented 9 years ago
Okay, I found the cause for this strange behavior. For me it was only working, 
when I switched to the CXF consumer. The Jersey consumer always sent the 
encoded + sign. But when debugging the ODataJerseyClient.doRequest method, I 
could see that the UriBuilder (that is used within the WebResource) was of type 
org.apache.cxf.jaxrs.impl.UriBuilderImpl. When I added the code to explicitly 
use the Jersey implementation of RuntimeDelegate, the example worked fine...

So the question is, how do we ensure that the correct JAX-RS implementation is 
loaded when running an example? Should we add this to the JaxRsImplementation 
class? Or more general to OData[Jersey|Cxf][Consumer|Server]? But the later 
might be the wrong place, as in productive scenarios, there should be only one 
JAX-RS implementation available. Any suggestions?

Original comment by philipp.sebastian.thun on 26 Mar 2012 at 2:21

GoogleCodeExporter commented 9 years ago
Fixed with revision 1a6da031f6ec.

Original comment by philipp.sebastian.thun on 26 Apr 2012 at 5:53