JBoss AS has a new name: as you probably know future versions of the application server will be named Wildfly. Let's have our first taste of WildFly 8

Start by downloading the Wildfly application server from http://www.wildfly.org/ . Luckily the new application server release is not a radical departure from the 7.x releases ! In terms of development, the most important hightlight of this new server version is the Java EE 7 specification which has been recentely released (http://java.net/projects/javaee-spec/downloads).
Along with this, you need to be aware that the new server contains a new module filesystem layout (which has been already introduced in JBoss EAP 6.1)
Basically the new modules file system layout is organized as follows:

jboss 8 wildfly jboss 8 wildfly jboss 8 wildfly jboss 8 wildfly
 
The system root level is used to separate modules associated with the distribution base from add-ons and other modules that you can add to customize your distribution. Because of the new module file system, the older JBoss Tools plugin will not be able to configure WildFly as Server. For this purpose we suggest the following environemt:

  • JBoss Tools 4.1.1 
  • Eclipse Kepler 4.3.1

Once installed JBoss Tools from Eclipse Market Place, define a new WildFly Server as shown by the following picture:
jboss 8 wildfly jboss 8 wildfly jboss 8 wildfly jboss 8 wildfly

On the other hand, in this example we will use Maven and the Maven WildFly plugin to compile and deploy our application which uses an EJB 3.2 feature that enables excluding passivation on a component basis, either by annotations or by the ejb-jar.xml configuration file. So let's create a simple Maven project which uses a javaee6-webapp archetype and then add the following EJB to your project:

package com.sample;
@javax.ejb.Stateful(passivationCapable=false)
public class NoPassivation {
    int total =0;
    public void sum(int i) {
        total+=i;
    }
    public int getTotal() {
        return total;
    }

}

In order to test our EJB just add a simple Servlet which invokes the NoPassivation EJB a couple of times:
   @EJB
    NoPassivation ejb;
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ejb.sum(5);
        ejb.sum(5);
        
        PrintWriter out = response.getWriter();
        out.println("Hello from EJB 3.2 on WildFly");
        out.println("Total "+ejb.getTotal());
        out.close();
    }

Finally a pom.xml which is based on jboss-javaee-6.0 BOM but includes the jboss-ejb-api_3.2_spec Alpha version:     
    
<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.sample</groupId>
    <artifactId>DemoWildfly</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>DemoWildfly</name>

<properties>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- maven-compiler-plugin -->
        <maven.compiler.target>1.7</maven.compiler.target>
        <maven.compiler.source>1.7</maven.compiler.source>
    </properties>

    <repositories>
        <repository>
            <id>JBoss Repository</id>
            <url>https://repository.jboss.org/nexus/content/groups/public/</url>
        </repository>
    </repositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.spec</groupId>
                <artifactId>jboss-javaee-7.0</artifactId>
                <version>1.0.0.Final-SNAPSHOT</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
             
        </dependencies>
    </dependencyManagement>
    <dependencies>

        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
            <scope>provided</scope>
        </dependency>

    
        <!-- Import the Common Annotations API (JSR-250) -->
        <dependency>
            <groupId>org.jboss.spec.javax.annotation</groupId>
            <artifactId>jboss-annotations-api_1.2_spec</artifactId>
            <scope>provided</scope>
        </dependency>
      
    </dependencies>

    <build>
         
        <finalName>${project.artifactId}</finalName>

        <plugins>
             
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.0.0.Beta1</version>
            </plugin>
        </plugins>
    </build>


</project>    

Package and compile with:

mvn install wildfly:deploy		

That's all! Enjoy Wildfly 8 !

0
0
0
s2smodern

Related articles available on mastertheboss.com

Configuring Eclipse to use WildFly

How do I integrate WildFly with Eclipse? This tutorial shows how

Maven configuration for Java EE 7 projects on WildFly

In this tutorial we will learn how to configure Maven Project Obj

Running WildFly with JDK 8

The JDK 1.8 early access is available for download at Oracle's si

Patching WildFly application server

The final version of WildFly 8.1.0 has been released and it conta

Configuring WildFly Batch Job Repository

WildFly ships with a subsystem named batch which is the administr

Monitoring WildFly using VisualVM

This short tutorial shows how you can connect to WildFly 8 using