TomEE with Azure Web Apps
I’m prefacing this that I am by no means a Java Developer or have a desire to become one :). This was a case related to configuring TomEE with Azure web apps. With IIS the httpPlatformHandler dynamically assigns a port to the process its communicating with (PHP, Nodejs, DotnetCore, Java, ect).
Because of this the specific process you are wanting to communicate has to be listening to the desired port otherwise the connection will fail or timeout. What we came across with the TomEE app was the timeout scenario. We deployed the correct application files, setup the web.config properly per the documentation and the request would spin until it timed out after 240 seconds.
Since the request wasn’t failing we knew the Java process had to be starting up and HttpPlatformHandler was thinking some service was listening. Long story short, TomEE has its own config file under /conf/server.xml where it allocates the port its listening to, by default 8080 I believe.
In your folder bin/Tomee/conf/server.xml find an entry that looks like the one below and update it to contain the value ${port.http}. Unlike some of the other versions of Java, the main entry in the web.config for Catalina_OPTS seems to be ignored as there’s a whole different config file for how the process is actually starting up.
<Connector port=”${port.http}” protocol=”HTTP/1.1″
connectionTimeout=”20000″
redirectPort=”8443″ xpoweredBy=”false” server=”Apache TomEE” />
Expert from my logs – we can see that both the Dport.http and the handler are listening on the same port. Below that is the actually output from the logs indicating the app is now responding.
17-Sep-2020 03:58:55.407 INFO [main] sun.reflect.NativeMethodAccessorImpl.invoke Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
17-Sep-2020 03:58:55.407 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dport.http=27626
17-Sep-2020 03:58:55.407 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dtomeeport=%HTTP_PLATFORM_PORT%
17-Sep-2020 03:58:55.407 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dignore.endorsed.dirs=
17-Sep-2020 03:58:55.407 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dcatalina.base=D:\home\site\wwwroot\target\apache-tomee
17-Sep-2020 03:58:55.407 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dcatalina.home=D:\home\site\wwwroot\target\apache-tomee
17-Sep-2020 03:58:55.407 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Djava.io.tmpdir=D:\home\site\wwwroot\target\apache-tomee\temp
…..
17-Sep-2020 03:59:09.657 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invokeStarting ProtocolHandler [“http-nio-27626”]
17-Sep-2020 03:59:09.657 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invoke Starting ProtocolHandler [“ajp-nio-8009”]
17-Sep-2020 03:59:09.657 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invoke Server startup in 10937 ms
17-Sep-2020 03:59:09.923 WARNING
com.vaadin.flow.server.DefaultDeploymentConfiguration.checkProductionMode
====================================================================
Vaadin is running in DEBUG MODE.
Add productionMode=true to web.xml to disable debug features.
====================================================================
17-Sep-2020 03:59:11.204 INFO [http-nio-27626-exec-4] com.vaadin.tutorial.flow.helloworld.maven.tomee.VaadinApp.null setting now the main ui content..
17-Sep-2020 03:59:12.689 INFO [http-nio-27626-exec-6] com.vaadin.tutorial.flow.helloworld.maven.tomee.VaadinApp.null setting now the main ui content..
17-Sep-2020 03:59:13.110 INFO [http-nio-27626-exec-7] com.vaadin.tutorial.flow.helloworld.maven.tomee.VaadinApp.null setting now the main ui content..
17-Sep-2020 03:59:13.282 INFO [http-nio-27626-exec-8] com.vaadin.tutorial.flow.helloworld.maven.tomee.VaadinApp.null setting now the main ui content..
17-Sep-2020 03:59:40.395 INFO [http-nio-27626-exec-1] com.vaadin.tutorial.flow.helloworld.maven.tomee.VaadinApp.null setting now the main ui content..
17-Sep-2020 04:02:44.690 INFO [http-nio-27626-exec-3] com.vaadin.tutorial.flow.helloworld.maven.tomee.VaadinApp.null setting now the main ui content..
17-Sep-2020 04:02:46.414 INFO [http-nio-27626-exec-5] com.vaadin.tutorial.flow.helloworld.maven.tomee.VaadinApp.null setting now the main ui content..
17-Sep-2020 04:07:44.965 INFO [http-nio-27626-exec-5] com.vaadin.tutorial.flow.helloworld.maven.tomee.VaadinApp.null setting now the main ui content..
17-Sep-2020 04:07:46.593 INFO [http-nio-27626-exec-6] com.vaadin.tutorial.flow.helloworld.maven.tomee.VaadinApp.null setting now the main ui content..
Hope this saves anyone else time 🙂
Ref blog: https://www.tomitribe.com/blog/tomee-configuration-techniques/#Substitutionsforjustabouteverything
Sample Tomee app : https://github.com/vaadin-learning-center/flow-helloworld-maven-tomee