Installing Java 6 And GlassFish 3.1 On FreeBSD 8.0

I’m in the process of creating a HA cluster based on FreeBSD, GEOM, HAST and ZFS. For our customers we need Java and GlassFish as well.

The servers are set up with FreeBSD 8.2.

Installing Oracle JDK 1.6

You need to download several files manually as licenses must be accepted:

Place all these files under /usr/ports/distfiles.

To install the jdk16 port, download some files from Oracle via command line:

#!bash
# cd /usr/ports/distfiles
# curl -v -L -o /usr/ports/distfiles/jdk-6u3-fcs-src-b05-jrl-24_sep_2007.jar http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-src-b05-jrl-24_sep_2007.jar
# curl -v -L -o /usr/ports/distfiles/jdk-6u3-fcs-bin-b05-jrl-24_sep_2007.jar http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-bin-b05-jrl-24_sep_2007.jar
# curl -v -L -o /usr/ports/distfiles/jdk-6u3-fcs-mozilla_headers-b05-unix-24_sep_2007.jar http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-mozilla_headers-b05-unix-24_sep_2007.jar

Attention: installing the port jdk16 will also automagically install diablo-jdk16.

Tweak the ports

As the port assumes an older version of the Timzeone Updater, edit the Makefiles in /usr/ports/java/jdk16 and /usr/ports/java/diablo-jdk16. In my case I could download the version 1.3.38_2011e from Oracle:

#!bash
TZUPDATE_VERSION=       1_3_38
TZUPDATE_TZVERSION=     2011e

Add the SHA256 hash for tzupdater-1_3_38-2011e.zip to the distinfo files:

#!bash
# cd /usr/ports/distfiles
# sha256 tzupdater-1_3_38-2011e.zip >> /usr/ports/java/jdk16/distinfo
# sha256 tzupdater-1_3_38-2011e.zip >> /usr/ports/java/diablo-jdk16/distinfo

Important: first cd into /usr/ports/disfiles and the issue sha256 as only the filename (without the path) must be present in distinfo.

Install the jdk16 port

#!bash
# cd /usr/ports/java/jdk16
# make install

Verify that Java was installed to /usr/local/jdk1.6.0:

#!bash
# which java
/usr/local/bin/java

Start Java with --version:

#!bash
# java -version
java version "1.6.0_03-p4"
Java(TM) SE Runtime Environment (build 1.6.0_03-p4-root_28_apr_2011_10_26-b00)
Java HotSpot(TM) Client VM (build 1.6.0_03-p4-root_28_apr_2011_10_26-b00, mixed mode)

Yeeha!

Installing GlassFish 3.1

Manually download the ZIP-version from Oracle GlassFish Downloads.

Unzip that distribution:

#!bash
# cd /opt
# unzip ogs-3.1.zip

Next create a GlassFish domain:

#!bash
# cd glassfish3
# bin/asadmin create-domain domain1

Watch the domain being created:

#!bash
Enter admin user name [Enter to accept default "admin" / no password]> 
Using port 4848 for Admin.
Using default port 8080 for HTTP Instance.
Using default port 7676 for JMS.
Using default port 3700 for IIOP.
Using default port 8181 for HTTP_SSL.
Using default port 3820 for IIOP_SSL.
Using default port 3920 for IIOP_MUTUALAUTH.
Using default port 8686 for JMX_ADMIN.
Using default port 6666 for OSGI_SHELL.
Using default port 9009 for JAVA_DEBUGGER.
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=skunk1,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US]
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=skunk1-instance,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US]
No domain initializers found, bypassing customization step
Domain domain1 created.
Domain domain1 admin port is 4848.
Domain domain1 allows admin login as user "admin" with no password.
Command create-domain executed successfully.

Also enable secure admin to use remote administration, i.e. with NetBeans:

#!bash
# cd glassfish3
# bin/asadmin enable-secure-admin
Command enable-secure-admin executed successfully.

Finally start your domain:

#!bash
# cd glassfish3
# bin/asadmin start-domain domain1

#!bash
Waiting for domain1 to start ...
Successfully started the domain : domain1
domain  Location: /root/glassfish3/glassfish/domains/domain1
Log File: /root/glassfish3/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

I could not use the web based administration console as after starting it up by pointing the browser to http://freebsd:4848 an ClassNotFoundException showed up in GlassFish’s log:

#!bash
# cd glassfish3
# less glassfish/domains/domain1/logs/server.log

[#|2011-04-28T11:14:02.467+0200|INFO|oracle-glassfish3.1|javax.enterprise.resource.webcontainer.jsf.config|_ThreadID=20;_ThreadName=Thread-1;|Unsanitized stacktrace from failed start...
com.sun.faces.config.ConfigurationException: 
  Source Document: jndi:/__asadmin/WEB-INF/faces-config.xml
  Cause: Unable to find class 'com.sun.webui.jsf.faces.UIComponentELResolver'

Googling around, this seems to be fixed by installing a newer version of Java 6. Maybe another port like openjdk6 will do the trick? Anyways, I can use GlassFish with NetBeans (Server tab) under FreeBSD now.

There’s also some documentation on GlassFish v2 and FreeBSD 8.0: http://freebie.miraclenet.co.th/server/fbsd_glassfish.html.

This entry was posted in System Administration and tagged , , , . Bookmark the permalink.