: 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
: -Dcom.sun.management.jmxremote -jar start.jar") I can't connect to

have you considered the possibility that when you start with JMX enabled 
it just happens to take longer then 5 seconds for the port to start up?

FWIW: using Runtime.exec in java to launch another java program seems 
extremely crackpot.  if you want Solr to run in a servlet container, and 
you really want your own code to exist in the same app, have you 
considered...
  1) making your app a webapp that also runs in that container
  2) coompiling a servlet container (like Jetty) into your app and loading 
the solr webap programaticly?

#1 is probably the sanest, #2 can be accomplished fairly easily (it's what 
some of the Jetty based solr tests do)


: 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?
: 
: /Tim
: 
: 
: import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
: import org.apache.solr.client.solrj.SolrQuery;
: import java.net.URL;
: import java.net.URLConnection;
: import java.io.File;
: 
: class StartSolr {
: 
:    public static void main(String[] args) {
:       try {
:           String cmd = "java -Dcom.sun.management.jmxremote -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);
:           Thread.sleep(5*1000);
: 
:           URL url = new URL("http://localhost:8983/solr";);
:           URLConnection connection = url.openConnection();
:           Object content = connection.getContent();
:           System.out.println(content);
:           System.out.println("Success");
:       }
:       catch (Exception e) {
:           e.printStackTrace();
:       }
:    }
: }
: 



-Hoss

Reply via email to