Skip to content

Commit

Permalink
#1066 Recommender status info
Browse files Browse the repository at this point in the history
- Register WS endpoing when deploying in Eclipse with "serve modules without publishing" enabled - otherwise WS doesn't work
  • Loading branch information
reckart committed Jul 26, 2019
1 parent 71f3fc8 commit daf75c7
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit daf75c7

Please sign in to comment.