The project generator allows you to select basic project properties (Maven Group ID and Artifact ID) and a list of dependencies for the project before creating a Maven project that can be downloaded and used from within your favorite IDE.
The list of dependencies is what makes this generator most useful to me. If you know the name of the dependency to add, or even a few letters from it, you can enter that in the dependencies field and the generator will automatically show the matching dependencies. For example, entering “rs” shows all the JAX-RS related dependencies.
Once you’ve configured the name and dependencies for the project, selecting the “Generate Project” button downloads a zipped Maven project that’s ready for use and which can be run via maven by executing
The WildFly Swarm Generator is an excellent tool that reduces the barrier to developing with WildFly Swarm. If you’re a Swarm user, I’d recommend trying this out.
WildFly Swarm applications can be deployed to Heroku, simply by adding a few files to the deployment. In this post, I’ll show the changes that are needed to be made to a WildFly Swarm application and how to then deploy the application to Heroku. I’ll show how to deploy my Fruits example WildFly Swarm application to Heroku. The source for this application can be cloned from GitHub at https://github.com/doobrie/swarm-rs
Creating a Heroku Application
Assuming that you’ve got the Heroku Toolbelt installed, creating a Heroku application is a matter of opening a command prompt/terminal in the root of a WildFly Swarm project (for this example, a Maven project), and executing the heroku create command.
This creates a Heroku application, adding a git remote, heroku, ready for deploying your application.
Defining the Java Runtime
Heroku can automatically determine that your application is Java based, but needs to be told which version of Java to run. To define this, create a file called system.properties in the root of the project containing a single line indicating the version of Java required.
How To Execute The Application
Heroku uses a Procfile to determine how your application should be exeuted. This file should also be located in the root of your project. To run a web application, we need to tell Heroku to run a Web Dyno. We also need to tell it what command to run and what port to run on.
In Heroku, the port that applications must listen on is defined by the $PORT environment variable. A default WildFly Swarm application runs on port 8080, but this can be changed by adding the swarm.http.port environment variable. To execute a WildFly Swarm application, the Procfile should look something like
Since we’re running a WildFly Swarm “fat” Jar, there are no additional class path entries required - all that is needed is the name of the Jar file containing the application, swarm-rs-1.0-SNAPSHOT-swarm.jar in this example.
Deploying The Application
That’s all that is required to get going with Heroku and WildFly Swarm. You can see that we’ve made no changes to the application itself other than adding a system.properties file to determine which Java runtime to use, and a Procfile to define how to start the application.
To deploy the application on Heroku, ensure these files are added and committed to the local Git repository and then push the changes to Heroku.
Last week, a new version, 1.0.0.Alpha6 of WildFly Swarm was released. One of the main features of this release, from a development point of view, is the simplified handling of dependencies within a project’s pom.xml file.
All of the artifactId values for WildFly Swarm dependencies have been simplified from wildfly-swarm-artifactName to simply artifactName
Recently, I showed how to create a simple JAX-RS application using WildFly Swarm. With the previous version of WildFly Swarm, 1.0.0.Alpha5, the JAX-RS Swarm dependency was defined as:
A new Darcula theme based upon the Darcula Look and Feel for IntelliJ has been released as a plugin for NetBeans.
This new plugin can be installed via the NetBeans Tools | Plugins option so there is no need to manually download the plugin to install it.
After installing the plugin, NetBeans needs to be restarted. Probably the first thing you notice after installation is that the editor window still retains the existing NetBeans colour scheme. The can be changed to a dark look and feel, for example, by using the Norway Today profile. After specifying this profile, you can customize the colours used within the editor window exactly how you like them, whilst retaining a full dark look and feel.
I really like this plugin. There are still some issues with it, for example the --fontsize NetBeans parameter doesn’t work with it, however that doesn’t detract from the use of the plugin which I now enable on all my NetBeans installations.
WildFly Swarm provides an easy solution for deploying Java EE applications as a standalone Jar file. This makes it very easy to deploy applications, particularly REST or web services. Swarm is very similar to Spring Boot in that respect, in that it enables web (.War) applications to be developed quickly and then deployed as standalone applications without the need to deploy an application server.
The WildFly Swarm documentation describes itself as:
Swarm offers an innovative approach to packaging and running Java EE applications by packaging them with just enough of the platform to “java -jar” your application.
Deploying an Java EE application as a Swarm application is fairly straightforward:
Add dependencies on the aspects of WildFly Swarm that you are to use to your project’s pom.xml file, for example, JAX-RS or JPA.
Add the WildFly Swarm plugin to your project’s pom.xml file to enable an executable Jar file to be created.
Sit back, relax and run your application as a standalone executable Jar !
To give a demonstration of how easy this is, I’ve created a very simple JAX-RS web service that returns a list of fruits - very similar to the Angular.js factory I created a few years ago.
The code for this sample application is available on GitHub
To create a JAX-RS web service and run as a WlidFly Swarm application, we just need to add the wildfly-swarm-jaxrs dependency. All of the dependencies that can be used with WildFly Swarm are documented in the User’s Guide