Adds random naming to Tomcat Engine
- Shutting down multiple instances of AASHTTPServer resulted in lifecycle exceptions.
This is now fixed by giving random names to the tomcat engine
Change-Id: I5c2a5874690d8cf7c2fe353270fd9658e6d294bc
Signed-off-by: Frank Schnicke <frank.schnicke@iese.fraunhofer.de>
diff --git a/sdks/java/basys.sdk/src/main/java/org/eclipse/basyx/vab/protocol/http/server/AASHTTPServer.java b/sdks/java/basys.sdk/src/main/java/org/eclipse/basyx/vab/protocol/http/server/AASHTTPServer.java
index f7ead88..02bb5fa 100644
--- a/sdks/java/basys.sdk/src/main/java/org/eclipse/basyx/vab/protocol/http/server/AASHTTPServer.java
+++ b/sdks/java/basys.sdk/src/main/java/org/eclipse/basyx/vab/protocol/http/server/AASHTTPServer.java
@@ -3,6 +3,7 @@
import java.io.File;
import java.util.Iterator;
import java.util.Map.Entry;
+import java.util.UUID;
import javax.servlet.http.HttpServlet;
@@ -45,6 +46,10 @@
public AASHTTPServer(BaSyxContext context) {
// Instantiate and setup Tomcat server
tomcat = new Tomcat();
+
+ // Set random name to prevent lifecycle expections during shutdown of multiple
+ // instances
+ tomcat.getEngine().setName(UUID.randomUUID().toString());
if (context.isSecuredConnectionEnabled()) {
Connector httpsConnector = tomcat.getConnector();