Glassfish server installation and Configuration
Here we describe how to install and configure the
glassfish Web Application Server.
Note: For development using the
netbeans IDE
you want to use the glassfish server that is bundled with netbeans. In that case you still have to make sure that the
G4Expert and
G4Admin users are created and that the connection pools and
DataSources are created.
we will run the server as user glassfish. So first (as root) we create user glassfish:
/usr/sbin/adduser -d /usr/glassfish4 -m --shell /bin/bash glassfish
Then as user glassfish obtain glassfish from the glassfish download site
http://download.oracle.com/glassfish/4.1/release
wget " target="_blank">http://download.oracle.com/glassfish/4.1/release/glassfish-4.1.zip]]
cd /usr unzip ~/glassfish-4.1.zip
chown -R glassfish.glassfish /usr/glassfish4
get jdk from:
here
Now change the configuration file for glassfish to point to the correct jdk: emacs /usr/glassfish4/glassfish/config/asenv.conf add the line (replace the xxxx with the correct java version AS_JAVA="/usr/java/jdk1..xxxx" Start up scripts:
edit /etc/rc.d/init.d/glassfish make sure the glassfish path is set correctly: GLASSFISHPATH=/usr/glassfish4/bin now before starting set the glassfish server set the admin password
/usr/glassfish4/bin/asadmin change-admin-password --user admin that will prompt you for the new admin password now start the server and allow for remote administration:
/etc/rc.d/init.d/glassfish start
/usr/glassfish4/bin/asadmin --port 4848 enable-secure-admin
this will ask you for the admin account and password you now can administer the server remotely using the following url in case of the g4devel machine:
https://g4devel.fnal.gov:4848/
use the Gui to create the
G4Expert and
G4Admin account and then to deploy the web application.
Configuring a Connection pool on the Web application Server
Our Web Application and Web Service depend on connection pools (one that connects to the database read only, the other with read/write access for authenticated users) being made available on the web application server (glassfish) as a
DataSource. This provides efficient access to the database and avoids that any database info like username, port, dbname and passwords are exposed. Currently the creation and configuration via the web admin gui doesn't seem to work below we list the command line (asadmin) instructions used to set up the pools on the g4devel server providing access to the development database. To be able to use connection pools first one needs to Install the correct jar file containing the
PostgreSQL JDBC driver in the domains area:
/usr/glassfish4/glassfish/domains/domain1/lib/postgresql-9.4.1208.jar
or:
/usr/glassfish4/glassfish/domains/domain1/lib/ext/postgresql-9.4.1208.jar. The jar file can be obtained from the
PostgreSQL download site:
https://jdbc.postgresql.org/download.html
then as user glassfish execute the following command to create the 2 connection pools. These will be started automatically whenever the glassfish server is started.
path_to_glassfish_binaries/asadmin create-jdbc-connection-pool --datasourceclassname org.postgresql.ds.PGConnectionPoolDataSource --restype javax.sql.ConnectionPoolDataSource --property user=xxxxxx:password=yyyyy:url="jdbc\:postgresql\://fnalpgsdev.fnal.gov\:5453/validationdb" myjdbc_postgres-poolpath_to_glassfish_binaries/asadmin create-jdbc-resource --connectionpoolid myjdbc_postgres-pool DataSource path_to_glassfish_binaries/asadmin get domain.resources.jdbc-connection-pool.myjdbc_postgres-poolpath_to_glassfish_binaries/asadmin ping-connection-pool myjdbc_postgres-pool path_to_glassfish_binaries/asadmin create-jdbc-connection-pool --datasourceclassname org.postgresql.ds.PGConnectionPoolDataSource --restype javax.sql.ConnectionPoolDataSource --property user=xxxxxx:password=yyyy:url="jdbc\:postgresql\://fnalpgsdev.fnal.gov\:5453/validationdb" myjdbc_postgres-writerpoolpath_to_glassfish_binaries/asadmin create-jdbc-resource --connectionpoolid myjdbc_postgres-writerpool WriterSource path_to_glassfish_binaries/asadmin get domain.resources.jdbc-connection-pool.myjdbc_postgres-writerpoolpath_to_glassfish_binaries/asadmin ping-connection-pool myjdbc_postgres-writerpool