Creating a Servlet in the Liberty environment

Introduction

Configure the Servlet to work in the Liberty environment.

Download Derby

Download Derby for use from Liberty and db-derby-10.14.2.0-lib.zip Extract the jar file to the directory [liberty_install_dir] / usr / servers / [server_name] / derby.

Apache Derby: Downloads

dir


C:\opt\wlp\usr\servers\server1\derby\lib>dir
...
 C:\opt\wlp\usr\servers\server1\derby\lib directory

2018/06/14  23:33    <DIR>          .
2018/06/14  23:33    <DIR>          ..
2018/06/14  23:33         3,232,770 derby.jar
2018/06/14  23:33             1,490 derby.war
2018/06/14  23:33           588,394 derbyclient.jar
2018/06/14  23:33            94,559 derbyLocale_cs.jar
2018/06/14  23:33           112,080 derbyLocale_de_DE.jar
2018/06/14  23:33           105,743 derbyLocale_es.jar
...

Liberty server.xml

Liberty is configured by editing server.xml. If it is created by default, the SSL key password and administrative user are not specified. The following is the specification and Derby specified in the session DB. The location of server.xml is server.config.dir

server.config.dir : [liberty_install_dir]/usr/servers/[server_name]

Will be.

server.xml


<server description="new server">
    <featureManager>
      <feature>javaee-7.0</feature>
      <feature>sessionDatabase-1.0</feature>
      <feature>localConnector-1.0</feature>
    </featureManager>

    <keyStore password="password"/> 
    <basicRegistry id="basic" realm="BasicRealm">
        <user name="wasadmin" password="password"/>
    </basicRegistry>
    <httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>
    <httpSessionDatabase id="SessionDB" dataSourceRef="SessionDS"/>
    
    <fileset id="DerbyFiles" includes="*.jar" dir="${server.config.dir}/derby/lib"/>
    <library id="DerbyLib" filesetRef="DerbyFiles"/>
    <jdbcDriver id="DerbyDriver" libraryRef="DerbyLib"/>

    <dataSource id="SessionDS" jdbcDriverRef="DerbyDriver" jndiName="jdbc/sessions">
    <properties.derby.embedded
            databaseName="${server.config.dir}/derby/sessiondb" createDatabase="create" />
    </dataSource>
    
    <applicationManager autoExpand="true"/>
</server>

Launch Liberty

This is not a problem when starting from Eclipse, but the following settings are required when executing from the command line. You can start server1.

cmd


set JAVA_HOME=C:\opt\eclipseJ9\ibm_sdk80
set PATH=C:\opt\wlp\bin;%PATH%
server start server1
Server server1 is starting.
Server server1 has started.

server stop server1
Server server1 is down.
Server server1 has stopped.

Create Servlet in Eclipse

Create a Web Project with File> New> Web Project. image.png

Create with Servlet> New> Servlet. image.png

Start the application with Servlet> Run As> Run On Server to access the Servlet. image.png

If you remember this procedure, you will be able to do a simple test immediately.

reference

Configure Liberty session persistence (https://www.ibm.com/support/knowledgecenter/en/SS7K4U_liberty/com.ibm.websphere.wlp.zseries.doc/ae/twlp_admin_session_persistence.html) Configuring related database connections in Liberty (https://www.ibm.com/support/knowledgecenter/en/SSAW57_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_dep_configuring_ds.html) Server command options (https://www.ibm.com/support/knowledgecenter/en/SSAW57_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/rwlp_command_server.html)

Recommended Posts

Creating a Servlet in the Liberty environment
Easily monitor the indoor environment-⑦ Summarize in a simple tool-
Create a database in a production environment
Create a Servlet program in Eclipse
Build a browser test environment using Capybara in the Docker development environment
Install Rails in the development environment and create a new application
We will build a Spring Framework development environment in the on-premises environment.
Building a Lambda development environment in Eclipse
The road to creating a music game 2
[Creating] A memorandum about coding in Java
Creating a matrix class in Java Part 1
Take a thread dump in a JRE environment
[Rails] Reset the database in the production environment
The road to creating a music game 3
Display the background image in the production environment
The road to creating a music game 1
Creating a sample program using the problem of a database specialist in DDD Improvement 2
Add .gitignore when creating a project in Xcode
Escape processing when creating a URL in Ruby
Be careful when setting the class name when creating a document-based app in Swift
Measure the size of a folder in Java
Creating a sample program using the problem of a database specialist in DDD Improvement 1
(Ruby on Rails6) Creating data in a table
[When using MiniMagick] A memorandum because I stumbled in the CircleCI test environment.
The road to creating a Web service (Part 1)
I stumbled when I tried using neo4j in the jenv environment, so make a note
Count the number of occurrences of a string in Ruby
Memo to build a Servlet environment on AWS EC2
How to create a Java environment in just 3 seconds
Prepare the execution environment of Tomcat in IntelliJ Community
I get Mysql2 :: Error :: ConnectionError in the production environment
Calculate the difference between numbers in a Ruby array
A note for Initializing Fields in the Java tutorial
[Ruby / Rails] Set a unique (unique) value in the class
Verification value error that occurred in a clustering environment
[Note] Build a Python3 environment with Docker in EC2
[Java] Get the file in the jar regardless of the environment
A command that definitely cleans the local docker environment
SSL in the local environment of Docker / Rails / puma
[Error] The app is not displayed in the production environment
Hivernate Validator does not work in WAS Liberty environment
Creating a lightweight Java environment that runs on Docker
Creating a local repository
Creating a test case
What is a Servlet?
Create a MySQL test environment (+ millions of test data) in 5 minutes
Install / run a standalone robot simulator in wsl2 / docker environment!
A memorandum of the environment variable "JAVA_HOME" path setting procedure
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
A quick explanation of the five types of static in Java
Let's make a calculator application in Java ~ Display the application window
Check the dependency of a specific maven artifact in Coursier
Install by specifying the version of Django in the Docker environment
Determine that the value is a multiple of 〇 in Ruby
Resolve CreateProcess error = 206 when running Java in a Windows environment
How to create a placeholder part to use in the IN clause
Setting the baseURL in the axios module of Docker environment Nuxt
[JSP, Servlet] Launch a new project and check the connection !!
Error in production environment (The asset "~" is not present in the asset pipeline.)
Create a method to return the tax rate in Java
How to add the same Indexes in a nested array