javaee7-hol/docs/chapters/appendix.adoc at master · javaee-samples/javaee7-hol · GitHub
Skip to content

Latest commit

 

History

History
executable file
·
461 lines (400 loc) · 24.2 KB

File metadata and controls

executable file
·
461 lines (400 loc) · 24.2 KB

Appendix A: Appendix

Configure WildFly 8 in NetBeans

Install WildFly plugin

  1. In NetBeans, click on `Tools', `Plugins', `Available Plugins', type ``wildfly'' in `Search:' box, and select the plugin by clicking on the checkbox in `Install' column.

    16 netbeans available plugins wildfly
    Figure 1. Available Plugins in NetBeans

    The exact plugin version and the date may be different.

  2. Click the Install button, then Next >, accept the license agreement by clicking on the checkbox, then click the Install button to install the plugin. Click the Finish button to restart the IDE and complete installation.

Configure WildFly 8

  1. In NetBeans, click on `Services' tab.

  2. Right-click on Servers, choose `Add Server…​' in the pop-up menu.

    netbeans addserver
    Figure 2. Add Server in NetBeans
  3. Select `WildFly Application Server' in the Add Server Instance wizard, set the name to `WildFly 8' and click Next >.

    16 netbeans add instance wildfly
    Figure 3. Add WildFly instance to NetBeans
  4. Click on Browse…​ for `Server Location' and select the directory that got created when WildFly archive was unzipped. Click on Browse…​ for `Server Configuration' and select the `standalone/configuration/standalone-full.xml' file in the unzipped WildFly archive.

    16 netbeans wildfly full platform
    Figure 4. Configure WildFly full instance in NetBeans

    Click on Next and then Finish. The `Services' should show the WildFly instance.

    16 netbeans wildfly server
    Figure 5. WildFly instance in NetBeans Services tab

Prepare IntelliJ IDEA for working with WildFly 8

To be able to perform the exercises discussed in this tutorial, you need the Ultimate Edition of IntelliJ IDEA. Keep that in mind when downloading IntelliJ IDEA from http://www.jetbrains.com/idea/download/.

When the appropriate edition of IntelliJ IDEA is installed, you can start preparing the IDE for the exercises:

Specify the JDK

First of all, you should specify the JDK that you are going to use. In IntelliJ IDEA, this is done in the Project Structure dialog:

  1. Start IntelliJ IDEA. If, as a result, a project opens, close the project (File  Close Project).

  2. On the Welcome screen, under Quick Start, click Configure.

    i13 welcome configure
    Figure 6. Welcome to IntelliJ IDEA
  3. Under Configure, click Project Defaults, and then, under Project Defaults, click Project Structure.

  4. In the left-hand pane of the Project Structure dialog, under Platform Settings, select SDKs. Click i13 plus icon and select JDK.

    i13 plus jdk
    Figure 7. Add JDK in IntelliJ IDEA
  5. In the Select Home Directory for JDK dialog, select the folder in which the JDK that you are going to use is installed, and click OK.

    i13 jdk home
    Figure 8. JDK home in IntelliJ IDEA
  6. In the Project Structure dialog, click Apply.

    i13 jdk defined
    Figure 9. JDK defined in IntelliJ IDEA

    Now, let’s make the JDK that we have specified the default SDK.

  7. In the left-hand pane, under Project Settings, select Project. In the right-hand part of the dialog, under Project SDK, select the JDK from the list.

    i13 project sdk
    Figure 10. Project SDK in IntelliJ IDEA
  8. Click OK.

Define WildFly

Defining an application server in IntelliJ IDEA, normally, is just telling the IDE where the server is installed. The servers are defined in the Settings dialog. (On OSX, this dialog is called Preferences.)

  1. On the Welcome screen, to the left of Project Defaults, click Back i13 back icon.

  2. Under Configure, click Settings.

  3. In the left-hand pane of the Settings (Preferences) dialog, under IDE Settings, select Application Servers. On the Application Servers page, click i13 plus icon and select JBoss Server. (WildFly is a server from the "JBoss family".)

    i13 plus jboss
    Figure 11. Add WildFly in IntelliJ IDEA
  4. In the JBoss Server dialog, click i13 ellipsis button to the right of the JBoss Home field.

    i13 jboss server dialog initial
    Figure 12. WildFly server dialog in IntelliJ IDEA
  5. In the JBoss Home Directory dialog, select the folder in which you have the WildFly server installed, and click OK.

    i13 jboss home directory
    Figure 13. WildFly home in IntelliJ IDEA
  6. Click OK in the JBoss Server dialog.

    i13 jboss server dialog final
    Figure 14. WildFly final dialog in IntelliJ IDEA
  7. In the Settings (Preferences) dialog, click OK.

    i13 jboss defined
    Figure 15. WildFly defined in IntelliJ IDEA

Create a project

The sample application is supplied as a Maven project with an associated pom.xml file that contains all the necessary project definitions. The corresponding IntelliJ IDEA project in such a case can be created by simply "opening" the pom.xml file. (Obviously, this isn’t the only way to create projects in IDEA. You can create projects for existing collections of source files, import Eclipse and Flash Builder projects, and Gradle build scripts. Finally, you can create projects from scratch.)

  1. On the Welcome screen, to the left of Configure, click Back i13 back icon.

  2. Under Quick Start, click Open Project.

    i13 open project
    Figure 16. Open project in IntelliJ IDEA
  3. In the Open Project dialog, select the pom.xml file associated with the sample application, and click OK.

    i13 select pom
    Figure 17. Select pom in IntelliJ IDEA

    Wait while IntelliJ IDEA is processing pom.xml and creating the project. When this process is complete, the following message is shown:

    i13 jpa detected
    Figure 18. Configure JPA in IntelliJ IDEA
  4. Click Configure in the message box. (If by now the message has disappeared, click i13 exclamation mark icon on the Status bar.

    i13 jpa detected status bar
    Figure 19. JPA detected in status bar in IntelliJ IDEA

    The Event Log tool window will open. Click Configure in this window.)

    i13 jpa detected event log
    Figure 20. JPA detected event log in IntelliJ IDEA
  5. In the Setup Frameworks dialog, just click OK. (By doing so you confirm that the file persistence.xml found in the project belongs to the JPA framework.)

    i13 setup frameworks jpa
    Figure 21. Setup frameworks in IntelliJ IDEA

    Now, as an intermediate check, make sure that the project structure looks something similar to this:

    i13 initial project structure
    Figure 22. Project structure in IntelliJ IDEA

Create a run/debug configuration

Applications in IntelliJ IDEA are run and debugged according to what is called run/debug configurations. Now we are going to create the configuration for running and debugging the sample application in the context of WildFly.

  1. In the main menu, select Run  Edit Configurations…​.

    i13 run edit configurations
    Figure 23. Edit configurations in IntelliJ IDEA
  2. In the Run/Debug Configurations dialog, click i13 plus icon, select JBoss Server, and then select Local.

    i13 run configs plus jboss
    Figure 24. WildFly configuration in IntelliJ IDEA

    As a result, the run/debug configuration for the WildFly server is created and its settings are shown in the right-hand part of the dialog.

  3. Change the name of the run/debug configuration to WildFly8 (optional).

  4. In the lower part of the dialog, within the line Warning: No artifacts marked for deployment, click Fix and select movieplex7:war exploded. (Artifacts in IntelliJ IDEA are deployment-ready project outputs and also the configurations according to which such outputs are produced. In our case, there are two configurations for the sample application (movieplex7:war and movieplex7:war exploded). Both configurations represent a format suitable for deployment onto a Java EE 7-enabled application server. movieplex7:war corresponds to a Web archive (WAR). movieplex7:war exploded corresponds to the sample application directory structure (a decompressed archive). The second of the formats is more suitable at the development stage because manipulations with it are faster.)

    i13 jboss fix deployment
    Figure 25. Fixing deployment warning in IntelliJ IDEA
  5. Within the line Error: Artifact 'movieplex7: exploded' has invalid extension, click Fix.

    i13 jboss invalid extension
    Figure 26. Invalid extension error message in IntelliJ IDEA
  6. In the Project Structure dialog, add .war at the end of the output directory path, and click OK. (For the servers of the JBoss family, the application root directory has to have .war at the end.)

    i13 jboss fix extension
    Figure 27. Extension error fix in IntelliJ IDEA
  7. In the Run/Debug Configurations dialog, switch to the Server tab. In the field for the application starting page URL, replace http://localhost:8080/movieplex7-1/ with http://localhost:8080/movieplex7-1.0-SNAPSHOT/ and click OK.

    i13 jboss url fixed
    Figure 28. Fixing application URL in IntelliJ IDEA

The Application Servers tool window opens in the lower part of the workspace. Shown in this window are the server run/debug configuration and the associated deployment artifact. Now you are ready to run the application.

Run the application

In the Application Servers tool window, select the server run/debug configuration (WildFly8 [local]) and click Run i13 run icon.

i13 run wildfly
Figure 29. Run WildFly in IntelliJ IDEA

IntelliJ IDEA compiles the code, builds the artifact, starts WildFly and deploys the artifact to the server. You can monitor this process in the Run tool window that opens in the lower part of the workspace.

i13 run tool window wildfly
Figure 30. Run tool window in IntelliJ IDEA

Finally, your default Web browser opens and the starting page of the application is shown.

i13 starting page in browser
Figure 31. Starting page in browser from IntelliJ IDEA

At this step IntelliJ IDEA is fully prepared for your development work, and you can continue with your exercises.