cambridge-cares / TheWorldAvatar

A knowledge-graph-based digital twin of the world.
https://theworldavatar.io/
MIT License
87 stars 25 forks source link

Closing connection to Ontop endpoint triggers exception #388

Open kok-foong opened 2 years ago

kok-foong commented 2 years ago

11:20:49.881 |-WARN in o.s.b.f.s.DisposableBeanAdapter - Invocation of close method failed on bean with name 'setupVirtualRepository' org.eclipse.rdf4j.repository.RepositoryException: java.lang.NullPointerException at it.unibz.inf.ontop.rdf4j.repository.impl.OntopVirtualRepository.shutDownInternal(OntopVirtualRepository.java:102) at org.eclipse.rdf4j.repository.base.AbstractRepository.shutDown(AbstractRepository.java:51) at it.unibz.inf.ontop.rdf4j.repository.impl.OntopVirtualRepository.close(OntopVirtualRepository.java:124) at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:239) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:587) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:559) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1161) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:520) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1154) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1106) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1075) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:172) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1021) at it.unibz.inf.ontop.endpoint.OntopEndpointApplication.lambda$restart$1(OntopEndpointApplication.java:47) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.lang.NullPointerException: null at it.unibz.inf.ontop.rdf4j.repository.impl.OntopVirtualRepository.shutDownInternal(OntopVirtualRepository.java:100) ... 14 common frames omitted

kok-foong commented 2 years ago

The latest RemoteStoreClient now closes the connection after each query, this causes an issue if an agent is querying from the ontop endpoint repeatedly

kok-foong commented 2 years ago

Possible workaround is to avoid connecting to ontop directly and use the service keyword from blazegraph for all queries

kok-foong commented 2 years ago

It seems that even without closing the connection, I'm still getting a ClosedChannelException when connecting to ontop directly

kok-foong commented 2 years ago

Exception from ontop:

13:21:20.672 |-DEBUG in o.s.b.d.LoggingFailureAnalysisReporter - Application failed to start due to an exception org.springframework.boot.web.server.PortInUseException: Port 8080 is already in use at org.springframework.boot.web.server.PortInUseException.lambda$throwIfPortBindingException$0(PortInUseException.java:70) at org.springframework.boot.web.server.PortInUseException.lambda$ifPortBindingException$1(PortInUseException.java:85) at org.springframework.boot.web.server.PortInUseException.ifCausedBy(PortInUseException.java:103) at org.springframework.boot.web.server.PortInUseException.ifPortBindingException(PortInUseException.java:82) at org.springframework.boot.web.server.PortInUseException.throwIfPortBindingException(PortInUseException.java:69) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:228) at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) at java.base/java.lang.Iterable.forEach(Unknown Source) at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) at it.unibz.inf.ontop.endpoint.OntopEndpointApplication.lambda$restart$1(OntopEndpointApplication.java:48) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed at org.apache.catalina.core.StandardService.addConnector(StandardService.java:244) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213) ... 17 common frames omitted Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed at org.apache.catalina.connector.Connector.startInternal(Connector.java:1074) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.addConnector(StandardService.java:240) ... 19 common frames omitted Caused by: java.net.BindException: Address already in use at java.base/sun.nio.ch.Net.bind0(Native Method) at java.base/sun.nio.ch.Net.bind(Unknown Source) at java.base/sun.nio.ch.Net.bind(Unknown Source) at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source) at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:277) at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:241) at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1193) at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1279) at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:608) at org.apache.catalina.connector.Connector.startInternal(Connector.java:1071) ... 21 common frames omitted 13:21:20.672 |-ERROR in o.s.b.d.LoggingFailureAnalysisReporter -


APPLICATION FAILED TO START


Description:

Web server failed to start. Port 8080 was already in use.

Action:

Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.

gpeb2 commented 2 years ago

Not sure about the "close" failures but the following exception is almost certainly due to the way Ontop restarts when the OBDA file is updated.

13:21:20.672 |-DEBUG in o.s.b.d.LoggingFailureAnalysisReporter - Application failed to start due to an exception org.springframework.boot.web.server.PortInUseException: Port 8080 is already in use