2019/10/7 Full revision
============================================================================= Hello. It is zd6ir7. It has been a long time since Last post. This time, I will post a memo when I built a Java EE environment on AWS and deployed and ran a web application there. The application to be run this time is the Web application of the online shop of "Miscellaneous goods store.com" that appears at the end of "Introduction to Easy-to-understand JavaEE Web System" (Note 1) ).
The software configuration of the AWS EC2 environment realized this time is as follows.
--OS: Linux kernel version 4.14
The procedure for building the environment and running the Web application this time is as follows.
Create an AWS account by referring to the article "First introduction of AWS Cloud9". Create an EC2 instance of Amazon Linux from the EC2 menu in the management console.
Java is included in the environment, but it has been updated to Java 8 based on the article "Building Java 8 development environment with AWS Cloud9".
Install glassfish 5.0.1 (Note 2) by referring to the article "Memo for building AWS + GlassFish 4.1". When you type the wget command, you need to specify the download source URL of glassfish5.0.1, but specify the URL of v5.0.1 from glassfish download site. Derby (JavaDB) is installed at the same time as glassfish is installed. Leave glassfish running for later steps.
The Web application to be run this time needs to be connected to the database. Since the connection will be set later, 3. Start Derby installed in (Note 3).
sudo bin/asadmin start-database
Starting database in Network Server mode on host 0.0.0.0 and port 1527.
--------- Derby Network Server Information --------
Version: CSS10100/10.10.2.0 - (1582446) Build: 1582446 DRDA Product Id: CSS10100
(Omission)
Starting database in the background.
Log redirected to /opt/glassfish4/glassfish/databases/derby.log.
Command start-database executed successfully.
Added security settings to the AWS EC2 environment to access the glassfish console screen and applications from a PC. Specifically, select the relevant security group from the EC2 menu of the AWS console, and specify the protocol, port number, and access source IP address you want to access the AWS EC2 environment on the "Inbound" tab. In the figure below, the default port number 8080 for glassfish, the port number 4848 for the glassfish management console, and the port number 22 for SSH are set to pass.
Five. In addition, it is necessary to obtain information on the access destination host name or IP address. As shown in the figure below, you can refer to this information by selecting the relevant environment from the EC2 menu of the AWS console.
From a PC browser, https: // <6. Host name or access destination IP address obtained in>: 4848 / Go to and launch the glassfish management console. 3. 3. Since I also set it to pass https, depending on the browser, you may be asked if you want to browse this site, but continue browsing as it is. As shown in the figure below, you will be prompted to enter your user name and password. Log in by entering the user name and password set in.
Set the data source from the glassfish management console screen logged in in 7. Specifically, the following two steps are taken.
--Create a new connection pool by pressing "New" from the "JDBC" menu> "JDBC Connection Pools" on the left side of the management console. Set based on the information in "Introduction to Easy-to-understand Java EE Web System". Created here with the name "Derby Pool". The figure below shows the situation when communicating from this connection pool to the Derby database. --Similarly, press "New" from the "JDBC" menu> "JDBC Resources" to create a data source. Give the JNDI name to the "Derby Pool" created above. Following the same book, the JNDI name is "jdbc / mydb".
Place the "General store.com" application war file in the deployment directory. For this placement, upload the file from the PC using "SCP" of Tera Term. Since glassfish is in the running state, glassfish reads it and executes the deployment process when it is placed. The following is an excerpt of the server log at the time of deployment.
[2019-10-07T11:38:08.497+0900] [glassfish 5.0] [INFO] [AS-WEB-GLUE-00172] [javax.enterprise.web] [tid: _ThreadID =53 _ThreadName=AutoDeployer] [timeMillis: 1570415888497] [levelValue: 800] [[
Loading application [zakka-ya-san] at [/zakka-ya-san]]]
[2019-10-07T11:38:08.617+0900] [glassfish 5.0] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=53 _Thre adName=AutoDeployer] [timeMillis: 1570415888617] [levelValue: 800] [[
zakka-ya-san was successfully deployed in 9,423 milliseconds.]]
[2019-10-07T11:38:08.619+0900] [glassfish 5.0] [INFO] [NCLS-DEPLOYMENT-02035] [javax.enterprise.system.tools.dep loyment.autodeploy] [tid: _ThreadID=53 _ThreadName=AutoDeployer] [timeMillis: 1570415888619] [levelValue: 800] [ [
[AutoDeploy] Successfully autodeployed : /opt/glassfish5/glassfish/domains/domain1/autodeploy/zakka-ya-san.war .]]
From your PC browser, http: // <6. Access the host name or access destination IP address obtained in>: 8080 / zakka-ya-san / and execute the "General store.com" application. A shopping site for learning appears (Note 4)
There were some difficult points, but I was able to build it in a surprisingly short period of time. It's a really convenient time because you can easily create an environment. Thank you for reading this far.
(Note 1) For details of the application, refer to Chapter 18 of the same book. To be exact, it is after the last exercise. (Note 2) With glassfish5.0, I do "asadmin restart-domain" in "AWS + GlassFish 4.1 build memo", but there is an error It will become. See stackoverflow article for more information. Since the problem has been solved in the higher version, glassfish 5.0.1, I decided to use the same version here. (Note 3) Please refer to the following URL for details on the start / stop operation of Derby. https://docs.oracle.com/cd/E19159-01/820-3956/genej/index.html (Note 4) Originally a learning application, you can't shop here! !!
Recommended Posts