diff --git a/inception-app-webapp/src/main/java/de/tudarmstadt/ukp/inception/INCEpTION.java b/inception-app-webapp/src/main/java/de/tudarmstadt/ukp/inception/INCEpTION.java index 71b874ec8c1..2e89fd53c0d 100644 --- a/inception-app-webapp/src/main/java/de/tudarmstadt/ukp/inception/INCEpTION.java +++ b/inception-app-webapp/src/main/java/de/tudarmstadt/ukp/inception/INCEpTION.java @@ -17,6 +17,8 @@ */ package de.tudarmstadt.ukp.inception; +import static com.giffing.wicket.spring.boot.starter.web.config.WicketWebInitializerAutoConfig.WebSocketWicketWebInitializerAutoConfiguration.REGISTER_SERVER_ENDPOINT_ENABLED; + import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -25,6 +27,7 @@ import javax.validation.Validator; import org.apache.catalina.connector.Connector; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfigurationExcludeFilter; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -48,8 +51,6 @@ import org.springframework.security.crypto.password.StandardPasswordEncoder; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; -import com.giffing.wicket.spring.boot.starter.web.config.WicketWebInitializerAutoConfig.WebSocketWicketWebInitializerAutoConfiguration; - import de.tudarmstadt.ukp.clarin.webanno.automation.service.AutomationService; import de.tudarmstadt.ukp.clarin.webanno.automation.service.export.AutomationMiraTemplateExporter; import de.tudarmstadt.ukp.clarin.webanno.automation.service.export.AutomationTrainingDocumentExporter; @@ -145,10 +146,23 @@ protected SpringApplicationBuilder createSpringApplicationBuilder() { SpringApplicationBuilder builder = super.createSpringApplicationBuilder(); builder.properties("running.from.commandline=false"); - // add this property in the case of .war deployment - builder.properties( - WebSocketWicketWebInitializerAutoConfiguration.REGISTER_SERVER_ENDPOINT_ENABLED - + "=false" ); + + // Unless we are running in Eclipse and "serve modules without publishing" is enabled, we + // need to instruct Wicket to not register the WebSocket endpoint because Tomcat is already + // registering it. + String wtpDeploy = System.getProperty("wtp.deploy", ""); + // If this system property is set, we are probably running in Eclipse WTP + boolean runningInEclipseWtp = StringUtils.isNotEmpty(wtpDeploy); + // When serving *with* publishing, then WTP publishes to its plugin folder under the + // Eclispe workspace .metadata folder. So if we don't see the name of the plugin folder, + // then we assume that modules are served without publishing + boolean servingModulesWithoutPublishing = !wtpDeploy.contains("org.eclipse.wst.server.core"); + if (!(runningInEclipseWtp && servingModulesWithoutPublishing)) { + // Avoid error caused by Wicket tryig to register a WS endpoint while Tomcat has + // already registered one. + builder.properties(REGISTER_SERVER_ENDPOINT_ENABLED + "=false"); + } + init(builder); return builder; }