lucene-solr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim TerlegÄrd <>
Subject Starting solr and connecting to it in the same process
Date Wed, 10 Feb 2010 09:35:43 GMT
There is something really interesting going on when I try to start
Solr and then connect to it in the same process. I get a "connection
refused" error. The code I try to use is found below. If I start solr
with runtime.exec("java -jar start.jar") it works fine to connect to
it afterwards, but if I start solr with runtime.exec("java -jar start.jar") I can't connect to
solr. It is possible to connect with the web browser however, or any
other program, even with the same code that fails when it's in the
same process.

I just can't figure out why I can't connect to solr. Anyone have any hints?


import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.SolrQuery;

class StartSolr {

   public static void main(String[] args) {
      try {
          String cmd = "java -jar start.jar";
          String cmd2 = "java -jar start.jar";  // works
          File workingDir = new File("/some/path/apache-1.4.0/example");
          Runtime.getRuntime().exec(cmd2, null, workingDir);

          URL url = new URL("http://localhost:8983/solr");
          URLConnection connection = url.openConnection();
          Object content = connection.getContent();
      catch (Exception e) {

View raw message