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.