You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Tom Mortimer <to...@flax.co.uk> on 2011/08/10 17:05:32 UTC

Error loading a custom request handler in Solr 4.0

Hi,

Apologies if this is really basic. I'm trying to learn how to create a
custom request handler, so I wrote the minimal class (attached), compiled
and jar'd it, and placed it in example/lib. I added this to solrconfig.xml:

    <requestHandler name="/flaxtest" class="FlaxTestHandler" />

When I started Solr with java -jar start.jar, I got this:

    ...
    SEVERE: java.lang.NoClassDefFoundError:
org/apache/solr/handler/RequestHandlerBase
at java.lang.ClassLoader.defineClass1(Native Method)
        ...

So I copied all the dist/*.jar files into lib and tried again. This time it
seemed to start ok, but browsing to http://localhost:8983/solr/ displayed
this:

    org.apache.solr.common.SolrException: Error Instantiating Request
Handler, FlaxTestHandler is not a org.apache.solr.request.SolrRequestHandler

	at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:410) ...


Any ideas?

thanks,
Tom

Re: Error loading a custom request handler in Solr 4.0

Posted by Chris Hostetter <ho...@fucit.org>.
: custom request handler, so I wrote the minimal class (attached), compiled
: and jar'd it, and placed it in example/lib. I added this to solrconfig.xml:

that's the crux of hte issue.

example/lib is where the jetty libraries live -- not solr plugins.

you should either put your custom jar's in the "lib" dir of your solr home 
(ie: example/solr/lib) or put it in a directory of your choice that you 
refer to from your solrconfig.xml file using a <lib/> directive.

: So I copied all the dist/*.jar files into lib and tried again. This time it

ouch ... make sure you remove *all* of those, or you will have no end of 
random obscure classpath issues at random times as jars are sometimes 
loaded from the war and sometimes loaded from that directory.


-Hoss

Re: Error loading a custom request handler in Solr 4.0

Posted by Tom Mortimer <to...@flax.co.uk>.
Thanks Simon. I'll try again tomorrow.

Tom

On 10 August 2011 18:46, simon <mt...@gmail.com> wrote:

> This is in trunk (up to date). Compiler is 1.6.0_26
>
> classpath was
>  dist/apache-solr-solrj-4.0-SNAPSHOT.jar:dist/apache-solr-core-4.0-SNAPSHOT.jar
> built from trunk just prior by 'ant dist'
>
> I'd try again with a clean trunk .
>
> -Simon
>
> On Wed, Aug 10, 2011 at 1:20 PM, Tom Mortimer <to...@flax.co.uk> wrote:
> > Interesting.. is this in trunk (4.0)? Maybe I've broken mine somehow!
> >
> > What classpath did you use for compiling? And did you copy anything other
> > than the new jar into lib/ ?
> >
> > thanks,
> > Tom
> >
> >
> > On 10 August 2011 18:07, simon <mt...@gmail.com> wrote:
> >
> >> It's working for me. Compiled, inserted in solr/lib, added the config
> >> line to solrconfig.
> >>
> >>  when I send a /flaxtest request i get
> >>
> >> <response>
> >> <lst name="responseHeader">
> >> <int name="status">0</int>
> >> <int name="QTime">16</int>
> >> </lst>
> >> <str name="FlaxTest">Hello!</str>
> >> </response>
> >>
> >> I was doing this within a core defined in solr.xml
> >>
> >> -Simon
> >>
> >> On Wed, Aug 10, 2011 at 11:46 AM, Tom Mortimer <to...@flax.co.uk> wrote:
> >> > Sure -
> >> >
> >> > import org.apache.solr.request.SolrQueryRequest;
> >> > import org.apache.solr.response.SolrQueryResponse;
> >> > import org.apache.solr.handler.RequestHandlerBase;
> >> >
> >> > public class FlaxTestHandler extends RequestHandlerBase {
> >> >
> >> >    public FlaxTestHandler() { }
> >> >
> >> >    public void handleRequestBody(SolrQueryRequest req,
> SolrQueryResponse
> >> > rsp)
> >> >        throws Exception
> >> >    {
> >> >        rsp.add("FlaxTest", "Hello!");
> >> >    }
> >> >
> >> >    public String getDescription() { return "Flax"; }
> >> >    public String getSourceId() { return "Flax"; }
> >> >    public String getSource() { return "Flax"; }
> >> >    public String getVersion() { return "Flax"; }
> >> >
> >> > }
> >> >
> >> >
> >> >
> >> > On 10 August 2011 16:43, simon <mt...@gmail.com> wrote:
> >> >
> >> >> Th attachment isn't showing up (in gmail, at least). Can you inline
> >> >> the relevant bits of code ?
> >> >>
> >> >> On Wed, Aug 10, 2011 at 11:05 AM, Tom Mortimer <to...@flax.co.uk>
> wrote:
> >> >> > Hi,
> >> >> > Apologies if this is really basic. I'm trying to learn how to
> create a
> >> >> > custom request handler, so I wrote the minimal class (attached),
> >> compiled
> >> >> > and jar'd it, and placed it in example/lib. I added this to
> >> >> solrconfig.xml:
> >> >> >     <requestHandler name="/flaxtest" class="FlaxTestHandler" />
> >> >> > When I started Solr with java -jar start.jar, I got this:
> >> >> >     ...
> >> >> >     SEVERE: java.lang.NoClassDefFoundError:
> >> >> > org/apache/solr/handler/RequestHandlerBase
> >> >> > at java.lang.ClassLoader.defineClass1(Native Method)
> >> >> >         ...
> >> >> > So I copied all the dist/*.jar files into lib and tried again. This
> >> time
> >> >> it
> >> >> > seemed to start ok, but browsing to
> >> http://localhost:8983/solr/displayed
> >> >> > this:
> >> >> >     org.apache.solr.common.SolrException: Error Instantiating
> Request
> >> >> > Handler, FlaxTestHandler is not a
> >> >> org.apache.solr.request.SolrRequestHandler
> >> >> >
> >> >> >       at
> >> org.apache.solr.core.SolrCore.createInstance(SolrCore.java:410)
> >> >> ...
> >> >> >
> >> >> > Any ideas?
> >> >> > thanks,
> >> >> > Tom
> >> >> >
> >> >>
> >> >
> >>
> >
>

Re: Error loading a custom request handler in Solr 4.0

Posted by simon <mt...@gmail.com>.
This is in trunk (up to date). Compiler is 1.6.0_26

classpath was  dist/apache-solr-solrj-4.0-SNAPSHOT.jar:dist/apache-solr-core-4.0-SNAPSHOT.jar
built from trunk just prior by 'ant dist'

I'd try again with a clean trunk .

-Simon

On Wed, Aug 10, 2011 at 1:20 PM, Tom Mortimer <to...@flax.co.uk> wrote:
> Interesting.. is this in trunk (4.0)? Maybe I've broken mine somehow!
>
> What classpath did you use for compiling? And did you copy anything other
> than the new jar into lib/ ?
>
> thanks,
> Tom
>
>
> On 10 August 2011 18:07, simon <mt...@gmail.com> wrote:
>
>> It's working for me. Compiled, inserted in solr/lib, added the config
>> line to solrconfig.
>>
>>  when I send a /flaxtest request i get
>>
>> <response>
>> <lst name="responseHeader">
>> <int name="status">0</int>
>> <int name="QTime">16</int>
>> </lst>
>> <str name="FlaxTest">Hello!</str>
>> </response>
>>
>> I was doing this within a core defined in solr.xml
>>
>> -Simon
>>
>> On Wed, Aug 10, 2011 at 11:46 AM, Tom Mortimer <to...@flax.co.uk> wrote:
>> > Sure -
>> >
>> > import org.apache.solr.request.SolrQueryRequest;
>> > import org.apache.solr.response.SolrQueryResponse;
>> > import org.apache.solr.handler.RequestHandlerBase;
>> >
>> > public class FlaxTestHandler extends RequestHandlerBase {
>> >
>> >    public FlaxTestHandler() { }
>> >
>> >    public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse
>> > rsp)
>> >        throws Exception
>> >    {
>> >        rsp.add("FlaxTest", "Hello!");
>> >    }
>> >
>> >    public String getDescription() { return "Flax"; }
>> >    public String getSourceId() { return "Flax"; }
>> >    public String getSource() { return "Flax"; }
>> >    public String getVersion() { return "Flax"; }
>> >
>> > }
>> >
>> >
>> >
>> > On 10 August 2011 16:43, simon <mt...@gmail.com> wrote:
>> >
>> >> Th attachment isn't showing up (in gmail, at least). Can you inline
>> >> the relevant bits of code ?
>> >>
>> >> On Wed, Aug 10, 2011 at 11:05 AM, Tom Mortimer <to...@flax.co.uk> wrote:
>> >> > Hi,
>> >> > Apologies if this is really basic. I'm trying to learn how to create a
>> >> > custom request handler, so I wrote the minimal class (attached),
>> compiled
>> >> > and jar'd it, and placed it in example/lib. I added this to
>> >> solrconfig.xml:
>> >> >     <requestHandler name="/flaxtest" class="FlaxTestHandler" />
>> >> > When I started Solr with java -jar start.jar, I got this:
>> >> >     ...
>> >> >     SEVERE: java.lang.NoClassDefFoundError:
>> >> > org/apache/solr/handler/RequestHandlerBase
>> >> > at java.lang.ClassLoader.defineClass1(Native Method)
>> >> >         ...
>> >> > So I copied all the dist/*.jar files into lib and tried again. This
>> time
>> >> it
>> >> > seemed to start ok, but browsing to
>> http://localhost:8983/solr/displayed
>> >> > this:
>> >> >     org.apache.solr.common.SolrException: Error Instantiating Request
>> >> > Handler, FlaxTestHandler is not a
>> >> org.apache.solr.request.SolrRequestHandler
>> >> >
>> >> >       at
>> org.apache.solr.core.SolrCore.createInstance(SolrCore.java:410)
>> >> ...
>> >> >
>> >> > Any ideas?
>> >> > thanks,
>> >> > Tom
>> >> >
>> >>
>> >
>>
>

Re: Error loading a custom request handler in Solr 4.0

Posted by Tom Mortimer <to...@flax.co.uk>.
Interesting.. is this in trunk (4.0)? Maybe I've broken mine somehow!

What classpath did you use for compiling? And did you copy anything other
than the new jar into lib/ ?

thanks,
Tom


On 10 August 2011 18:07, simon <mt...@gmail.com> wrote:

> It's working for me. Compiled, inserted in solr/lib, added the config
> line to solrconfig.
>
>  when I send a /flaxtest request i get
>
> <response>
> <lst name="responseHeader">
> <int name="status">0</int>
> <int name="QTime">16</int>
> </lst>
> <str name="FlaxTest">Hello!</str>
> </response>
>
> I was doing this within a core defined in solr.xml
>
> -Simon
>
> On Wed, Aug 10, 2011 at 11:46 AM, Tom Mortimer <to...@flax.co.uk> wrote:
> > Sure -
> >
> > import org.apache.solr.request.SolrQueryRequest;
> > import org.apache.solr.response.SolrQueryResponse;
> > import org.apache.solr.handler.RequestHandlerBase;
> >
> > public class FlaxTestHandler extends RequestHandlerBase {
> >
> >    public FlaxTestHandler() { }
> >
> >    public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse
> > rsp)
> >        throws Exception
> >    {
> >        rsp.add("FlaxTest", "Hello!");
> >    }
> >
> >    public String getDescription() { return "Flax"; }
> >    public String getSourceId() { return "Flax"; }
> >    public String getSource() { return "Flax"; }
> >    public String getVersion() { return "Flax"; }
> >
> > }
> >
> >
> >
> > On 10 August 2011 16:43, simon <mt...@gmail.com> wrote:
> >
> >> Th attachment isn't showing up (in gmail, at least). Can you inline
> >> the relevant bits of code ?
> >>
> >> On Wed, Aug 10, 2011 at 11:05 AM, Tom Mortimer <to...@flax.co.uk> wrote:
> >> > Hi,
> >> > Apologies if this is really basic. I'm trying to learn how to create a
> >> > custom request handler, so I wrote the minimal class (attached),
> compiled
> >> > and jar'd it, and placed it in example/lib. I added this to
> >> solrconfig.xml:
> >> >     <requestHandler name="/flaxtest" class="FlaxTestHandler" />
> >> > When I started Solr with java -jar start.jar, I got this:
> >> >     ...
> >> >     SEVERE: java.lang.NoClassDefFoundError:
> >> > org/apache/solr/handler/RequestHandlerBase
> >> > at java.lang.ClassLoader.defineClass1(Native Method)
> >> >         ...
> >> > So I copied all the dist/*.jar files into lib and tried again. This
> time
> >> it
> >> > seemed to start ok, but browsing to
> http://localhost:8983/solr/displayed
> >> > this:
> >> >     org.apache.solr.common.SolrException: Error Instantiating Request
> >> > Handler, FlaxTestHandler is not a
> >> org.apache.solr.request.SolrRequestHandler
> >> >
> >> >       at
> org.apache.solr.core.SolrCore.createInstance(SolrCore.java:410)
> >> ...
> >> >
> >> > Any ideas?
> >> > thanks,
> >> > Tom
> >> >
> >>
> >
>

Re: Error loading a custom request handler in Solr 4.0

Posted by simon <mt...@gmail.com>.
It's working for me. Compiled, inserted in solr/lib, added the config
line to solrconfig.

  when I send a /flaxtest request i get

<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">16</int>
</lst>
<str name="FlaxTest">Hello!</str>
</response>

I was doing this within a core defined in solr.xml

-Simon

On Wed, Aug 10, 2011 at 11:46 AM, Tom Mortimer <to...@flax.co.uk> wrote:
> Sure -
>
> import org.apache.solr.request.SolrQueryRequest;
> import org.apache.solr.response.SolrQueryResponse;
> import org.apache.solr.handler.RequestHandlerBase;
>
> public class FlaxTestHandler extends RequestHandlerBase {
>
>    public FlaxTestHandler() { }
>
>    public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse
> rsp)
>        throws Exception
>    {
>        rsp.add("FlaxTest", "Hello!");
>    }
>
>    public String getDescription() { return "Flax"; }
>    public String getSourceId() { return "Flax"; }
>    public String getSource() { return "Flax"; }
>    public String getVersion() { return "Flax"; }
>
> }
>
>
>
> On 10 August 2011 16:43, simon <mt...@gmail.com> wrote:
>
>> Th attachment isn't showing up (in gmail, at least). Can you inline
>> the relevant bits of code ?
>>
>> On Wed, Aug 10, 2011 at 11:05 AM, Tom Mortimer <to...@flax.co.uk> wrote:
>> > Hi,
>> > Apologies if this is really basic. I'm trying to learn how to create a
>> > custom request handler, so I wrote the minimal class (attached), compiled
>> > and jar'd it, and placed it in example/lib. I added this to
>> solrconfig.xml:
>> >     <requestHandler name="/flaxtest" class="FlaxTestHandler" />
>> > When I started Solr with java -jar start.jar, I got this:
>> >     ...
>> >     SEVERE: java.lang.NoClassDefFoundError:
>> > org/apache/solr/handler/RequestHandlerBase
>> > at java.lang.ClassLoader.defineClass1(Native Method)
>> >         ...
>> > So I copied all the dist/*.jar files into lib and tried again. This time
>> it
>> > seemed to start ok, but browsing to http://localhost:8983/solr/displayed
>> > this:
>> >     org.apache.solr.common.SolrException: Error Instantiating Request
>> > Handler, FlaxTestHandler is not a
>> org.apache.solr.request.SolrRequestHandler
>> >
>> >       at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:410)
>> ...
>> >
>> > Any ideas?
>> > thanks,
>> > Tom
>> >
>>
>

Re: Error loading a custom request handler in Solr 4.0

Posted by Tom Mortimer <to...@flax.co.uk>.
Sure -

import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.handler.RequestHandlerBase;

public class FlaxTestHandler extends RequestHandlerBase {

    public FlaxTestHandler() { }

    public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse
rsp)
        throws Exception
    {
        rsp.add("FlaxTest", "Hello!");
    }

    public String getDescription() { return "Flax"; }
    public String getSourceId() { return "Flax"; }
    public String getSource() { return "Flax"; }
    public String getVersion() { return "Flax"; }

}



On 10 August 2011 16:43, simon <mt...@gmail.com> wrote:

> Th attachment isn't showing up (in gmail, at least). Can you inline
> the relevant bits of code ?
>
> On Wed, Aug 10, 2011 at 11:05 AM, Tom Mortimer <to...@flax.co.uk> wrote:
> > Hi,
> > Apologies if this is really basic. I'm trying to learn how to create a
> > custom request handler, so I wrote the minimal class (attached), compiled
> > and jar'd it, and placed it in example/lib. I added this to
> solrconfig.xml:
> >     <requestHandler name="/flaxtest" class="FlaxTestHandler" />
> > When I started Solr with java -jar start.jar, I got this:
> >     ...
> >     SEVERE: java.lang.NoClassDefFoundError:
> > org/apache/solr/handler/RequestHandlerBase
> > at java.lang.ClassLoader.defineClass1(Native Method)
> >         ...
> > So I copied all the dist/*.jar files into lib and tried again. This time
> it
> > seemed to start ok, but browsing to http://localhost:8983/solr/displayed
> > this:
> >     org.apache.solr.common.SolrException: Error Instantiating Request
> > Handler, FlaxTestHandler is not a
> org.apache.solr.request.SolrRequestHandler
> >
> >       at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:410)
> ...
> >
> > Any ideas?
> > thanks,
> > Tom
> >
>

Re: Error loading a custom request handler in Solr 4.0

Posted by simon <mt...@gmail.com>.
Th attachment isn't showing up (in gmail, at least). Can you inline
the relevant bits of code ?

On Wed, Aug 10, 2011 at 11:05 AM, Tom Mortimer <to...@flax.co.uk> wrote:
> Hi,
> Apologies if this is really basic. I'm trying to learn how to create a
> custom request handler, so I wrote the minimal class (attached), compiled
> and jar'd it, and placed it in example/lib. I added this to solrconfig.xml:
>     <requestHandler name="/flaxtest" class="FlaxTestHandler" />
> When I started Solr with java -jar start.jar, I got this:
>     ...
>     SEVERE: java.lang.NoClassDefFoundError:
> org/apache/solr/handler/RequestHandlerBase
> at java.lang.ClassLoader.defineClass1(Native Method)
>         ...
> So I copied all the dist/*.jar files into lib and tried again. This time it
> seemed to start ok, but browsing to http://localhost:8983/solr/ displayed
> this:
>     org.apache.solr.common.SolrException: Error Instantiating Request
> Handler, FlaxTestHandler is not a org.apache.solr.request.SolrRequestHandler
>
> 	at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:410) ...
>
> Any ideas?
> thanks,
> Tom
>