RE: BasicHelloRequestHandler plugin - class path changed

2010-11-30 Thread Hong-Thai Nguyen
Hi,
I found the problem:
The class name has been changed to 1.4.1:
From: import org.apache.solr.response.SolrQueryResponse;
To: import org.apache.solr.request.SolrQueryResponse;

Best,
---
Hong-Thai

-Message d'origine-
De : Hong-Thai Nguyen [mailto:hong-thai.ngu...@polyspot.com] 
Envoyé : lundi 29 novembre 2010 16:41
À : solr-user@lucene.apache.org
Objet : BasicHelloRequestHandler plugin

Hi,

Thank for helping us.

I’m creating a ‘helloword’ plugin in Solr 1.4 in BasicHelloRequestHandler.java

In solrconfig.xml, I added:

 





 

   Default message 

   -10 

 

  

 

I verified ‘hello’ plugin is figured well at: 
http://localhost:8983/solr/admin/plugins

 

When I executed: http://localhost:8983/solr/select?qt=hello, the 
java.lang.AbstractMethodError raised:

type Rapport d'état

message null java.lang.AbstractMethodError at 
org.apache.solr.core.SolrCore.execute(SolrCore.java:1316) at 
org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:338) 
at 
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:241)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) 
at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) 
at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at 
java.lang.Thread.run(Thread.java:595) 

I supposed that handleRequest in the BasicHelloRequestHandler isn’t called.

Here’s BasicHelloRequestHandler .java code:

import com.polyspot.mercury.common.params.HelloParams;

import org.apache.solr.common.SolrException;

import org.apache.solr.common.params.SolrParams;

import org.apache.solr.common.util.NamedList;

import org.apache.solr.common.util.SimpleOrderedMap;

import org.apache.solr.request.SolrQueryRequest;

import org.apache.solr.request.SolrRequestHandler;

import org.apache.solr.response.SolrQueryResponse;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

 

import java.net.URL;

 

 

/**

 * User: nguyenht

 * Date: 26 nov. 2010

 */

public class BasicHelloRequestHandler implements SolrRequestHandler {

 

  protected static Logger log = 
LoggerFactory.getLogger(BasicHelloRequestHandler.class);

 

  protected NamedList initArgs = null;

  protected SolrParams defaults;

 

 

  /**

   * init will be called just once, immediately after creation.

   * The args are user-level initialization parameters that

   * may be specified when declaring a request handler in

   * solrconfig.xml

   */

  public void init(NamedList args) {

log.info("initializing BasicHelloRequestHandler: " + args);

 

initArgs = args;

 

if (args != null) {

  Object o = args.get("defaults");

  if (o != null && o instanceof NamedList) {

defaults = SolrParams.toSolrParams((NamedList) o);

  }

}

 

  }

 

  /**

   * Handles a query request, this method must be thread safe.

   * 

   * Information about the request may be obtained from req and

   * response information may be set using rsp.

   * 

   * There are no mandatory actions that handleRequest must perform.

   * An empty handleRequest implementation would fulfill

   * all interface obligations.

   */

  public void handleRequest(SolrQueryRequest solrQueryRequest, 
SolrQueryResponse solrQueryResponse) {

 

log.info("handling request for BasicHelloRequestHandler: ");

 

//get request params

SolrParams params = solrQueryRequest.getParams();

String message = params.get(HelloParams.MESSAGE);

 

if (message == null)

{ 

  throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "message is 
mandatory");

}

 

 

log.info("get anumber ");

 

Integer anumber = params.getInt(HelloParams.ANUMBER);

if (anumber == null)

{

  anumber = defaults.getInt(HelloParams.ANUMBER);

}



 

 

int messageLength = message.length();

 

 

//write response

solrQueryResponse.add("yousaid", message);

solrQueryResponse.add("message length", messageLength);

solrQueryResponse.add("optionalNumber", anumber);

 

 

BasicHelloRequestHandler plugin

2010-11-29 Thread Hong-Thai Nguyen
Hi,

Thank for helping us.

I’m creating a ‘helloword’ plugin in Solr 1.4 in BasicHelloRequestHandler.java

In solrconfig.xml, I added:

 





 

   Default message 

   -10 

 

  

 

I verified ‘hello’ plugin is figured well at: 
http://localhost:8983/solr/admin/plugins

 

When I executed: http://localhost:8983/solr/select?qt=hello, the 
java.lang.AbstractMethodError raised:

type Rapport d'état

message null java.lang.AbstractMethodError at 
org.apache.solr.core.SolrCore.execute(SolrCore.java:1316) at 
org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:338) 
at 
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:241)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) 
at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) 
at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at 
java.lang.Thread.run(Thread.java:595) 

I supposed that handleRequest in the BasicHelloRequestHandler isn’t called.

Here’s BasicHelloRequestHandler .java code:

import com.polyspot.mercury.common.params.HelloParams;

import org.apache.solr.common.SolrException;

import org.apache.solr.common.params.SolrParams;

import org.apache.solr.common.util.NamedList;

import org.apache.solr.common.util.SimpleOrderedMap;

import org.apache.solr.request.SolrQueryRequest;

import org.apache.solr.request.SolrRequestHandler;

import org.apache.solr.response.SolrQueryResponse;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

 

import java.net.URL;

 

 

/**

 * User: nguyenht

 * Date: 26 nov. 2010

 */

public class BasicHelloRequestHandler implements SolrRequestHandler {

 

  protected static Logger log = 
LoggerFactory.getLogger(BasicHelloRequestHandler.class);

 

  protected NamedList initArgs = null;

  protected SolrParams defaults;

 

 

  /**

   * init will be called just once, immediately after creation.

   * The args are user-level initialization parameters that

   * may be specified when declaring a request handler in

   * solrconfig.xml

   */

  public void init(NamedList args) {

log.info("initializing BasicHelloRequestHandler: " + args);

 

initArgs = args;

 

if (args != null) {

  Object o = args.get("defaults");

  if (o != null && o instanceof NamedList) {

defaults = SolrParams.toSolrParams((NamedList) o);

  }

}

 

  }

 

  /**

   * Handles a query request, this method must be thread safe.

   * 

   * Information about the request may be obtained from req and

   * response information may be set using rsp.

   * 

   * There are no mandatory actions that handleRequest must perform.

   * An empty handleRequest implementation would fulfill

   * all interface obligations.

   */

  public void handleRequest(SolrQueryRequest solrQueryRequest, 
SolrQueryResponse solrQueryResponse) {

 

log.info("handling request for BasicHelloRequestHandler: ");

 

//get request params

SolrParams params = solrQueryRequest.getParams();

String message = params.get(HelloParams.MESSAGE);

 

if (message == null)

{ 

  throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "message is 
mandatory");

}

 

 

log.info("get anumber ");

 

Integer anumber = params.getInt(HelloParams.ANUMBER);

if (anumber == null)

{

  anumber = defaults.getInt(HelloParams.ANUMBER);

}



 

 

int messageLength = message.length();

 

 

//write response

solrQueryResponse.add("yousaid", message);

solrQueryResponse.add("message length", messageLength);

solrQueryResponse.add("optionalNumber", anumber);

 

 

  }

 

  /*

  methods below are for JMX info

   */

 

 public String getName() {

return this.getClass().getName();

  }

 

  public String getVersion() {

return "1";  //TODO implement this

  }

 

  public String getDescription() {

return "hello";  //TODO implement this

  }

 

  public Category getCategory() {

return Category.OTHER;  //TODO implement this

  }

 

  public String getSourceId() {

return "some hello source id from " + 
BasicHelloRequestHandler.class.getCanonicalNam