Skip to content

Commit

Permalink
Merge pull request #179 from jansohn/random-port-fix
Browse files Browse the repository at this point in the history
fix: fixed random port selection support
  • Loading branch information
rhusar authored Oct 2, 2024
2 parents d791980 + 323fa8e commit 7b0d411
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentExcept
final StandardContext standardContext = (StandardContext) host.findChild(contextName.getName());
standardContextProducer.set(standardContext);

// Use tomcat values instead of configuration ones to support automatic/random port selection
final HTTPContext httpContext =
new HTTPContext(configuration.getBindAddress(), configuration.getBindHttpPort());
new HTTPContext(tomcat.getHost().getName(), tomcat.getConnector().getLocalPort());

for (final String mapping : standardContext.findServletMappings()) {
httpContext.add(new Servlet(standardContext.findServletMapping(mapping), contextName.getPath()));
Expand Down Expand Up @@ -222,7 +223,7 @@ protected void startTomcatEmbedded() throws LifecycleException, org.apache.catal
host.setConfigClass(EmbeddedContextConfig.class.getCanonicalName());

embeddedHostConfig = new EmbeddedHostConfig();
((StandardHost) host).setUnpackWARs(configuration.isUnpackArchive());
embeddedHostConfig.setUnpackWARs(configuration.isUnpackArchive());

host.addLifecycleListener(embeddedHostConfig);

Expand Down

0 comments on commit 7b0d411

Please sign in to comment.