Enterprise Java

Getting Started With EAP 7 Alpha and Java EE 7

Red Hat JBoss Enterprise Application Platform 7 (JBoss EAP 7) is a middleware platform built on open standards and compliant with the Java Enterprise Edition 7 specification. Built on top of innovative and proven open source technologies like WildFly, it will make Java EE 7 development a lot easier. Here is a quick guide on how to get started with the latest ALPHA release.

Prerequisites and Preface

JBoss EAP 7 provides two operating modes for JBoss EAP 7 instances: standalone server or managed domain. The standalone server operating mode represents running JBoss EAP as a single server instance. The managed domain operating mode allows for the management of multiple JBoss EAP instances from a single control point. The available version as of today is EAP 7 ALPHA. Just like with any Alpha release, please anticipate issues. If you find issues, feel free to file them in the corresponding JIRA. You need to have a supported JDK installed. EAP 7 requires Java SE 8.

You can test-drive EAP 7 under the Red Hat JBoss Developer Program. All you need to do is to register with jboss.org right after you click download on the EAP product page.

Download And Install JBoss EAP 7

Open a web browser and navigate to http://www.jboss.org/products/eap/. Click the green “download” button on the upper right of the page. If you have not yet done so, you will be prompted to review and accept the terms of the Red Hat JBoss Developer Program. Alternatively, just log-in and wait for the download to begin. Attention: This will download the 6.4.0-installer. We just want to download a ZIP file of the ALPHA release! You need to follow the link to all downloads and select the 7.0.0.Alpha ZIP Download (172mb). When finished, unzip into a folder of your choice. We call this folder “EAP_HOME” from now on. The installation is finished.

Startup And Basic Administration

Start the server in standalone mode via the following command:

$ EAP_HOME/bin/standalone.bat|.sh

If successful, you will see the following last lines of the output:

09:46:50,789 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: EAP 7.0.0.Alpha1 (WildFly Core 2.0.0.CR8) started in 15482ms - Started 259 of 489 services (314 services are lazy, passive or on-demand)

You must create a management user in order to access the web-based management console and remote instances of the management CLI. Execute the script:

$ EAP_HOME/bin/add-user.bat|.sh

and fill in the required information. Make sure to select the option “a) Management User” when offered. I am using the highly unsecure combination of admin/admin as username/password. If you added the user, you can check in your browser if the server is up and running. Redirect your browser to http://localhost:9990/ and login with the admin-user. You will be presented with the revamped admin-console.

jboss-eap7-admin

Now it is time to setup your development environment and get you started with a first Java EE 7 application.

Setup The Development Environment

The natural choice for EAP 7 based applications is the JBoss Developer Studio (JBDS). Download the latest version 9.0 from the jboss.org product pages and install as described there. Start it after installation and go to the “servers tab” to add a new EAP 7 server.

jbds-eap7-server

Expand Red Hat JBoss Middleware and choose JBoss Enterprise Application Platform 7.0 (Experimental). Enter a server name, for example, “JBoss EAP 7.0”, then click Next to create the JBoss runtime and define the server. The next time you define a new server, this dialog displays a Server runtime environment selection with the new runtime definition. Create a Server Adapter to manage starting and stopping the server. Keep the defaults and click Next. Enter a name, for example “JBoss EAP 7.0 Runtime”. Under Home Directory, click Browse and navigate to your JBoss EAP install location. Then click Next.

Create Your First Java EE 7 Application

Now all the bits and pieces are in place and you can start to create your first Java EE 7 application. Right click into the project explorer in JBDS and select “new”, select “other”, scroll down to Maven and select “New Maven Project”. Accept the standards in the next dialogue and type “javaee7” into the filter text.box. Select the “com.airhacks.javaee7-essentials-archetype” and click next.

jbds-new-ee7

Enter a group- and artifact-id and click “finish”. Maven is downloading the archetype and instantiating a project from that template. Expand the project and navigate to the source package com.airhacks and right click. Select “new”, “other”, “WebServices” and select “JAX-RS Resource”. Enter source folder and package and name the resource “HelloResource”. Click “Finish”. Open the newly created class and change it to this:

package net.eisele;

import javax.enterprise.context.RequestScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@RequestScoped
@Path("")
public class HelloService {

 @Produces("application/json")
 @GET
 public String sayHello(){
  return "{\"name\" : \"Hello\"}";
 }
}

Last step is to actually deploy and run the application on EAP 7. Right click the project and select “Run As…” and “Run On Server” and select the existing EAP 7 server. You can see, that our demo project is configured in the next dialogue. Click “Finish” and switch to the “Console” view to see the server starting. And as you can see, the demo.war file is also deployed. When you now visit http://localhost:8080/demo/resources with your browser, you see the json output:

{"name" : "Hello"}

Congratulations! That has been your first Java EE 7 example on JBoss EAP 7 ALPHA. Now you might want to check out the quickstarts or the documentation:

Markus Eisele

Markus is a Developer Advocate at Red Hat and focuses on JBoss Middleware. He is working with Java EE servers from different vendors since more than 14 years and talks about his favorite topics around Java EE on conferences all over the world. He has been a principle consultant and worked with different customers on all kinds of Java EE related applications and solutions. Beside that he has always been a prolific blogger, writer and tech editor for different Java EE related books. He is an active member of the German DOAG e.V. and it's representative on the iJUG e.V. As a Java Champion and former ACE Director he is well known in the community. Follow him on Twitter @myfear.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button