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 Hans-Peter Stricker <st...@epublius.de> on 2013/05/27 14:15:19 UTC

A strange RemoteSolrException

Hello,

I'm writing my first little Solrj program, but don't get it running because of an RemoteSolrException: Server at http://localhost:8983/solr returned non ok status:404

The server is definitely running and the url works in the browser.

I am working with Solr 4.3.0.

This is my source code:

public static void main(String[] args) {

        String url = "http://localhost:8983/solr";
        SolrServer server;
        
        try {
            server = new HttpSolrServer(url);
            server.ping();
       } catch (Exception ex) {
            ex.printStackTrace();
       }
}

with the stack trace:

org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Server at http://localhost:8983/solr returned non ok status:404, message:Not Found
 at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:372)
 at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:180)
 at org.apache.solr.client.solrj.request.SolrPing.process(SolrPing.java:62)
 at org.apache.solr.client.solrj.SolrServer.ping(SolrServer.java:293)
 at de.epublius.blogindexer.App.main(App.java:47)

If I call server.shutdown(), there is no such exception, but for almost all other SolrServer-methods.

What am I doing wrong?

Thanks in advance

Hans-Peter

Re: A strange RemoteSolrException

Posted by Shawn Heisey <so...@elyograg.org>.
On 5/27/2013 8:34 AM, Hans-Peter Stricker wrote:
> Dear Shawn, dear Shalin,
> 
> thanks for your valuable replies!
> 
> Could/should I have known better (by reading more carefully the manual)?

I just looked at the wiki.  The SolrJ wiki page doesn't mention using
the core name, which I find surprising, because Solr has had multicore
capability for a REALLY long time, and it has been the default in the
example since the 3.x days.

The only wiki example code that has a URL with a core name is the code
in the database example:

http://wiki.apache.org/solr/Solrj#Reading_data_from_a_database

Oddly enough, I wrote and contributed that example, but it was a few
years ago and I haven't looked at it since.

When I find the time, I will go through the SolrJ wiki page and bring it
into this decade.  Multicore operation is very likely going to be
required on Solr 5.0 when that version comes out.

If anyone else wants to update the wiki, feel free.  If you don't
already have edit permission, just ask.  We can add your wiki username
to the contributors group.

Thanks,
Shawn


Re: A strange RemoteSolrException

Posted by Hans-Peter Stricker <st...@epublius.de>.
Dear Shawn, dear Shalin,

thanks for your valuable replies!

Could/should I have known better (by reading more carefully the manual)?

I'll try to fix it - and I am confident that it will work!

Best regards

Hans

--------------------------------------------------
From: "Shawn Heisey" <so...@elyograg.org>
Sent: Monday, May 27, 2013 4:29 PM
To: <so...@lucene.apache.org>
Subject: Re: A strange RemoteSolrException

> On 5/27/2013 8:24 AM, Hans-Peter Stricker wrote:
>> Yes, I started it up with java -Dsolr.solr.home=example-DIH/solr -jar
>> start.jar.
> 
> That explains it.  See my other reply.  The solr.xml file for
> example-DIH does not have a defaultCoreName attribute.
> 
> Thanks,
> Shawn
> 
> 


Re: A strange RemoteSolrException

Posted by Shawn Heisey <so...@elyograg.org>.
On 5/27/2013 8:24 AM, Hans-Peter Stricker wrote:
> Yes, I started it up with java -Dsolr.solr.home=example-DIH/solr -jar
> start.jar.

That explains it.  See my other reply.  The solr.xml file for
example-DIH does not have a defaultCoreName attribute.

Thanks,
Shawn


Re: A strange RemoteSolrException

Posted by Hans-Peter Stricker <st...@epublius.de>.
Yes, I started it up with java -Dsolr.solr.home=example-DIH/solr -jar 
start.jar.

Without the java options I don't get the expections neither! (I should have 
checked.)

What now?

--------------------------------------------------
From: "Shalin Shekhar Mangar" <sh...@gmail.com>
Sent: Monday, May 27, 2013 3:58 PM
To: <so...@lucene.apache.org>
Subject: Re: A strange RemoteSolrException

> I downloaded solr 4.3.0, started it up with java -jar start.jar (from
> inside the example directory) and executed your program. No exceptions are
> thrown. Is there something you did differently?
>
>
> On Mon, May 27, 2013 at 5:45 PM, Hans-Peter Stricker
> <st...@epublius.de>wrote:
>
>> Hello,
>>
>> I'm writing my first little Solrj program, but don't get it running
>> because of an RemoteSolrException: Server at 
>> http://localhost:8983/solrreturned non ok status:404
>>
>> The server is definitely running and the url works in the browser.
>>
>> I am working with Solr 4.3.0.
>>
>> This is my source code:
>>
>> public static void main(String[] args) {
>>
>>         String url = "http://localhost:8983/solr";
>>         SolrServer server;
>>
>>         try {
>>             server = new HttpSolrServer(url);
>>             server.ping();
>>        } catch (Exception ex) {
>>             ex.printStackTrace();
>>        }
>> }
>>
>> with the stack trace:
>>
>> org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException:
>> Server at http://localhost:8983/solr returned non ok status:404,
>> message:Not Found
>>  at
>> org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:372)
>>  at
>> org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:180)
>>  at 
>> org.apache.solr.client.solrj.request.SolrPing.process(SolrPing.java:62)
>>  at org.apache.solr.client.solrj.SolrServer.ping(SolrServer.java:293)
>>  at de.epublius.blogindexer.App.main(App.java:47)
>>
>> If I call server.shutdown(), there is no such exception, but for almost
>> all other SolrServer-methods.
>>
>> What am I doing wrong?
>>
>> Thanks in advance
>>
>> Hans-Peter
>>
>
>
>
> -- 
> Regards,
> Shalin Shekhar Mangar.
> 


Re: A strange RemoteSolrException

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
I downloaded solr 4.3.0, started it up with java -jar start.jar (from
inside the example directory) and executed your program. No exceptions are
thrown. Is there something you did differently?


On Mon, May 27, 2013 at 5:45 PM, Hans-Peter Stricker
<st...@epublius.de>wrote:

> Hello,
>
> I'm writing my first little Solrj program, but don't get it running
> because of an RemoteSolrException: Server at http://localhost:8983/solrreturned non ok status:404
>
> The server is definitely running and the url works in the browser.
>
> I am working with Solr 4.3.0.
>
> This is my source code:
>
> public static void main(String[] args) {
>
>         String url = "http://localhost:8983/solr";
>         SolrServer server;
>
>         try {
>             server = new HttpSolrServer(url);
>             server.ping();
>        } catch (Exception ex) {
>             ex.printStackTrace();
>        }
> }
>
> with the stack trace:
>
> org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException:
> Server at http://localhost:8983/solr returned non ok status:404,
> message:Not Found
>  at
> org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:372)
>  at
> org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:180)
>  at org.apache.solr.client.solrj.request.SolrPing.process(SolrPing.java:62)
>  at org.apache.solr.client.solrj.SolrServer.ping(SolrServer.java:293)
>  at de.epublius.blogindexer.App.main(App.java:47)
>
> If I call server.shutdown(), there is no such exception, but for almost
> all other SolrServer-methods.
>
> What am I doing wrong?
>
> Thanks in advance
>
> Hans-Peter
>



-- 
Regards,
Shalin Shekhar Mangar.

Re: A strange RemoteSolrException

Posted by Shawn Heisey <so...@elyograg.org>.
On 5/27/2013 6:15 AM, Hans-Peter Stricker wrote:
> I'm writing my first little Solrj program, but don't get it running because of an RemoteSolrException: Server at http://localhost:8983/solr returned non ok status:404
> 
> The server is definitely running and the url works in the browser.
> 
> I am working with Solr 4.3.0.

Hans,

To use SolrJ against the URL that you provided, you must have a
defaultCoreName attribute in solr.xml that points at a core that exists.
 The defaultCoreName used in the old-style solr.xml (4.3.1 and earlier)
is collection1.  The new-style solr.xml (4.4 and later, when released)
does not define a default core name.

A far safer option for any Solr client API is to use a base URL that
includes the name of the core.  If you are using SolrCloud, you can
optionally use the collection name instead.  This option will be
required for the new style solr.xml.  Here's the format:

http://server:port/solr/corename

In the UI, the cores that exist will be in a left-side dropdown that
says "Core Selector."  If you are using SolrCloud, you can click on the
Cloud option in the UI and then on Graph to see the collection names.
They will be on the left side of the graph.

NB: If you are using SolrCloud, it is better to use CloudSolrServer
instead of HttpSolrServer.

Thanks,
Shawn