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
articleSome official information about version 10
- The implementation is certified to comply with the Full and Web profiles of Java EE 7. WildFly code is distributed under the LGPL;
- Unlike the commercial product JBoss Enterprise Application Platform, which is positioned as a fully tested and certified Java EE platform, WildFly is primarily focused on technology promotion. WildFly acts as an upstream project for the commercial product JBoss Enterprise. The development and rapid deployment of prototypes is considered the main area of ​​use for WildFly.
Main features of the release
- Discontinued support for Java 7, which allowed for deeper integration with Java 8 Runtime. Added support for current Java 9 snapshots;
- Delivery of ActiveMQ Artemis as a Java Message Service Broker, protocol-compatible, and replacing HornetQ;
- Support for starting a host controller using the CLI. The new embed-host-controller command allows you to edit the contents of the domain.xml and host.xml files without starting additional processes or opening network sockets;
- JavaScript support in the Undertow.io http server, which allows you to create server-side scripts in JavaScript that can access CDI Beans and JPA Entity Beans. This ability is convenient to use to create external binding or REST handlers. Edited JavaScript code becomes available immediately and does not require restarting the application;
- Support for single fail-safe deployment of an application (“singleton deployment”), in which, if a group of clustered servers are used, deployment will be performed only on one node, but if this node fails, the application will be automatically transferred to another node;
- Support for a single fault-tolerant message distribution broker (Singleton MDB), which starts delivery on only one node, but in case of failure, uses another node to process messages;
- Automatic selection of the size of the SLSB and MDB pool, depending on the available system resources;
- Tools for migrating legacy subsystems, such as jbossweb (AS 7.1), jacorb (WildFly 8) and hornetq (WildFly 9), which automate the conversion of old configurations to equivalents running in WildFly 10;
- Hibernate 5 implementations significantly improved the quality of bytecode, made performance optimizations and added improvements to the API.
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:
- Sometimes restarting WildFLy is delayed and localhost: 9990 - the console pulls up for a long time.
- 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.