Red Hat

WildFly Swarm Alpha2

We’ve been churning through the improvements and fixes for Alpha2!

Windows

All the Windows issues are now resolved. You can enjoy the benefits of WildFly Swarm on your operating system of choice.

Modify your Application from Alpha1

We’ve made a few changes to how the plugin works which means that you will need to update any applications that are already utilizing Alpha1:

  • Remove the execution phase from the wildfly-swarm-plugin

  • Change the goal of the wildfly-swarm-plugin from create to package

  • Remove the provided scope from all WildFly Swarm dependencies in your pom.xml

Weld and JAX-RS

There were some WildFly modules missing when you wanted to use Weld with JAX-RS, so we’ve created a new fraction to cater for this combination. Simply add the following dependency:

<dependency>
  <groupId>org.wildfly.swarm</groupId>
  <artifactId>wildfly-swarm-weld-jaxrs</artifactId>
  <version>${version.wildfly-swarm}</version>
</dependency>

JPA

This release brings initial support for JPA projects. There are improvements planned for Alpha3 to make it even easier, but right now your project needs to have jar packaging, not war, and you will need your own Main:

public class Main {

    public static void main(String[] args) throws Exception {
      Container container = new Container();
      container.start();

      // Create a JDBC driver deployment using maven groupId:artifactId
      // The version is resolved from your pom.xml's <dependency>
      DriverDeployment driverDeployment = new DriverDeployment(container, "com.h2database:h2", "h2");
      container.deploy(driverDeployment);

      // Create a DS deployment
      DatasourceDeployment dsDeployment = new DatasourceDeployment(container, new Datasource("ExampleDS")
              .connectionURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE")
              .driver("h2")
              .authentication("sa", "sa")
      );
      container.deploy(dsDeployment);

      // Create the WAR and bundle all the JPA Entities and persistence.xml
      WarDeployment deployment = new DefaultWarDeployment(container);
      deployment.getArchive().addClasses(Employee.class);
      deployment.getArchive().addClass(EmployeeServlet.class);
      deployment.getArchive().addAsWebInfResource(new ClassLoaderAsset("META-INF/persistence.xml", Main.class.getClassLoader()), "classes/META-INF/persistence.xml");
      deployment.getArchive().addAsWebInfResource(new ClassLoaderAsset("META-INF/load.sql", Main.class.getClassLoader()), "classes/META-INF/load.sql");

      container.deploy(deployment);
    }
}

More ways to run your WildFly Swarm Application!

As with Alpha1 you can run your generated self-contained executable with:

java -jar ./target/myproject-1.0-swarm.jar

With Alpha2 you can also run it from the command line, without building the project:

mvn wildfly-swarm:run

or run the Main class of your application, or org.wildfly.swarm.Swarm if you don’t have one, directly within your favorite IDE!

What do I download?

There is no special download or installation instructions. Simply start using org.wildfly.swarm artifacts in your pom.xml, throw in the plugin and continue doing your builds. Everything is available through Maven Central.

Stay in Touch

You can keep up with the project through the WildFly HipChat room, @wildflyswarm on Twitter, or through GitHub Issues.

Ken Finnigan

Ken is a Principal Software Engineer at Red Hat, working on various projects. He is the project co-lead of WildFly Swarm with Bob McWhirter, and the author of books on GateIn and CDI.

Location:  Boston, MA

Occupation:  WildFly Swarm Project Co-Lead

Latest News

back to top