hubz / j-calais

Automatically exported from code.google.com/p/j-calais
Apache License 2.0
0 stars 0 forks source link

Problem when Open Calais returns errors #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I get the following error randomly :

24 mai 2011 14:44:08 com.sun.jersey.api.client.ClientResponse getEntity
GRAVE: A message body reader for Java class java.util.Map, and Java type 
interface java.util.Map, and MIME media type text/xml; charset=UTF-8 was not 
found
24 mai 2011 14:44:08 com.sun.jersey.api.client.ClientResponse getEntity
GRAVE: The registered message body readers compatible with the MIME media type 
are:
text/xml; charset=UTF-8 ->
  com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$Text
  com.sun.jersey.core.impl.provider.entity.DocumentProvider
  com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
  com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$Text
  com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$Text
  com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$Text
*/* ->
  com.sun.jersey.core.impl.provider.entity.FormProvider
  com.sun.jersey.atom.rome.impl.provider.entity.AtomFeedProvider
  com.sun.jersey.core.impl.provider.entity.StringProvider
  com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
  com.sun.jersey.core.impl.provider.entity.FileProvider
  com.sun.jersey.core.impl.provider.entity.InputStreamProvider
  com.sun.jersey.core.impl.provider.entity.DataSourceProvider
  com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
  com.sun.jersey.core.impl.provider.entity.ReaderProvider
  com.sun.jersey.core.impl.provider.entity.DocumentProvider
  com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
  com.sun.jersey.atom.rome.impl.provider.entity.AtomEntryProvider
  com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
  com.sun.jersey.core.impl.provider.entity.EntityHolderReader
  com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
  com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
  com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy

java.util.concurrent.ExecutionException: 
com.sun.jersey.api.client.ClientHandlerException: A message body reader for 
Java class java.util.Map, and Java type interface java.util.Map, and MIME media 
type text/xml; charset=UTF-8 was not found
    at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at newspecker.entities.EntityDictionary.getEntitiesFor(EntityDictionary.java:141)
    at newspecker.spaces.articles.ArticlePipeline.extractEntities(ArticlePipeline.java:168)
    at newspecker.spaces.articles.ArticlePipeline.build(ArticlePipeline.java:71)
    at newspecker.crawler.ArticleTask.run(ArticleTask.java:30)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: com.sun.jersey.api.client.ClientHandlerException: A message body 
reader for Java class java.util.Map, and Java type interface java.util.Map, and 
MIME media type text/xml; charset=UTF-8 was not found
    at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:549)
    at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:506)
    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:674)
    at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
    at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:563)
    at mx.bigdata.jcalais.rest.CalaisRestClient.analyze(CalaisRestClient.java:126)
    at mx.bigdata.jcalais.rest.CalaisRestClient.analyze(CalaisRestClient.java:108)
    at newspecker.entities.CalaisCallable.call(CalaisCallable.java:19)
    at newspecker.entities.CalaisCallable.call(CalaisCallable.java:1)
    ... 5 more

I guess the main problem is that Open Calais is returning XML instead of JSON 
from time to time. According to this page 
(http://www.opencalais.com/documentation/calais-web-service-api/error-messages),
 error messages are given as XML. Maybe j-calais should handle this properly. 
Unfortunately, I haven't been able to solve the issue myself on j-calais 
sourcecode nor finding any clue of what triggers this strange behaviour.

Original issue reported on code.google.com by ma.dous...@gmail.com on 24 May 2011 at 12:57

GoogleCodeExporter commented 9 years ago
I guess I have the error "Calais Backend-Server is Busy. Please try again 
later." when it crashes. In this case, I retry some delay latter and it's ok 
this way, but it doesn't mean that j-calais handles Open Calais' errors 
correctly, though. 

Thanks for all your work !

Original comment by ma.dous...@gmail.com on 24 May 2011 at 4:52

GoogleCodeExporter commented 9 years ago
Thank you I will add proper error handling for Open Calais XML errors.

Original comment by elmer.garduno@gmail.com on 24 May 2011 at 4:58

GoogleCodeExporter commented 9 years ago

Original comment by elmer.garduno@gmail.com on 24 May 2011 at 5:00

GoogleCodeExporter commented 9 years ago
I'll need to do an important refactoring of how the connection and parsing is 
done in order to be able to process the error messages.

Original comment by elmer.garduno@gmail.com on 4 Jul 2011 at 3:44

GoogleCodeExporter commented 9 years ago
I guess so, unfortunately... Good luck if you take the job to the end !

Original comment by ma.dous...@gmail.com on 4 Jul 2011 at 3:58

GoogleCodeExporter commented 9 years ago
Hi, I have added appropriate error handling.

If an error returned by the OpenCalais Web service a CalaisException is thrown, 
CalaisException contains all the information returned in the XML, and can be 
retrieved using the following methods:

  public String getMethod();

  public String getCalaisRequestID();

  public String getCreationDate();

  public String getCalaisVersion();

  public String getMessage();

Could you please test it using the following artifact and give me feedback so I 
can release this changes.

 <repositories>
    <repository>
      <id>sonatype-snapshots</id>
      <url>http://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
  </repositories>

    <dependency>
      <groupId>mx.bigdata.jcalais</groupId>
      <artifactId>j-calais</artifactId>
      <version>0.3-SNAPSHOT</version>
    </dependency>

Or this jar:

http://code.google.com/p/j-calais/downloads/detail?name=j-calais-0.3-SNAPSHOT.ja
r

Thanks, 

Original comment by elmer.garduno@gmail.com on 17 Jul 2011 at 1:44

GoogleCodeExporter commented 9 years ago
I'll give it a try along coming week and provide some feedback. Thanks for your 
work !

Original comment by ma.dous...@gmail.com on 17 Jul 2011 at 8:45