8.3.1. Initial Setup of Web Project

The following is procedures of initial setup of the web project:

  • Generate web project
  • Confirm communications of the web project Overview of the generated project

The overview of the project generated by this procedure is as follows.

Item Description
Project type Maven project
Project composition Single project composition
DB used H2 Database Engine (embedded in the application)
Built-in adapter Routing adapter (for details, see Routing Adapter)
What is included in the generated project?

The following is included in the generated project:

  • Basic configuration for the Nablarch web application
  • web application for communication confirmation
  • Initial configuration of the tool that operates in conjunction with Maven (is imported by referring to nablarch-archetype-parent (parent project)).

For relationship with other projects and directories, see Maven Archetype Configuration. Create blank project

Generate a blank project using the archetypes provided by Nablarch. Execute the mvn command

Use Maven Archetype Plugin(external site) to generate a blank project.

Change the current directory to the directory where the blank project (can be any directory) is to be created, and place the following file.

Batch file

After placing the file, specify the necessary parameters in the arguments and execute the bat file.

generateWebProject.bat 5u24 <<groupId>> <<artifactId>> <<version>> <<package(optional)>>

The parameters configured in the above command are as follows. To change the version of nablarch, change 5u24.

Input item Description Configuration example
groupId Group ID (normally, enter the package name) com.example
artifactId Artifact ID myapp-web
version Version number 0.1.0
package Package (normally the same as group ID) com.example


Item groupId and package are mapped to the Java package name. Use lowercase letters, numbers, and dots for these input values, and do not use hyphens.

If the command ends normally, a blank project is created under the current directory. Communication confirmation Automated test

The following unit tests are included in the project generated from the archetype.

Unit test classes Test content
SampleActionRequestTest Use Nablarch testing framework to check if the screen is visible.

Execute the unit test and confirm that the blank project was successfully generated.

Execute the following command.

cd myapp-web
mvn test


“clean” and “test” of Maven used here are Built-in Lifecycle of Maven.

For information on other lifecycles that exist, see Built-in Lifecycle Bindings (external site).

If the execution is successful, the log given below will be output to the console.

[INFO] -----------------------< com.example:myapp-web >------------------------
[INFO] Building myapp-web 0.1.0
[INFO] --------------------------------[ war ]---------------------------------
[INFO] Results:
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
(rest is omitted) Launch confirmation

The following screen is included in the generated project.

Class used for screen display Details
SampleAction Confirm communications of Nablarch functions commonly used when implementing web applications.

Confirm that the blank project has been successfully generated by displaying the screen on the browser.

If the current directory is not yet moved to the generated project, move the directory.

cd myapp-web

Execute the following command to build the web application.

mvn compile

Execute the following command to start the application for communication confirmation on the web module.

mvn waitt:run


“waitt:run” of Maven used in the above command example is a specification to use the run goal of the waitt maven plugin.

For information on the waitt maven plugin, see waitt maven plugin (external site).

The browser will automatically start up if the launch is successful and the communication confirmation screen will be displayed. Read the contents of the displayed page and confirm that the launch was successful.

Check the log to make sure that an error has not occurred. If the communication confirmation fails for some reason

If the communication confirmation fails for some unknown reason, the correct procedure may not have been followed in some part.

If the reason is not known, try again from Create blank project. Supplementary information (web.xml)

Although <resource-ref> element has to be defined in web.xml to obtain a connection through JNDI, web.xml is shared instead of being separated for each environment for ease of management.

When acquiring the connection through JNDI only in the production environment, <resource-ref> element definition is not required as a setting for the development environment of the local PC, and unless the code that uses the definition is written in the application, <resource-ref> elements are not used. Therefore, a problem does not occur during the operation of the application in the development environment of the local PC.


Custom server.xml cannot be loaded in Tomcat, which is launched by waitt maven plugin. When running the application using the waitt maven plugin, JNDI cannot be used even if the element <resource-ref> is defined in web.xml. Supplementary notes

For information on the method of confirming the data of H2 and tools included in the blank project, see Initial Setup Procedure Supplementary Information.