Chapter 3. Developing Applications Using JBoss EAP
This guide provides information on getting started developing applications by using Red Hat JBoss Developer Studio and the JBoss EAP 7 quickstart examples.
Red Hat JBoss Developer Studio is an Eclipse-based integrated development environment (IDE) that integrates JBoss application development plug-ins. JBoss Developer Studio can assist with your application development with the availability of JBoss-specific wizards and the ability to deploy applications to JBoss EAP servers. Many quickstart code examples are provided with JBoss EAP 7 to help users get started writing applications using different Java EE 7 technologies.
This guide provides basic installation instructions for JBoss Developer Studio. See the Install Red Hat JBoss Developer Studio guide for complete installation instructions.
3.2. Setting up the Development Environment
3.2.1. Download JBoss Developer Studio
JBoss Developer Studio can be downloaded from the Red Hat Customer Portal.
- Log in to the Red Hat Customer Portal.
- Click Downloads.
- In the Product Downloads list, click Red Hat JBoss Developer Studio.
Select the desired version in the Version drop-down menu.Note
It is recommended to use JBoss Developer Studio version 9.1 or later.
- Find the Red Hat JBoss Developer Studio 9.x.x Stand-alone Installer entry in the table and click Download.
- Save the JAR file to the desired directory.
3.2.2. Install JBoss Developer Studio
- Open a terminal and navigate to the directory containing the downloaded JAR file.
Run the following command to launch the GUI installation program:
$ java -jar jboss-devstudio-BUILD_VERSION-installer-standalone.jarNote
Alternatively, you may be able to double-click the JAR file to launch the installation program.
- Click Next to start the installation process.
- Select I accept the terms of this license agreement and click Next.
Adjust the installation path and click Next.Note
If the installation path folder does not exist, a prompt will appear. Click OK to create the folder.
- Choose a JVM, or leave the default JVM selected, and click Next.
- Click Next when asked to select platforms and servers.
- Review the installation details, and click Next.
- Click Next when the installation process is complete.
- Configure the desktop shortcuts for JBoss Developer Studio, and click Next.
- Click Done.
3.2.3. Start JBoss Developer Studio
To start JBoss Developer Studio, you can double-click on the desktop shortcut created during the installation, or you can start it from a command line. Follow the below steps to start JBoss Developer Studio using the command line.
- Open a terminal and navigate to the JBoss Developer Studio installation directory.
Run the following command to start JBoss Developer Studio:
For Windows Server, use the
3.2.4. Add the JBoss EAP Server to JBoss Developer Studio
These instructions assume that you have not yet added any JBoss EAP servers to JBoss Developer Studio. Use the following steps to add your JBoss EAP server using the Define New Server wizard.
Open the Servers tab.Note
If the Servers tab is not shown, add it to the panel by selecting Window → Show View → Servers.
Click on the No servers are available. Click this link to create a new server link.
Figure 3.1. Add a New Server
Expand Red Hat JBoss Middleware and choose JBoss Enterprise Application Platform 7.0. Enter a server name, for example,
JBoss EAP 7.0, then click Next.
Figure 3.2. Define a New Server
Create a server adapter to manage starting and stopping the server. Keep the defaults and click Next.
Figure 3.3. Create a New Server Adapter
Enter a name, for example
JBoss EAP 7.0 Runtime. Click Browse next to Home Directory and navigate to your JBoss EAP installation directory. Then click Next.
Figure 3.4. Add New Server Runtime EnvironmentNote
Some quickstarts require that you run the server with a different profile or additional arguments. For example, to deploy a quickstart that requires the full profile, you must define a new server and specify
standalone-full.xmlin the Configuration file field. Be sure to give the new server a descriptive name.
Configure existing projects for the new server. Because you do not have any projects at this point, click Finish.
Figure 3.5. Modify Resources for the New Server
JBoss EAP 7.0 server is now listed in the Servers tab.
Figure 3.6. Server List
3.3. Using the Quickstart Examples
The quickstart examples provided with JBoss EAP are Maven projects.
3.3.1. About Maven
Apache Maven is a distributed build automation tool used in Java application development to create, manage, and build software projects. Maven uses standard configuration files called Project Object Model (POM) files to define projects and manage the build process. POMs describe the module and component dependencies, build order, and targets for the resulting project packaging and output using an XML file. This ensures that the project is built in a correct and uniform manner.
Maven achieves this by using a repository. A Maven repository stores Java libraries, plug-ins, and other build artifacts. The default public repository is the Maven 2 Central Repository, but repositories can be private and internal within a company with a goal to share common artifacts among development teams. Repositories are also available from third-parties. For more information, see the Apache Maven project and the Introduction to Repositories guide.
JBoss EAP includes a Maven repository that contains many of the requirements that Java EE developers typically use to build applications on JBoss EAP.
For more information about how to use Maven with JBoss EAP, see Using Maven with JBoss EAP in the JBoss EAP Development Guide.
3.3.2. Using Maven with the Quickstarts
The artifacts and dependencies needed to build and deploy applications to JBoss EAP 7 are hosted on a public repository. Starting with the JBoss EAP 7 quickstarts, it is no longer necessary to configure your Maven
settings.xml file to use these repositories when building the quickstarts. The Maven repositories are now configured in the quickstart project POM files. This method of configuration is provided to make it easier to get started with the quickstarts, however, is generally not recommended for production projects because it can slow down your build.
Red Hat JBoss Developer Studio includes Maven, so there is no need to download and install it separately. It is recommended to use JBoss Developer Studio version 9.1 or later.
If you plan to use the Maven command line to build and deploy your applications, then you must first download Maven from the Apache Maven project and install it using the instructions provided in the Maven documentation.
3.3.3. Download and Run the Quickstarts
220.127.116.11. Download the Quickstarts
JBoss EAP comes with a comprehensive set of quickstart code examples designed to help users begin writing applications using various Java EE 7 technologies. The quickstarts can be downloaded from the Red Hat Customer Portal.
- Log in to the Red Hat Customer Portal.
- Click Downloads.
- In the Product Downloads list, click Red Hat JBoss Enterprise Application Platform.
- Select the desired version in the Version drop-down menu.
- Find the Red Hat JBoss Enterprise Application Platform 7.0.0 Quickstarts entry in the table and click Download.
- Save the ZIP file to the desired directory.
- Extract the ZIP file.
18.104.22.168. Run the Quickstarts in JBoss Developer Studio
Once the quickstarts have been downloaded, they can be imported into JBoss Developer Studio and deployed to JBoss EAP.
Import a Quickstart into JBoss Developer Studio
Each quickstart ships with a POM file that contains its project and configuration information. Use this POM file to easily import the quickstart into JBoss Developer Studio.
If your quickstart project folder is located within the IDE workspace when you import it into JBoss Developer Studio, the IDE generates an invalid project name and WAR archive name. Be sure your quickstart project folder is located outside the IDE workspace before you begin.
- Start JBoss Developer Studio.
- Select File → Import.
Choose Maven → Existing Maven Projects, then click Next.
Figure 3.7. Import Existing Maven Projects
Browse to the desired quickstart’s directory (for example the
helloworldquickstart), and click OK. The Projects list box is populated with the
pom.xmlfile of the selected quickstart project.
Figure 3.8. Select Maven Projects
- Click Finish.
Run the helloworld Quickstart
helloworld quickstart is a simple way to verify that the JBoss EAP server is configured and running correctly.
- If you have not yet defined a server, add the JBoss EAP server to JBoss Developer Studio.
Right-click the jboss-helloworld project in the Project Explorer tab and select Run As → Run on Server.
Figure 3.9. Run As - Run on Server
Select JBoss EAP 7.0 from the server list and click Next.
Figure 3.10. Run on Server
The jboss-helloworld quickstart is already listed to be configured on the server. Click Finish to deploy the quickstart.
Figure 3.11. Modify Resources Configured on the Server
Verify the results.
In the Server tab, the
JBoss EAP 7.0server status changes to
The Console tab shows messages detailing the JBoss EAP server start and the
WFLYUT0021: Registered web context: /jboss-helloworld WFLYSRV0010: Deployed "jboss-helloworld.war" (runtime-name : "jboss-helloworld.war")
helloworldapplication is available at http://localhost:8080/jboss-helloworld and displays the text
- In the Server tab, the
Run the bean-validation Quickstart
Some quickstarts, such as the
bean-validation quickstart, do not provide a user interface layer and instead provide Arquillian tests to demonstrate functionality.
bean-validationquickstart into JBoss Developer Studio.
- In the Servers tab, right-click on the server and choose Start to start the JBoss EAP server. If you do not see a Servers tab or have not yet defined a server, add the JBoss EAP server to Red Hat JBoss Developer Studio.
Right-click on the
jboss-bean-validationproject in the Project Explorer tab and select Run As → Maven Build.
Enter the following in the Goals input field and then click Run.
clean test -Parq-wildfly-remote
Figure 3.12. Edit Configuration
Verify the results.
The Console tab shows the results of the
------------------------------------------------------- T E S T S ------------------------------------------------------- Running org.jboss.as.quickstarts.bean_validation.test.MemberValidationTest Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.189 sec Results : Tests run: 5, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
22.214.171.124. Run the Quickstarts from the Command Line
You can easily build and deploy the quickstarts from the command line using Maven. If you do not yet have Maven installed, see the Apache Maven project to download and install it.
README.md file is provided at the root directory of the quickstarts that contains general information about system requirements, configuring Maven, adding users, and running the quickstarts.
Each quickstart also contains its own
README.md file that provides the specific instructions and Maven commands to run that quickstart.
Run the helloworld Quickstart from the Command Line
README.mdfile in the root directory of the helloworld quickstart.
Start the JBoss EAP server.
- Navigate to the helloworld quickstart directory.
Build and deploy the quickstart using the Maven command provided in the quickstart’s
mvn clean install wildfly:deploy
The helloworld application is now available at http://localhost:8080/jboss-helloworld and displays the text