WildFly 18 has been released and one of the most interesting news is the alignment of the project with Jakarta EE 8 API.

WildFly 17.0.1 was the first release of the applicaiton server certified as a Jakarta EE 8 compatible implementation. In terms of API do we have anything to change in our configuration ?

In general terms, Jakarta EE 8 and Java EE 8 APIs are identical and so is their implementation. In practical terms, even if the source from which the server is built changes, it is not expected to introduce any runtime incompatibility. Therefore, WildFly 18 is still a Java EE 8 compatible application server.

On the other hand, you will see that from WildFly 18 and newer versions, the dependencies and BOM files will be collected from a different location, so the groupIp and artifactId will be different.

This is the new BOM file for Jakarta EE projects:

 <dependencyManagement>
        <dependencies>      
            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>wildfly-jakartaee8-with-tools</artifactId>
                <version>${version.server.bom}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
</dependencyManagement>

Then, for projects that were consuming an API jar produced by a JBoss.org community project, a new github repo was created, with the initial code derived from the Jakarta projects, and new releases were produced.

Here is the list dependencies which now fall under the Jakarta Umbrella:

<artifactId>jakarta.activation</artifactId>
<groupId>com.sun.activation</groupId>

<artifactId>jakarta.enterprise.cdi-api</artifactId>
<groupId>jakarta.enterprise</groupId>

<artifactId>jakarta.inject-api</artifactId>
<groupId>jakarta.inject</groupId>

<artifactId>jakarta.json-api</artifactId>
<groupId>jakarta.json</groupId>

<artifactId>jakarta.mail</artifactId>
 <groupId>com.sun.mail</groupId>

<artifactId>jakarta.persistence-api</artifactId>
<groupId>jakarta.persistence</groupId>

<artifactId>jakarta.security.enterprise-api</artifactId>
<groupId>jakarta.security.enterprise</groupId>

<artifactId>jakarta.validation-api</artifactId>
<groupId>jakarta.validation</groupId>

A sample Jakarta EE 8 project

To show you an example, we have moved one Hello World Rest/JPA Example coded for Java EE 8 into the new Jakarta EE 8 style.

This project is made up of a basic REST Endpoint that exposes a set of methods to list and create resources:

@Path("/service")
public class RESTService {

    @Inject
    ServiceBean ejb;

    @GET
    @Path("/list/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public SimpleProperty getPropertyByPathParam(@PathParam("id") String id)
    {
        return ejb.findById(id);
    }

    @GET
    @Path("/list")
    @Produces(MediaType.APPLICATION_JSON)
    public List<SimpleProperty> getProperty()
    {
        return ejb.findAll();
    }
    @POST
    @Produces(MediaType.TEXT_PLAIN)
    public Response createProperty(@FormParam("key")String key,
                                   @FormParam("value")String value)
    {
        ejb.put(key,value);

        return Response.ok("Inserted! Go back and check the list.").build();

    }

}

This is the ServiceBean which does some queries on the default Database:

@Stateless
public class  ServiceBean   {

    @PersistenceContext
    private EntityManager em;

    public void put(String key, String value){
        SimpleProperty p = new SimpleProperty();
        p.setKey(key);
        p.setValue(value);
        em.persist(p);
    }

    public void delete(SimpleProperty p){

        Query query = em.createQuery("delete FROM SimpleProperty p where p.key='"+p.getKey()+"'");

        query.executeUpdate();

    }

    public List<SimpleProperty> findAll(){

        Query query = em.createQuery("FROM SimpleProperty");

        List <SimpleProperty> list = query.getResultList();
        return list;

    }

    public SimpleProperty findById(String id){

        SimpleProperty p = em.find(SimpleProperty.class, id);
        return p;

    }

}

Most interesting for us, this is the list of Jakarta EE 8 dependencies for our project:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>wildfly-jakartaee8-with-tools</artifactId>
                <version>${version.server.bom}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>jakarta.enterprise</groupId>
            <artifactId>jakarta.enterprise.cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.persistence</groupId>
            <artifactId>jakarta.persistence-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

You can find the full source code for the project here: https://github.com/fmarchioni/mastertheboss/tree/master/jakartaee/wildfly-based

As the project includes also WildFly Maven plugin, you can simply run it as follows:

$ mvn install wildfly:deploy

Here is your first, minimal Jakarta EE 8 Project running on WildFly:

Jakarta ee 8 wildfly tutorial Jakarta ee 8 wildfly tutorial

That's with the Jakarta EE news!

0
0
0
s2sdefault