Saturday, October 24, 2020

Kicking the Tires of Jakarta EE 9 with Payara

We've been hearing all about it.  Jakarta EE 9 will be released in November 2020.  The Jakarta EE working group and community have been working hard to bring this release to the masses, and it is about ready.  Here's how to take a look at it today, using one of the most popular application server containers.

1.  Download the latest Payara Server Community 5.2020.5 release, which includes "Tech Preview" support for Jakarta EE 9.  https://www.payara.fish/downloads/#community

2.  Create a simple service using Jakarta EE APIs, adding the jakarta.platform:jakartaee.jakarta.jakartaee-api:9.0.0-RC3 dependency. 

3.  Build and deploy the service to Payara Server Community 5.2020.5.

That's it.  The Payara Server Community edition includes an Eclipse Transformer Configuration Option, which will automatically detect jakarta.* package references during the deployment of the application, and transform the class and resource files from the jakarta.* namespace to javax.*.  Take a look at this Payara blog post for more info:  https://blog.payara.fish/eclipse-transformer-configuration

Example POM including Payara Server Community Support:


<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.employeeevent</groupId>
    <artifactId>AcmeChat</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>AcmeChat-1.0-SNAPSHOT</name>
    
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <jakartaee>9.0.0-RC3</jakartaee>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>jakarta.platform</groupId>
            <artifactId>jakarta.jakartaee-api</artifactId>
            <version>${jakartaee}</version>
        </dependency>
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>jakarta.platform</groupId>
                                    <artifactId>jakarta.jakartaee-api</artifactId>
                                    <version>${jakartaee}</version>
                                    <type>pom</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>