Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

I am getting HTTP Version Not Supported (505)Error

843790Jul 9 2009 — edited Jul 9 2009
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.
/*
 * 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);

            URL commitUrl = new URL(commitCmd);
            HttpURLConnection commitConnection = (HttpURLConnection) commitUrl.openConnection();
            commitConnection.connect();
            code = commitConnection.getResponseCode();
            System.out.println(".............Commit Msg For Indexing: " + commitConnection.getResponseMessage());
            System.out.println(".................Commit..code: " + code);
            System.out.println(".....................RequestMethod:" + commitConnection.getRequestMethod());
        } 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
.....................commitCmd: http://localhost:9090/apache-solr/update?stream.body=<commit/>
.............Commit Msg For Indexing: OK
.................Commit..code: 200
.....................RequestMethod:GET
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2009
Added on Jul 9 2009
1 comment
740 views