📜 ⬆️ ⬇️

Automatic application deployment with Maven and Wildfly

Hi Habr! I want to start with a small article manual, how to make WildFly friends with Maven.

Wildfly - This is the rebranding and development of JBoss AS7 / EAP6 in the area of ​​both administration and API for developers. Wildfly is built using Java SE 7. It integrates perfectly with the core Java IDE. A brief quote from the article

Some official information about version 10



Main features of the release



I want to talk about the automatic deployment in Wildfly using Maven, as well as talk briefly about launching the UI in the same container.

You need to use Maven version not lower than 3.3.9 (I use maven 3.5.0), otherwise the Wildfly Plugin will not work.
')
The Wildfly version I currently use is 10.1.0-Final, the plugin version is 1.2.0.Alpha4

In the Pom.XML of the collected application, you must register the data to connect to the Wildfly server

Example:

<plugin> <groupId>org.wildfly.plugins</groupId> <artifactId>wildfly-maven-plugin</artifactId> <configuration> <hostname>${wildfly-hostname}</hostname> <port>${wildfly-port}</port> <username>${wildfly-username}</username> <password>${wildfly-password}</password> <name>${wildfly-name}</name> </configuration> </plugin> 

It is also good practice to take out the settings in settings.xml or in the pom.xml level above. This will also allow the use of profiles when deploying - local deploy, deploy to the prod.

Profile area in settings.xml.

  <profile> <id>localhost</id> <properties> <wildfly-hostname>localhost</wildfly-hostname> <wildfly-port>9990</wildfly-port> <wildfly-username>admin</wildfly-username> <wildfly-password>admin</wildfly-password> <wildfly-name>core.war</wildfly-name> </properties> </profile> <profile> <id>dev</id> <properties> <wildfly-hostname>Prod_Server</wildfly-hostname> <wildfly-port>9990</wildfly-port> <wildfly-username>admin</wildfly-username> <wildfly-password>admin</wildfly-password> <wildfly-name>core-prod_vers.war</wildfly-name> </properties> </profile> 

After all the settings, using maven, from the command line, from the IDE, from, for example, Jenkins (maven plugin), you can deploy the war using mvn wildfly: deploy , you can also use mvn wildfly: undeploy and mvn wildfly: redeploy for removal and redistribution, respectively. Selecting a profile -Plocalhost will allow you to run with settings from a profile with id localhost, -Pdev, respectively, runs for sale (all data in the settings are default or fictitious).

With the correct setting in the WildFly console, in the deployments section, you will have the necessary war.

In addition, WildFly allows you to run UI.

Configuring WildFly to run UI:

The project is placed in the root WildFLy in the directory that you choose for your UI.
In this example, I used the UI directory.

In the /PathToWildfly/standalone/configuration/standalone.xml file, you need to add lines (lines including adjacent lines, to facilitate the search):

 <location name="/" handler="welcome-content"/> <location name="/UI/" handler="UI"/> <filter-ref name="server-header"/> <filter-ref name="x-powered-by-header"/> 

 <handlers> <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/> <file name="UI" path="${jboss.home.dir}/UI/widget/build"/> 

After this, WildFLy automatically picks up the changes and your application will be available at localhost: 8080 / UI.

At the moment, the launch was carried out using the command ./standalone.sh -b = 0.0.0.0 -bmanagement = 0.0.0.0 , the application runs on Linux Oracle in screen.

During use, 2 problems were identified:

  1. Sometimes restarting WildFLy is delayed and localhost: 9990 - the console pulls up for a long time.
  2. When launched from Jenkins on Maven 3.3.9 with a redeploy tag, memory leaks occur and the application deletes both versions of war and swears at the duplicate. (Not always reproduced)

This bundle of about 2 months, in addition to the above, I have not encountered any problems. Jenkins drives everyone in this case, he starts mvn wildfly: undeploy mvn wildfly: deploy (I use this strategy, because redeploy does not work) and delivers the assembled UI to the UI directory, the update happens at night, the flight is normal.

I also tested the launch on the win host, did not notice the differences in the work, it is still stable.

Source: https://habr.com/ru/post/332086/


All Articles