Maven Wildfly Plugin Deployment from and to Docker Container

25 views
Skip to first unread message

Holger

unread,
Aug 5, 2025, 4:58:13 AM8/5/25
to WildFly
Hi,
in order to make life easier for colleagues I am trying to put Wildfly and Maven into their own containers. This is because there are a bunch of legacy Jars etc which are a pain to have for new Devs.
Wildfly runs fine and if i use my local machine to 'mvn package wildfly:deploy' i have to provide the mgmt credentials for the deployment. (short timer too, but that's a different ask).
When i now mount my src into the maven container and run it there i end up with 'connection refused':

[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:4.0.0.Final:deploy (default-cli) on project Phoenix-ear: Failed to execute goal deploy.: java.net.ConnectException: WFLYPRT0053: Could not connect to remote+http://localhost:9990. The connection failed: Connection refused

My interpretation of this is that the maven container does not recognize the WF container as localhost. But I am confused as to why it works from local then.
Port 9990 is forwarded in the WF container.

Any pointers would be greatly appreciated and I am fully aware that this is likely a misunderstanding on my part.

Torsten Liermann

unread,
Aug 5, 2025, 5:12:05 AM8/5/25
to WildFly

Hi Holger,

If I understand you correctly, WildFly is running inside a container. In that case, make sure the container isn’t bound to localhost, or simply start it with -b 0.0.0.0. If you ultimately plan to build an optimized image, take a look at tools such as Source-to-Image (S2I) or the WildFly Maven plugin’s image goal:
https://docs.wildfly.org/wildfly-maven-plugin/releases/5.1/image-example.html

jme...@redhat.com

unread,
Aug 5, 2025, 5:12:23 AM8/5/25
to WildFly
Hi,

Let me make sure I understand your use case correctly.

* You have a "maven" container where your source is mounted
* You have a "wildfly" container where WildFly is running
* When you do a "mvn package wildfly:deploy" from your "maven" container, you get a connection refused.

Is that correct?

That seems normal, in your "maven" container, localhost will point to this container and will not reach out to the "wildfly" container.


To make your use case work, there are 2 options afaict:
* use Docker compose[1] (so that the 2 containers are on the same network and the "maven" container can reach out to the "wildfly" container.
* create a network bridge[2] so that the containers are also on the same network

In both case, you will have to use  the `wildfly.hostname` system property to connect to the "wildfly" container (instead of the default "localhost"):
 
 mvn package wildfly:deploy -Dwildfly.hostname=<name of the wildfly container>

hope that helps,
Jeff

Holger

unread,
Aug 5, 2025, 5:24:44 AM8/5/25
to WildFly
First off: Thank you both for replying this quickly!

@Torsten: The WF container is running with -b 0.0.0.0 and -bmanagement 0.0.0.0 (at least for now). i will have a look at S2I down the line.

@JME: You are understanding correctly.
I will/am digging into the compose approach, though later the WF container might be running on an entirely different machine.
Thinking about it in that case people should just change things locally and we should then switch out the saved image.
For the hostname i assume it's the container ID or the Name? 
Reply all
Reply to author
Forward
0 new messages