How can i get tomcat random port used by studio ?

1
0
-1

When tomcat is started by the studio, the port used by tomcat is no more the 8080 fixed value, but a random available port.

i need to know this port to forge a task form link, but how can we guess it from env variable or other mean?

thanks

1 answer

1
0
-1

Hi,

Those technical details should not leak in your applicative code. Try to use a process parameter to store your host path. It might be localhost:8080 at dev time and then become something like www.my-company.com in production. So using a parameter in your app seems more flexible.

If you want to reset the port to 8080 in the Studio, you can edit the port in the Server preference. (be sure that is port is available otherwise it will be replaced with a free port).

You could use some tomcat specific code to retrieve it but I do not advise it.

Comments

Submitted by laurent.leseigneur on Mon, 01/25/2021 - 16:18

<p>Hi Romain,</p>

<p>I agree with your advice.</p>

<p>when deploying using BCD, it's easy to get this information from the BCD deploy json status file, and then update my&nbsp;process parameter using BCD extract/merge conf feature. This works as expected for my Qualification environment</p>

<p>The issue is only on studio with dev, since my e2e test can't verify a mail has been send with the expected content, since my "serveur Url" process parameter is localhost:8080, but should be updated with real port, and as you mentioned, if 8080 is already in use, a random port is used<br />
&nbsp;</p>

<p>&nbsp;</p>

Submitted by romain.bioteau on Wed, 01/27/2021 - 09:11

What about starting a dedicated runtime for your e2e tests ? Using the mutable Studio runtime might lead to reproducibility issues. In addition the logic to setup and run your tests should be as close as possible between the environments.

Notifications