0

I try to connect to the reasoner Racer. But I get the connectivity error. I know that there are many threads about the following error. I read most of them. But I could not solve this issue. Here is my code:

import com.racersystems.racer.Reasoner;
import com.racersystems.racer.ReasonerFactory;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.semanticweb.owlapi.reasoner.*;

import java.io.File;
public class Test4 {
    public static void main(String[] args) {
         File file=new File("C:\\IdeaProjects\\second\\edo.owl");
         OWLOntologyManager owlOntologyManager=  OWLManager.createOWLOntologyManager();
         OWLOntology owlOntology= null;
         try {
             owlOntology = owlOntologyManager.loadOntologyFromOntologyDocument(file);
             OWLReasoner owlreasoner=new Reasoner.ReasonerFactory().createReasoner(owlOntology);
             System.out.println(owlreasoner.isConsistent());
         } catch (OWLOntologyCreationException e) {
             e.printStackTrace();
     }         
   }
 }  

But I get the following error:

 Exception in thread "main" com.racersystems.racer.RacerRuntimeException: java.net.ConnectException: Connection refused: connect

          at com.racersystems.racer.Reasoner.<init>(Unknown Source)

          at com.racersystems.racer.Reasoner$ReasonerFactory.createReasoner(Unknown Source)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at java.lang.reflect.Method.invoke(Method.java:497)

          at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

 Caused by: java.net.ConnectException: Connection refused: connect

          at java.net.DualStackPlainSocketImpl.connect0(Native Method)

          at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)

          at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)

          at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

          at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)

          at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)

          at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

          at java.net.Socket.connect(Socket.java:589)

          at java.net.Socket.connect(Socket.java:538)

          at java.net.Socket.<init>(Socket.java:434)

          at java.net.Socket.<init>(Socket.java:244)

          at com.racersystems.racer.SocketAdapter.<init>(Unknown Source)

          ... 8 more

The error is generated because of the following row:

  OWLReasoner owlreasoner=new Reasoner.ReasonerFactory().createReasoner(owlOntology); 

I have owlapi-bin.jar and racer.jar under the lib in Intellij. I think the Server which is Racer Reasoner must be open on my Computer. Therefore I have Racer and RacerPorter open on my Computer. Many thanks for your help.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • Did you get any errors from the Racer server when you started it? Do you have any firewalls running on your machine? – Ignazio Jul 03 '15 at 08:54
  • Firewall does not run. – javaowlapi Jul 03 '15 at 14:27
  • I do not get any Errors from Racer when I start it. But when I run the Java program, after showing the above errors, the execution does not terminate and it is still running. I had to terminate the execution manually by clicking the stop button. Then I can see in the terminal of racer the error: "error during socket Operation: an available Connection was closed by remote host. – javaowlapi Jul 03 '15 at 14:45
  • @Ignazio: Firewall and Windows Defender are not running. Shall I change the settings for "allowing the communication of programms through the firewall" under control panel-> System -> Windows firewall? If yes, for Racer or for Intellij? – javaowlapi Jul 03 '15 at 14:48
  • Make sure there's only one instance of your program running - if there was one left running by accident, it might have kept your local port busy. – Ignazio Jul 03 '15 at 14:50
  • @Ignazio: thank you for your answer. I will check it again. – javaowlapi Jul 05 '15 at 10:40

0 Answers0