Installing the GlassFish 5 Server

At the time of writing this chapter, the Linux instance that's been created by AWS is preinstalled with JDK 7. However, we have been using JDK 8 in this book. Therefore, we will start by uninstalling JDK 7 and installing JDK 8. Open a shell in the instance from Eclipse (see the previous sections for details) and run the following commands:

Commands

Description

sudo yum remove java-1.7.0-openjdk -y

Removes JDK 7 from the instance.

sudo yum install java-1.8.0 -y

Installs JDK 8.

wget http://download.oracle.com/glassfish/5.0/release/glassfish-5.0.zip

Downloads GlassFish 5.

unzip glassfish-5.0.zip

Unzips the downloaded GlassFish 5 ZIP file.

glassfish5/glassfish/bin/asadmin --host localhost --port 4848 change-admin-password

Changes the password of the server. Default installation comes with an admin user and no password set. We need to set a password for the remote admin of the server to work.
Note that the user ID is admin and that the old password is empty (no password). Set a new password, for example, admin.

glassfish5/glassfish/bin/startserv > /dev/null 2>&1 &

Starts the server.

curl localhost:8080

Checks if the server is up.

glassfish5/glassfish/bin/asadmin --host localhost --port 4848 enable-secure-admin

Enables the remote admin of the GlassFish 5 Server. 
See the note following this table.

sudo glassfish5/glassfish/bin/asadmin

asadmin> create-service

Creates a service so that it is started when the VM instance starts. After you run the asadmin command, run the create-service command at asadmin> prompt.

glassfish5/glassfish/bin/stopserv

glassfish5/glassfish/bin/startserv > /dev/null 2>&1 &

Stops and starts the server so that the preceding changes take effect.

Note

Between writing this chapter and publishing of the book, the functionality to enable secure admin broke in GlassFish 5 if used with JDK version above 1.8.0.151. Remote access to GlassFish 5 administration console fails with the following error (logged on glassfish/domains/domain1logs/server.log):

java.lang.NoClassDefFoundError: sun/security/ssl/SupportedEllipticPointFormatsExtension

You can refer to the GlassFish 5 bug at https://github.com/javaee/glassfish/issues/22407.

Now, we need to instruct AWS to allow TCP requests at port 4848 (for admin), 8080 (for access web applications), and 3306 (for remote connection to MySQL server) on this instance. We will do this by setting inbound rules on the security group on the instance. Recall that in the previous section we had selected the eclipse-dev security group. We need to set inbound rules on this group. Unfortunately, we can’t do this from the Eclipse plugin (at the time of writing this book). Login to AWS Console on the web and go to Services | EC2 and then to NETWORK & SECURITY | Security Groups. Right-click on the security group eclipse-user and select the Edit inbound rules option. Add rules to allow TCP traffic from the IP of your machine (from where you will remotely access the instance; you can use sites like https://www.whatismyip.com/what-is-my-public-ip-address/ to find the real IP address of your machine):

Figure 13.7: Setting inbound rules on the security group

Note that if your machine receives a dynamic IP, then you will have to update it on the preceding page.


You can now browse to the admin site of GlassFish 5 on your instance—go to https://<your-instance-public-address>:4848. You can find the public address from Eclipse view EC2 Instances, or from the AWS Console online.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.38.176