Red Hat Training

A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform

Chapter 1. Get Started Developing Applications

1.1. Introduction

1.1.1. About Red Hat JBoss Enterprise Application Platform 7

Red Hat JBoss Enterprise Application Platform 7 (JBoss EAP) is a middleware platform built on open standards and compliant with the Java Enterprise Edition 7 specification.

JBoss EAP includes a modular structure that allows service enabling only when required, improving startup speed.

The management console and management command-line interface (CLI) make editing XML configuration files unnecessary and add the ability to script and automate tasks.

JBoss EAP provides two operating modes for JBoss EAP 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.

In addition, JBoss EAP includes APIs and development frameworks for quickly developing secure and scalable Java EE applications.

1.2. Become Familiar with Java Enterprise Edition 7

1.2.1. Overview of Java EE 7 Profiles

Java Enterprise Edition (Java EE) 7 includes support for profiles, which are subsets of APIs that represent configurations that are suited to specific classes of applications. The only profile that the Java EE 7 specification defines is the Web Profile. A product can choose to implement the full platform, the Web Profile, or one or more custom profiles, in any combination.

JBoss EAP 7.1 is a certified implementation of the Java Enterprise Edition 7 full platform and the Web Profile specifications.

Java Enterprise Edition 7 Web Profile

The Web Profile is the first and only profile defined by the Java Enterprise Edition 7 specification. It includes a selected subset of APIs that are designed to be useful for web application development. The Web Profile supports the following APIs:

  • Java EE 7 Web Profile Requirements:

    • Java Platform, Enterprise Edition 7
  • Java Web Technologies:

    • Servlet 3.1 (JSR 340)
    • JSP 2.3
    • Expression Language (EL) 3.0
    • JavaServer Faces (JSF) 2.2 (JSR 344)
    • Java Standard Tag Library (JSTL) for JSP 1.2

      Note

      A known security risk in JBoss EAP exists where the Java Standard Tag Library (JSTL) allows the processing of external entity references in untrusted XML documents which could access resources on the host system and, potentially, allow arbitrary code execution.

      To avoid this, the JBoss EAP server has to be run with system property org.apache.taglibs.standard.xml.accessExternalEntity correctly set, usually with an empty string as value. This can be done in two ways:

      • Configuring the system properties and restarting the server.

        org.apache.taglibs.standard.xml.accessExternalEntity
      • Passing -Dorg.apache.taglibs.standard.xml.accessExternalEntity="" as an argument to the standalone.sh or domain.sh scripts.
    • Debugging Support for Other Languages 1.0 (JSR 45)
  • Enterprise Application Technologies:

    • Contexts and Dependency Injection (CDI) 1.1 (JSR 346)
    • Dependency Injection for Java 1.0 (JSR 330)
    • Enterprise JavaBeans 3.2 Lite (JSR 345)
    • Java Persistence API 2.1 (JSR 338)
    • Common Annotations for the Java Platform 1.1 (JSR 250)
    • Java Transaction API (JTA) 1.2 (JSR 907)
    • Bean Validation 1.1 (JSR 349)

The full platform implementation defined by the Java EE 7 specification includes additional APIs.

Java Enterprise Edition 7 Full Platform

The Java EE 7 specification full platform includes all APIs and specifications included in the Java EE 7 specification. It supports the following APIs in addition to those supported in the Java Enterprise Edition 7 Web Profile:

Included in the Java EE 7 full platform:

  • Batch 1.0
  • JSON-P 1.0
  • Concurrency 1.0
  • WebSocket 1.1
  • JMS 2.0
  • JPA 2.1
  • JCA 1.7
  • JAX-RS 2.0
  • JAX-WS 2.2
  • Servlet 3.1
  • JSF 2.2
  • JSP 2.3
  • EL 3.0
  • CDI 1.1
  • CDI Extensions
  • JTA 1.2
  • Interceptors 1.2
  • Common Annotations 1.1
  • Managed Beans 1.0
  • EJB 3.2
  • Bean Validation 1.1

1.3. Setting up the Development Environment

It is recommended to use JBoss Developer Studio 11.0 or later with JBoss EAP 7.1.

  1. Download and install JBoss Developer Studio.

    For instructions, see Installing JBoss Developer Studio Stand-alone Using the Installer in the JBoss Developer Studio Installation Guide.

  2. Set up the JBoss EAP server in JBoss Developer Studio.

    For instructions, see Using Runtime Detection to Set Up JBoss EAP from within the IDE in the Getting Started with JBoss Developer Studio Tools guide.

1.4. Configure Annotation Processing in JBoss Developer Studio

Annotation Processing (AP) is turned off by default in Eclipse. If your project generates implementation classes, this can result in java.lang.ExceptionInInitializerError exceptions, followed by CLASS_NAME (implementation not found) error messages when you deploy your project.

You can resolve these issues in one of the following ways. You can enable annotation processing for the individual project or you can enable annotation processing globally for all JBoss Developer Studio projects.

Enable Annotation Processing for an Individual Project

To enable annotation processing for a specific project, you must add the m2e.apt.activation property with a value of jdt_apt to the project’s pom.xml file.

<properties>
    <m2e.apt.activation>jdt_apt</m2e.apt.activation>
</properties>

You can find examples of this technique in the pom.xml files for the logging-tools and kitchensink-ml quickstarts that ship with JBoss EAP.

Enable Annotation Processing Globally in JBoss Developer Studio

  1. Select WindowPreferences.
  2. Expand Maven, and select Annotation Processing.
  3. Under Select Annotation Processing Mode, select Automatically configure JDT APT (builds faster , but outcome may differ from Maven builds), then click Apply and Close.

1.5. Configure the Default Welcome Web Application

JBoss EAP includes a default Welcome application, which displays at the root context on port 8080 by default.

This default Welcome application can be replaced with your own web application. This can be configured in one of two ways:

You can also disable the welcome content.

Change the welcome-content File Handler

  1. Modify the existing welcome-content file handler’s path to point to the new deployment.

    /subsystem=undertow/configuration=handler/file=welcome-content:write-attribute(name=path,value="/path/to/content")
    Note

    Alternatively, you could create a different file handler to be used by the server’s root.

    /subsystem=undertow/configuration=handler/file=NEW_FILE_HANDLER:add(path="/path/to/content")
    /subsystem=undertow/server=default-server/host=default-host/location=\/:write-attribute(name=handler,value=NEW_FILE_HANDLER)
  2. Reload the server for the changes to take effect.

    reload

Change the default-web-module

  1. Map a deployed web application to the server’s root.

    /subsystem=undertow/server=default-server/host=default-host:write-attribute(name=default-web-module,value=hello.war)
  2. Reload the server for the changes to take effect.

    reload

Disable the Default Welcome Web Application

  1. Disable the welcome application by removing the location entry / for the default-host.

    /subsystem=undertow/server=default-server/host=default-host/location=\/:remove
  2. Reload the server for the changes to take effect.

    reload