How can i get tomcat random port used by studio ?

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

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.

Hi Romain,

I agree with your advice.

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

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
 

 

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.