Install GlassFish 3.1 on CentOS or RHEL

Install GlassFish 3.1 on CentOS or RHEL
Published (Last updated 11/01/2013 05:28 AM)
Permalink https://davidghedini.com/pg/entry/install_glassfish_3_1_on
This post will cover installing GlassFish 3.1 on CentOS or RHEL.

We’ll also see how to run GlassFish as a service, how to access the Admin Console, and how to run GlassFish under a minimally privileged user.

GlassFish 3.1 is the latest release and is available as GlassFish Server Open Source Edition 3.1 (free) and Oracle GlassFish Server 3.1 (supported and requires paid subscription).

I installed both using the same process below.

The procedure is the same as with 3.0.1 with some minor changes.

If you do not already have the Java Development Kit (JDK) installed on your machine, you will need to download and install the required JDK for your platform.

If you do have the JDK installed, you can skip to: Step 2: Download and Install the GlassFish 3.1 Server:

Step 1: Install the JDK

You can download the JDK here: http://www.oracle.com/technetwork/java/javase/downloads/index.html

I’m using the latest, which is JDK 6, update 24. The JDK is specific to 32 and 64 bit versions.

My CentOS box is 64 bit, so I’ll need: jdk-6u24-linux-x64.bin.

If you are on 32 bit, you’ll need: jdk-6u24-linux-i586.bin

Download the appropriate JDK and save it to a directory. I’m saving it to /root.

Move (mv) or copy (cp) the file to the /opt directory:

Create the directory /usr/java.

Change to the /usr/java directory we created and install the JDK using ‘sh /opt/jdk-6u24-linux-x64.bin’

Set the JAVA_HOME path. This is where we installed the JDK above.

To do this for your current session, you can issue the following:

To set the JAVA_HOME for users, we add this to the user ~/.bashrc or ~/.bash_profile of the user. We can also add it /etc/profile and then source it to give to all users.

Once you have added the above to ~/.bash_profile or ~/.bashrc, you should log out, then log back in and check that the JAVA_HOME is set correctly.

Step 2: Download and Install the GlassFish 3.1 Server:

You can download both the GlassFish Server Open Source Edition 3.1 and Oracle GlassFish Server 3.1 at http://glassfish.java.net/

Once you have downloaded the desired file, move (mv) or copy (cp) the file to /usr/share/glassfish-3.1.zip (or /usr/share/ogs-3.1.zip for Oracle GlassFish).

Change to the /usr/share directory and unzip the file:

The unzip will create the following directory: /usr/share/glassfish3

Note: Both GlassFish editions will create the same directory when unzipped: glassfish3

Step 3: Running GlassFish as a Service.

To run GlassFish as a service and enable start up at boot, we’ll now create a Start/Stop/Restart script.

We’ll create the script as /etc/init.d/glassfish, make the script executable, and then add our new glassfish service to chkconfig.

Create our glassfish script:

If you do not set the JAVA_HOME and PATH in the GlassFish script, when you attempt to start the GlassFish server it will complain it cannot find Java with the following:

error: /usr/share/glassfish3/glassfish/bin/asadmin: line 19: exec: java: not found

Now, make the script executable and add it to our chkconfig so it starts at boot.

We should now be able to Start, Stop, and Restart GlassFish as a service.

Start GlassFish:

Stop GlassFish:

Step 4: Check Homepage.

You should now see the GlassFish default home page at http://youdomain.com:8080 or http://YourIP:8080

If you do not see the home page, check the logs and insure that port 8080 is open and available.

Step 5: Access GlassFish Admin Console.

You should now be able to access the GlassFish Admin Console at:

http://yourdomain.com:4848 or http://yourip:4848

On accessing the GlassFish Admin Console for the first time, you will find that no user name or password is required.

Previous to 3.1, a default password ‘adminadmin’ was used.

You can set (or change) the admin password within the GlassFish Admin console.

1. Click “Domain” on the tree.

2. Click the Administrator Password tab.

3. Enter and confirm your password and click Save.

4. Note that the “Logout” button now appears at top right.

The first password save will create a file,.asadminpass, in the home directory of the user you are running the service under.

Alternatively, you can set the admin password via the CLI using.

Step 6: Running GlassFish with Minimally Privileged (non-root) User.

Since I am installing this on my development machine, I am running GlassFish as root above.

In production, you will want to run GlassFish as a non-root user with minimal privileges.

To do this, we can need to the following.

1. Create the user, glassfish, who will own the files.

Create the new group, glassfish, and add the user glassfish to the group:

2. Change ownership of the GlassFish files to the user glassfish we created.

We’ll change ownership of the files under /usr/share/glassfish3 from root to the user glassfish we created above:

3. Update our glassfish script.

Finally, we update the glassfish start/stop/restart script we created above so we su to user glassfish:

Step 7: Running GlassFish on Port 80 as Non-Root User.

To run services below port 1024 as user other than root, you will need to use port forwarding.

You can do this by adding the following to your IP tables:

JasperReportsIntegration 2.0.0 Beta on JBoss 7

Dietmar Aust / Opal Consulting have released JasperReportsIntegration 2.0.0 Beta for testing.

You can see the announcement here

It is has some amazing new features, is updated for JasperReports 4.7.0, and has a new deployment model.

Most importantly, the new version allows you to easily run JasperReportsIntegration on JBoss 🙂

If you don’t have JBoss 7.1.1 installed, you can follow my tutorial here:

One important note – it did not work for me with JDK 1.7 but worked wonderfully with JDK 1.6

The zip file contains the required items for deployment on JBoss as well as items for Oracle (/sql directory) and Apex (/apex directory), it also contains some scripts to run in standalone mode as well as Jetty.

1. Create a directory under /usr/share to be the home for under JasperReportsIntegration

2. Change to the new directory:

3. Download the kit from Opal:

Or use wget:

3. unzip it.

4. Your directory will look like this:

5. Change to the webapp directory and locate JasperReportsIntegration.war:

6. Move the JasperReportsIntegration.war to JBOSS_HOME/standalone/deployments

In my case /usr/share/jboss-as/standalone/deployments:

7. Once you have moved the WAR, delete the webapp directory along with the following:

4. You should now be left with the following:

If you are running under the user jboss, change ownership of the logs directory at /usr/share/JasperReportsIntegration/logs to the user jboss

5. Change to the conf directory, where you will find application.properties and log4jproperties:

6. The application.properties will look as below:

Change the data sources to your own.

Note that one of the verification tests later will look for a data source with the name ‘default’, so may want to leave one named as ‘default’.

7. Placing OC_JASPER_CONFIG_HOME into the path of JBoss.

Where you place the path to OC_JASPER_CONFIG_HOME depends on the user you running JBoss under.

If you are running JBoss under the user jboss, you need to add the path to OC_JASPER_CONFIG_HOME to the .bash_profile of user jboss.

If you are running JBoss under the user root, you need to add the path to OC_JASPER_CONFIG_HOME to the .bash_profile of the user root.

If you simply place the path into the Jboss init script (JBOSS_HOME/bin/jboss-as-standalone.sh) or into your jboss script under /etc/init.d, it will throw the following error as JBoss will look for the application.properties file under ../JasperReportsIntegration.war-xxx/conf/application.properties:

So, add the following to the .bash_profile of the user your running jboss under (jboss or root):

Along with JAVA_HOME and bin paths (and any others you have), your jboss (or root) user bash_profile would look something like:

8. Install the SQL into the user schema

This bit has not changed.

Connect to your database server and change directories to the location you uploaded the /sql directory.

Connect to SQL*Plus as the required user and run @user_install.sql

Make sure it compiles with no errors.

 

9. Install the f860_JasperIntegrationTest_2.0.0.0.sql Application

Import the f860_JasperIntegrationTest_2.0.0.0.sql into your work space.

The new testing application has some new features as you can see below.

 

10. Verify your installation.

In the screenshot below, you can see I did not use the name ‘default’ for any of my data sources.

JBoss 7 JRI Application

11. Test your reports.

Among other new features, there is now a “Save File on Server” option. This allows you to save the generated report on the file system of the application server (jboss). You need to supply the full OS path. One additional note, if you are running as user jboss you will only be able to save into directories owned by jboss (or made available to user jboss). If you are running a root, of course, you can save anywhere on the server.

Jboss 7 Jasper Test

There is the file, fromapp.pdf, saved to server in above screen shot.

 

Cool beans. Hoping to learn a lot more about this

Official Installation Guide