HTTP 500 error when invoking a REST client in Solr Analyzer

2013-11-11 Thread Dileepa Jayakody
Hi All,

I am working on a custom analyzer in Solr to post content to Apache Stanbol
for enhancement during indexing. To post content to Stanbol, inside my
custom analyzer's incrementToken() method I have written below code using
Jersey client API sample [1];

public boolean incrementToken() throws IOException {
if (!input.incrementToken()) {
  return false;
}
char[] buffer = charTermAttr.buffer();
String content = new String(buffer);
Client client = Client.create();
WebResource webResource = client.resource(http://localhost:8080/enhancer;);
ClientResponse response = webResource.type(text/plain).accept(new
MediaType(application, rdf+xml)).post(ClientResponse.class, content);
int status = response.getStatus();
if (status != 200  status != 201  status != 202) {
throw new RuntimeException(Failed : HTTP error code : 
 + response.getStatus());
}

String output = response.getEntity(String.class);
System.out.println(output);
   charTermAttr.setEmpty();
   char[] newBuffer = output.toCharArray();
   charTermAttr.copyBuffer(newBuffer, 0, newBuffer.length);
return true;
}

When testing the analyzer I always get a HTTP 500 response from Stanbol
server and I cannot process the enhancement response properly. But I could
successfully execute the same jersey client code above in a Java
application (in main method) and retrieve desired enhancement response from
Stanbol.

Any ideas why I always get a HTTP 500 error when invoking a rest endpoint
in Solr analyzer? Could it be a permission problem in my Solr analyzer ?
Appreciate your help.

Thanks,
Dileepa

[1]
https://blogs.oracle.com/enterprisetechtips/entry/consuming_restful_web_services_with

[2]
6424 [qtp918598659-11] ERROR org.apache.solr.core.SolrCore  –
java.lang.RuntimeException: Failed : HTTP error code : 500
at
com.solr.test.analyzer.ContentFilter.incrementToken(ContentFilter.java:70)
at
org.apache.solr.handler.AnalysisRequestHandlerBase.analyzeTokenStream(AnalysisRequestHandlerBase.java:179)
at
org.apache.solr.handler.AnalysisRequestHandlerBase.analyzeValue(AnalysisRequestHandlerBase.java:126)
at
org.apache.solr.handler.FieldAnalysisRequestHandler.analyzeValues(FieldAnalysisRequestHandler.java:221)
at
org.apache.solr.handler.FieldAnalysisRequestHandler.handleAnalysisRequest(FieldAnalysisRequestHandler.java:190)
at
org.apache.solr.handler.FieldAnalysisRequestHandler.doAnalysis(FieldAnalysisRequestHandler.java:101)
at
org.apache.solr.handler.AnalysisRequestHandlerBase.handleRequestBody(AnalysisRequestHandlerBase.java:59)
at
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
at
org.apache.solr.core.RequestHandlers$LazyRequestHandlerWrapper.handleRequest(RequestHandlers.java:241)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1859)
at
org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:703)
at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:406)
at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:195)
at
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:368)
at
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at
org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
at
org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942)
at
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at
org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
at
org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
at

Re: HTTP 500 error when invoking a REST client in Solr Analyzer

2013-11-11 Thread Dileepa Jayakody
This seems to be a weird intermittent issue when I use the Analysis UI (
http://localhost:8983/solr/#/collection1/analysis) for testing my Analyzer.
It works fine when I hard code the input value in the Analyzer and index. I
gave the same input : Tim Bernes Lee is a professor at MIT hard coded in
the Analyzer class and from the Solr Analysis UI. The UI response failed
intermittently when I adjust the field value.
This could be a problem with character encoding of the field value it seems.

Thanks,
Dileepa


On Tue, Nov 12, 2013 at 1:33 AM, Dileepa Jayakody dileepajayak...@gmail.com
 wrote:

 Hi All,

 I am working on a custom analyzer in Solr to post content to Apache
 Stanbol for enhancement during indexing. To post content to Stanbol, inside
 my custom analyzer's incrementToken() method I have written below code
 using Jersey client API sample [1];

 public boolean incrementToken() throws IOException {
 if (!input.incrementToken()) {
   return false;
 }
 char[] buffer = charTermAttr.buffer();
 String content = new String(buffer);
 Client client = Client.create();
 WebResource webResource = client.resource(http://localhost:8080/enhancer
 );
  ClientResponse response = webResource.type(text/plain).accept(new
 MediaType(application, rdf+xml)).post(ClientResponse.class, content);
  int status = response.getStatus();
 if (status != 200  status != 201  status != 202) {
  throw new RuntimeException(Failed : HTTP error code : 
  + response.getStatus());
  }

 String output = response.getEntity(String.class);
  System.out.println(output);
charTermAttr.setEmpty();
char[] newBuffer = output.toCharArray();
 charTermAttr.copyBuffer(newBuffer, 0, newBuffer.length);
 return true;
 }

 When testing the analyzer I always get a HTTP 500 response from Stanbol
 server and I cannot process the enhancement response properly. But I could
 successfully execute the same jersey client code above in a Java
 application (in main method) and retrieve desired enhancement response from
 Stanbol.

 Any ideas why I always get a HTTP 500 error when invoking a rest endpoint
 in Solr analyzer? Could it be a permission problem in my Solr analyzer ?
 Appreciate your help.

 Thanks,
 Dileepa

 [1]
 https://blogs.oracle.com/enterprisetechtips/entry/consuming_restful_web_services_with

 [2]
 6424 [qtp918598659-11] ERROR org.apache.solr.core.SolrCore  –
 java.lang.RuntimeException: Failed : HTTP error code : 500
 at
 com.solr.test.analyzer.ContentFilter.incrementToken(ContentFilter.java:70)
  at
 org.apache.solr.handler.AnalysisRequestHandlerBase.analyzeTokenStream(AnalysisRequestHandlerBase.java:179)
 at
 org.apache.solr.handler.AnalysisRequestHandlerBase.analyzeValue(AnalysisRequestHandlerBase.java:126)
  at
 org.apache.solr.handler.FieldAnalysisRequestHandler.analyzeValues(FieldAnalysisRequestHandler.java:221)
 at
 org.apache.solr.handler.FieldAnalysisRequestHandler.handleAnalysisRequest(FieldAnalysisRequestHandler.java:190)
  at
 org.apache.solr.handler.FieldAnalysisRequestHandler.doAnalysis(FieldAnalysisRequestHandler.java:101)
 at
 org.apache.solr.handler.AnalysisRequestHandlerBase.handleRequestBody(AnalysisRequestHandlerBase.java:59)
  at
 org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
 at
 org.apache.solr.core.RequestHandlers$LazyRequestHandlerWrapper.handleRequest(RequestHandlers.java:241)
  at org.apache.solr.core.SolrCore.execute(SolrCore.java:1859)
 at
 org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:703)
  at
 org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:406)
 at
 org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:195)
  at
 org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
 at
 org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
  at
 org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
 at
 org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
  at
 org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
 at
 org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
  at
 org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
 at
 org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
  at
 org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
 at
 org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
  at
 org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
 at
 org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
  at
 org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
 at org.eclipse.jetty.server.Server.handle(Server.java:368)
  at