I am getting HTTP Version Not Supported (505)Error

View: New views
4 Messages — Rating Filter:   Alert me  

I am getting HTTP Version Not Supported (505)Error

by Edukondalu Avula :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Friends,

I am working on Apache solr for indexing data by using java programming.
For Indexing data i used tomcat server and i started solr, i prepared url for indexing data. i given that url in any browser it's working (indexed the data). I given the prepared url in URL calss i got the HTTP Version Not Supported and the error code is 505.

My Code is as follows

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ejb.bprocess.cataloguing;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;

/**
*
* @author Edukondalu
*/
public class TestSolr {

public static void main(String[] args) throws MalformedURLException, IOException {
try {
String solrUrl = "http://localhost:9090/apache-solr";

String strToAdd = "<add><doc><field name=\"CatalogueRecordID\">121</field><field name=\"OwnerLibraryID\">1</field><field name=\"ID\">121_1</field></doc></add>";

String urlStr = solrUrl + "/update?stream.body=" + strToAdd;
System.out.println(".....................SOLR_SERVER_URL: " + urlStr);
URL indexUrl = new URL(urlStr);
HttpURLConnection indexConnection = (HttpURLConnection) indexUrl.openConnection();
indexConnection.setRequestMethod("POST");
indexConnection.connect();
int code = indexConnection.getResponseCode();
System.out.println(".................Indexing..code: " + code);
System.out.println(".............Resp Msg For Indexing: " + indexConnection.getResponseMessage());
System.out.println(".....................RequestMethod:" + indexConnection.getRequestMethod());
String commitCmd = solrUrl + "/update?stream.body=<commit/>";
System.out.println(".....................commitCmd: " + commitCmd);

} catch (Exception e) {
e.printStackTrace();
}
}
}



the output is

.....................SOLR_SERVER_URL: http://localhost:9090/apache-solr/update?stream.body=<add><doc><field name="CatalogueRecordID">121</field><field name="OwnerLibraryID">1</field><field name="ID">121_1</field></doc></add>
.................Indexing..code: 505
.............Resp Msg For Indexing: HTTP Version Not Supported
.....................RequestMethod:POST


If any have an idea help me

Re: I am getting HTTP Version Not Supported (505)Error

by Koji Sekiguchi-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Edukondalu,

Beside the question, are you aware of Solrj - Java API for Solr.

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

Koji

Edukondalu Avula wrote:

> Hi Friends,
>
> I am working on Apache solr for indexing data by using java programming.
> For Indexing data i used tomcat server and i started solr, i prepared url
> for indexing data. i given that url in any browser it's working (indexed the
> data). I given the prepared url in URL calss i got the HTTP Version Not
> Supported and the error code is 505.
>
> My Code is as follows
>
> /*
> * To change this template, choose Tools | Templates
> * and open the template in the editor.
> */
> package ejb.bprocess.cataloguing;
>
> import java.io.IOException;
> import java.net.HttpURLConnection;
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.util.Properties;
>
> /**
> *
> * @author Edukondalu
> */
> public class TestSolr {
>
> public static void main(String[] args) throws MalformedURLException,
> IOException {
> try {
> String solrUrl = "http://localhost:9090/apache-solr";
>
> String strToAdd = "<add><doc><field
> name=\"CatalogueRecordID\">121</field><field
> name=\"OwnerLibraryID\">1</field><field
> name=\"ID\">121_1</field></doc></add>";
>
> String urlStr = solrUrl + "/update?stream.body=" + strToAdd;
> System.out.println(".....................SOLR_SERVER_URL: " + urlStr);
> URL indexUrl = new URL(urlStr);
> HttpURLConnection indexConnection = (HttpURLConnection)
> indexUrl.openConnection();
> indexConnection.setRequestMethod("POST");
> indexConnection.connect();
> int code = indexConnection.getResponseCode();
> System.out.println(".................Indexing..code: " + code);
> System.out.println(".............Resp Msg For Indexing: " +
> indexConnection.getResponseMessage());
> System.out.println(".....................RequestMethod:" +
> indexConnection.getRequestMethod());
> String commitCmd = solrUrl + "/update?stream.body=<commit/>";
> System.out.println(".....................commitCmd: " + commitCmd);
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
>
>
>
> the output is
>
> .....................SOLR_SERVER_URL:
> http://localhost:9090/apache-solr/update?stream.body=<add><doc><field
> name="CatalogueRecordID">121</field><field
> name="OwnerLibraryID">1</field><field name="ID">121_1</field></doc></add>
> .................Indexing..code: 505
> .............Resp Msg For Indexing: HTTP Version Not Supported
> .....................RequestMethod:POST
>
>
> If any have an idea help me
>  


Re: I am getting HTTP Version Not Supported (505)Error

by Edukondalu Avula :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Edukondalu Avula wrote:
Hi Friends,

I am working on Apache solr for indexing data by using java programming.
For Indexing data i used tomcat server and i started solr, i prepared url for indexing data. i given that url in any browser it's working (indexed the data). I given the prepared url in URL calss i got the HTTP Version Not Supported and the error code is 505.

My Code is as follows

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ejb.bprocess.cataloguing;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;

/**
*
* @author Edukondalu
*/
public class TestSolr {

public static void main(String[] args) throws MalformedURLException, IOException {
try {
String solrUrl = "http://localhost:9090/apache-solr";

String strToAdd = "<add><doc><field name=\"CatalogueRecordID\">121</field><field name=\"OwnerLibraryID\">1</field><field name=\"ID\">121_1</field></doc></add>";

String urlStr = solrUrl + "/update?stream.body=" + strToAdd;
System.out.println(".....................SOLR_SERVER_URL: " + urlStr);
URL indexUrl = new URL(urlStr);
HttpURLConnection indexConnection = (HttpURLConnection) indexUrl.openConnection();
indexConnection.setRequestMethod("POST");
indexConnection.connect();
int code = indexConnection.getResponseCode();
System.out.println(".................Indexing..code: " + code);
System.out.println(".............Resp Msg For Indexing: " + indexConnection.getResponseMessage());
System.out.println(".....................RequestMethod:" + indexConnection.getRequestMethod());
String commitCmd = solrUrl + "/update?stream.body=<commit/>";
System.out.println(".....................commitCmd: " + commitCmd);

} catch (Exception e) {
e.printStackTrace();
}
}
}



the output is

.....................SOLR_SERVER_URL: http://localhost:9090/apache-solr/update?stream.body=<add><doc><field name="CatalogueRecordID">121</field><field name="OwnerLibraryID">1</field><field name="ID">121_1</field></doc></add>
.................Indexing..code: 505
.............Resp Msg For Indexing: HTTP Version Not Supported
.....................RequestMethod:POST


If any have an idea help me

i written the above code in jdk1.4, but if we want to use solr it supports jdk1.5 or higher, that's way i used the above code from the url
http://wiki.apache.org/solr/UpdateXmlMessages#head-093b582f7af0691c99f4934d1702b8e9e2bcd5d3

Re: I am getting HTTP Version Not Supported (505)Error

by hossman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


: data). I given the prepared url in URL calss i got the HTTP Version Not
: Supported and the error code is 505.

Solr never generates that error code.  what servlet container are you
using?


: String urlStr = solrUrl + "/update?stream.body=" + strToAdd;
: System.out.println(".....................SOLR_SERVER_URL: " + urlStr);
: URL indexUrl = new URL(urlStr);
: HttpURLConnection indexConnection = (HttpURLConnection)
: indexUrl.openConnection();
: indexConnection.setRequestMethod("POST");
: indexConnection.connect();

this is a wild shot in the dark here about what might be causing your
problem, but you are creating a POST request without actually POSTing
anything (the stream.body param is a hack to let you send data as a URL
param, if you are putting it in the URL args you don't need POST, but if
you're sending data programaticly like this you might as well just use
POST

If SolrJ won't work for you, at least look at the code for SimplePostTool
as an example of how to POST data to solr.




-Hoss