2
votes

I am a bit new to maven and wildfly. I can successfully deploy my app on 127.0.0.1:8080/myapp using eclipse and the wildfly-maven-plugin but I would like to deploy it on the IP address of my machine (192.168.0.101) so I can access it from another computer. My POM looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>org.vch.apps</groupId>
    <artifactId>myapp-chat</artifactId>
    <packaging>war</packaging>
    <version>1.0</version>
    <name>vch-myapp</name>
    <url>http://maven.apache.org</url>

    <dependencies>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>1.0.13</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.3</version>
        </dependency>
    </dependencies>

    <profiles>
    <profile>
     <id>profileIP</id>
     <build>
        <finalName>myapp</finalName>
        <plugins>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.0.1.Final</version>
                <configuration>
                    <jbossHome>/usr/local/wildfly-8.0.0.Final</jbossHome>
                    <!--hostname>192.168.0.101</hostname>
                    <port>8080</port-->
                </configuration>
            </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

If I execute wilfly:run from eclipse and specify the profileIP in the Profiles box in Eclipse, the wildfly I downloaded and unpacked to '/usr/local/wildfly-8.0.0.Final' will start on 127.0.0.1:8080 and my application will be deployed to this address. If I uncomment the hostname and port elements my app is still deployed on localhost.

Is there a way to deploy my app on the ip specified in the hostname element using the maven plugin or do I need to make changes to the configuration files in the wildfly folder? I only downloaded wildfly and unpacked it and did not add any wildlfy servers to eclipse.

3

3 Answers

2
votes

It seems like you might want to use the deploy goal instead. The run goal does, just as you said, optionally downloads WildFly, starts it and deploys your application. It actually should be failing too if you used the hostname and port you specified. If it's not that sounds like a bug.

On the WildFly side if you want to start the server so it runs on a different IP or is accessible to all IP's you need to use the -b option when start a standlone server. The port can be overridden by default via the system property jboss.http.port.

The following will start WildFly listening on port 80 on all available IP's.

$JBOSS_HOME/bin/standalone.sh -b 0.0.0.0 -Djboss.http.port=80

The settings above are only temporary and are HTTP only settings. Management by default listens on port 9990 on localhost. You can get more information about interfaces and ports in the documentation.

0
votes

I managed to do what I want by adding a user (using add-user.sh) for the wildfly user console available at: 127.0.0.1:9990/console/

In the console, I went to Porfile -> General COnfiguration -> Interfaces and changed the Inet Address of the public interface to: ${jboss.bind.address:192.168.0.101} which is the network IP of my local machine. I did not make any changes to my POM and I can now execute widlfy:run and specify the profileIP to start my wildfly server and deploy my ap on: 192.168.0.100:8080/myapp.

0
votes

You have to properly configure your settings.xml file with profile and your pom.xml to read the profile on the command line. For further details, see this post