WARN HttpChannel - /rest/sc javax.servlet.ServletException: java.lang.IllegalArgumentException: There already is a smart connector registered with ID
Sophietje opened this issue · 8 comments
In GitLab by @facoelho on Jul 26, 2023, 14:59
Hi while using the KER in the set up with Cybergrid running v1.2.1
We are getting this on our KER log.
Is this expected? In the past there was no problem creating knowledge bases whose ID was already taken. But now this is throwing an HTTP 500 and crashing over an already existing KB.
Is this expected ?
2023-07-26 15:49:35:774 +0100 [qtp565760380-987] WARN HttpChannel - /rest/sc
javax.servlet.ServletException: java.lang.IllegalArgumentException: There already is a smart connector registered with ID https://ke-pt.interconnectproject.eu/rest/adapter/hems-spine-adapter
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:410)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalArgumentException: There already is a smart connector registered with ID https://ke-pt.interconnectproject.eu/rest/adapter/hems-spine-adapter
at eu.knowledge.engine.smartconnector.runtime.LocalSmartConnectorRegistryImpl.register(LocalSmartConnectorRegistryImpl.java:34)
at eu.knowledge.engine.smartconnector.impl.SmartConnectorImpl.<init>(SmartConnectorImpl.java:90)
at eu.knowledge.engine.smartconnector.spi.SmartConnectorV2Provider.create(SmartConnectorV2Provider.java:12)
at eu.knowledge.engine.rest.api.impl.RestKnowledgeBase.<init>(RestKnowledgeBase.java:240)
at eu.knowledge.engine.rest.api.impl.RestKnowledgeBaseManager.createKB(RestKnowledgeBaseManager.java:86)
at eu.knowledge.engine.rest.api.impl.SmartConnectorLifeCycleApiServiceImpl.scPost(SmartConnectorLifeCycleApiServiceImpl.java:140)
at jdk.internal.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:159)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:475)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:397)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
... 18 more
In GitLab by @han.kruiger.tno.nl on Jul 27, 2023, 09:09
Hi @facoelho, thanks for reporting this.
This is not the expected response. Under normal circumstances, the KE REST API should return HTTP 400
(bad request) and gives the following JSON:
{
"messageType": "error",
"message": "That knowledge base ID is already in use."
}
Do you have more information on how this occurred? Can you reproduce this somehow?
In GitLab by @facoelho on Jul 27, 2023, 11:03
yes.
We booted v1.2.1 attached with the KD from Cybegrid. Link was acknowledged in our local KER instance. Then we created a smart connector (as the error that I reported) with an ID previously registered.
In GitLab by @han.kruiger.tno.nl on Jul 27, 2023, 11:36
Ah, and did you previously register it in the same KER or a different runtime?
In GitLab by @barry.nouwt.tno.nl on Aug 8, 2023, 11:30
Hi @facoelho,
like @han.kruiger.tno.nl mentions this is incorrect behaviour. I checked the code and noticed that this error can only happen if this if
-condition returns false
. And this only returns false
if the Smart Connector is not 'known' to the REST API, but there is still an active SmartConnector somehow. Apparently, the previous SmartConnector for that ID was not entirely/correctly deleted. When this happens the REST API's DELETE /rest/sc
operation returns a 404
with an error like
{
"type": "error",
"message": "Deletion of knowledge base failed, because it was already being deleted."
}
I expect this error to have occurred when trying to delete the Smart Connector the first time.
@han.kruiger.tno.nl The implementation of this DELETE /rest/sc
operation can maybe be improved by only removing the KB from the this.restKnowledgeBases
when the deletion was successful. It might also be worth to LOG the IllegalArgumentException
that might occur during this operation, to have some more information the next time it occurs. What do you think?
Best regards,
Barry
In GitLab by @han.kruiger.tno.nl on Aug 8, 2023, 11:50
Yes, those sound like helpful improvements to prevent 'stuck but invisible' smart connectors.
Specifically, in RestKnowledgeBaseManager::deleteKB
we should make the changes.
I can implement it this week!
In GitLab by @han.kruiger.tno.nl on Aug 8, 2023, 12:36
See: https://gitlab.inesctec.pt/interconnect/knowledge-engine/-/merge_requests/381
In GitLab by @barry.nouwt.tno.nl on Aug 11, 2023, 11:17
I assume we can close this issue now, since we implemented an improvement to prevent this behaviour in the next version of the Knowledge Engine.