This document gives a (rough) overview of WildFly, a Java EE application server. This document may serve as an introduction to application servers in Java EE.
Java EE defines a set of specifications, known as Java Specification Requests (JSR). Application servers have to implement (parts of) these standards in order to be compliant with (a subset of) Java EE. An important standard among those is the Servlet API, or JSR 369.
A Java EE application server is a piece of software that eases the development of web applications, by providing services to the Java web developer. Your application server provides containers in which you, the web developer, embed your code. The container calls your code whenever adequate. For example, we use the web container in the Servlets document.
Examples of Java EE compliant application servers: GlassFish (Oracle, open source, reference implementation of Java EE), WildFly (Red Hat / JBoss, open source), WebSphere AS (IBM)…
-
Download and install a local copy of WildFly (see Tools).
-
The server is commanded thanks to the commands in the
binsubfolder, to be run in a terminal. -
Start the server with
standalone.sh(we will use only the standalone mode). -
The command line interface (CLI) to the server is invoked with
jboss-cli.sh. After invoking this command, connect to your server (the tool tells you how to do this), then typehelp --commandsand find out how to shut it down.
One of the services an application server gives is to provide an SQL database usable by the applications running on the server. Any compliant Java EE server comes with an embedded SQL database management system, that will be used as a default for deployed applications if none other is configured. If the default is not suitable, it is possible to configure other databases on the server, and thus to switch database with no support for this in the source code of the deployed application. (In this course we will be content with the default database.)
-
Restart you server, connect to it with the CLI, type
/subsystem=datasources/:read-children-names(child-type=data-source)to list the configured data sources. What is the name of the default data source?
Supplementary to the somewhat austere CLI, it is possible to configure many aspects of the server using its graphical administration console.
-
Browse to http://localhost:8080/ to reach the server, then
Administration Console. Follow the instructions to create a user. You can then access the Administration console. -
Look at the properties of the data-source whose name you have found previously (into
Configuration, subsytemDatasource & Drivers). -
Open the server log file from the
Administration Console(look intoRuntime). Find where it is on the disk. (It is very useful, for debugging, to be able to open that file quickly with your favorite text viewer.)
The standalone/deployments directory is used to deploy your application, once it is packaged appropriately (e.g., as a WAR file). Simply drop the file there. WildFly will then create a file in the same folder to tell you whether the application was deployed successfully. (Check the Servlets document to learn how to create an adequate file.)
Add JAVA_OPTS="$JAVA_OPTS -ea" at the appropriate place in bin/standalone.conf (after the first line that defines JAVA_OPTS) to enable Java assertions (doc).