We discuss 2 methods of Glassfish/JavaEE bundle install on a headless system. The hints can also be applied to sole Glassfish installation with the Unix executables provided by Oracle, for example glassfish-3.1.2-unix.sh.
Java EE 6 SDK is a free integrated development kit used to build, test, and deploy Java EE 6 applications. It includes GlassFish Open Source Edition 3.1.2, Java EE 6 Code Samples, Java EE 6 API Documentation, Java EE 6 Tutorial and Your First Cup: An Introduction to the Java EE Platform.
Method 1: generate install template on a host with GUI and use it on your non-GUI VPS. Method 2: Install Xvnc server on your VPS and connect with VNC viewer to run the graphical installer. You can also generate template here for future use. We will combine both methods in this tutorial. We also presented a few common error messages that you may come across the procedure.
This example installation has been performed on a basic Centos 6.1 64bit VPS but will work on a dedicated box too. Start with creating a username that the install will run under.
[root@sdk ~]# adduser glassfish
[root@sdk ~]# passwd glassfish
Switch to glassfish
account and run the installer (already downloaded to /home/glassfish
in the example).
[root@sdk ~]# su - glassfish
[glassfish@testsdk ~]$ sh java_ee_sdk-6u4-jdk7-linux-x64.sh
Could not locate a suitable jar utility.
Please ensure that you have Java 6 or newer installed on your system
and accessible in your PATH or by setting JAVA_HOME
[root@sdk ~]# exit
We are missing jar, a part of JDK. There is no java install on this basic VPS so let's add one (already downloaded to /root
directory).
[root@sdk ~]# tar -C /opt -xzf jdk-7u4-linux-x64.tar.gz
ln -s /opt/jdk1.7.0_04 /opt/jdk
[root@sdk ~]# echo -e "export JAVA_HOME=/opt/jdk\nexport PATH=\$JAVA_HOME/bin:\$PATH" >> /home/glassfish/.bashrc
[root@sdk ~]# su - glassfish
[glassfish@sdk ~]# which java
/opt/jdk/bin/java
[glassfish@sdk ~]# java -version
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)
[glassfish@sdk ~]# sh java_ee_sdk-6u4-jdk7-linux-x64.sh
This program requires DISPLAY environment variable to be set.
Please re-run after assigning an appropriate value to DISPLAY.
[glassfish@sdk ~]# exit
We need to set DISPLAY to a working value but there is no GUI environment or Xserver so we will install lightweight Xvnc server with a few dependencies.
[root@sdk ~]# yum install tigervnc-server
In Centos 5 the package is vnc-server. Now we're adding the user to Xvnc coniguration, switch to glassfish and set VNC password for the user.
[root@sdk ~]# echo -e "VNCSERVERS=\"1:glassfish\"\nVNCSERVERARGS[1]=\"-geometry 800x600\"" >> /etc/sysconfig/vncservers
[root@sdk ~]# su - glassfish
[glassfish@sdk ~]# vncpasswd; exit
Finally we start Xvnc server. It will provide us with display 0 and screen as configured in /etc/sysconfig/vncservers
.
[root@testsdk ~]# /etc/init.d/vncserver start
Starting VNC server: 1:glassfish xauth: creating new authority file /home/glassfish/.Xauthority
New 'testsdk:1 (glassfish)' desktop is testsdk:1
Creating default startup script /home/glassfish/.vnc/xstartup
Starting applications specified in /home/glassfish/.vnc/xstartup
Log file is /home/glassfish/.vnc/testsdk:1.log [ OK ]
Now connect with linux command line vncviewer YOUR_VPS_IP:1
or Remote Desktop Viewer in Ubuntu or any VNC client software for your OS. A rather blank windows will open where install will soon run. We will first run fake install and save our choices as template.
[root@sdk ~]# su - glassfish
[glassfish@sdk ~]# export DISPLAY=0:1
[glassfish@sdk ~]$ sh java_ee_sdk-6u4-jdk7-linux-x64.sh -n template
Extracting the installer archive...
Extracting the installer runtime...
Extracting the installer resources...
Extracting the installer metadata...
Welcome to GlassFish installer
Using the user defined JAVA_HOME : /opt/jdk
Entering setup...
java.lang.UnsatisfiedLinkError: /opt/jdk1.7.0_04/jre/lib/amd64/xawt/libmawt.so: libXrender.so.1: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1939)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1864)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1825)
at java.lang.Runtime.load0(Runtime.java:792)
at java.lang.System.load(System.java:1059)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1939)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1864)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1846)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:67)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:47)
at java.security.AccessController.doPrivileged(Native Method)
at sun.java2d.Disposer.<clinit>(Disposer.java:59)
at javax.imageio.stream.FileCacheImageInputStream.<init>(FileCacheImageInputStream.java:110)
at com.sun.imageio.spi.InputStreamImageInputStreamSpi.createInputStreamInstance(InputStreamImageInputStreamSpi.java:69)
at javax.imageio.ImageIO.createImageInputStream(ImageIO.java:357)
at javax.imageio.ImageIO.read(ImageIO.java:1397)
at org.openinstaller.core.Orchestrator.main(Orchestrator.java:439)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.openinstaller.core.EngineBootstrap.main(EngineBootstrap.java:208)
SEVERE INTERNAL ERROR: /opt/jdk1.7.0_04/jre/lib/amd64/xawt/libmawt.so: libXrender.so.1: cannot open shared object file: No such file or directory
chmod: cannot access `./template': No such file or directory
We miss a library and need to install it. Then we successfully run the installer. Below are welcome and config screenshots.
[glassfish@sdk ~]# exit
[root@sdk ~]# yum install libXrender
[root@sdk ~]# su - glassfish
[glassfish@sdk ~]$ sh java_ee_sdk-6u4-jdk7-linux-x64.sh -n template
Extracting the installer archive...
Extracting the installer runtime...
Extracting the installer resources...
Extracting the installer metadata...
Welcome to GlassFish installer
Using the user defined JAVA_HOME : /opt/jdk
Entering setup...
SwixML 1.5 (#144)
/home/glassfish/glassfish3/glassfish/lib/registration/servicetag-registry.xml (No such file or directory)
WARNING: [/home/glassfish/glassfish3/glassfish/lib/registration/servicetag-registry.xml (No such file or directory)]*[{0} {1}]
You can see that the chosen destination directory /home/glassfish/glassfish3
is empty. This is how fake install works. Now you have template file in your home directory with the answers you gave during fake installation and a few more. You may now use this template to perform automatic (silent) installation on a system without GUI (Xvnc, Xserver etc.). Let's try the silent install on our testing VPS.
[glassfish@sdk ~]$ sh java_ee_sdk-6u4-jdk7-linux-x64.sh -a template -s
Extracting the installer archive...
Extracting the installer runtime...
Extracting the installer resources...
Extracting the installer metadata...
Welcome to GlassFish installer
Using the user defined JAVA_HOME : /opt/jdk
Entering setup...
File 511/511
File 303/303
File 564/564
File 317/317
SETTING UP DOMAIN FOR SILENT INSTALL...
Executing /home/glassfish/glassfish3/glassfish/bin/asadmin --user admin --passwordfile - create-domain --savelogin --checkports=false --adminport 4848 --instanceport 8080 --domainproperties=jms.port=7676:domain.jmxPort=8686:orb.listener.port=3700:http.ssl.port=8181:orb.ssl.port=3820:orb.mutualauth.port=3920 domain1
/home/glassfish/glassfish3/glassfish/bin/asadmin --user admin --passwordfile - create-domain --savelogin --checkports=false --adminport 4848 --instanceport 8080 --domainproperties=jms.port=7676:domain.jmxPort=8686:orb.listener.port=3700:http.ssl.port=8181:orb.ssl.port=3820:orb.mutualauth.port=3920 domain1 Using port 4848 for Admin.
Using port 8080 for HTTP Instance.
Using port 7676 for JMS.
Using port 3700 for IIOP.
Using port 8181 for HTTP_SSL.
Using port 3820 for IIOP_SSL.
Using port 3920 for IIOP_MUTUALAUTH.
Using 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=sdk,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US]
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=sdk-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.
Login information relevant to admin user name [admin]
for this domain [domain1] stored at
[/home/glassfish/.asadminpass] successfully.
Make sure that this file remains protected.
Information stored in this file will be used by
asadmin commands to manage this domain.
Command create-domain executed successfully.
We can now start the default domain domain1...
[glassfish@sdk ~]$ /home/glassfish/glassfish3/glassfish/bin/asadmin start-domain domain1
Waiting for domain1 to start .......
Successfully started the domain : domain1
domain Location: /home/glassfish/glassfish3/glassfish/domains/domain1
Log File: /home/glassfish/glassfish3/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
...and access our Glassfish main page at http://YOUR_VPS_IP:8080/
Note: To skip path when calling asadmin
in the future and to remove vncserver run:
[root@sdk ~]$ echo "export PATH=/home/glassfish/glassfish3/glassfish/bin:\$PATH" >> ~/.bashrc
[root@sdk ~]# /etc/init.d/vncserver stop
[root@sdk ~]# yum remove tightvnc-server
You may want to update Xmx parameter in /home/glassfish/glassfish3/glassfish/domains/domain1
to match your VPS memory and restart the domain. For example on a 2048MB VPS you may increase it to 1024 or more, on a small VPS (<= 512MB) you will need to decrease it to leave RAM for other processes like MySQL or mail server. Never forget swap space usage will drastically decrease perfomance of your application server.
If you are getting below when starting glassfish
There is a process already using the admin port 4848 -- it probably is another instance of a GlassFish server. Command start-domain failed.
and you are sure there is nothing running on port 4848 (check with netstat -tlnp
command) then make sure the hostname (run hostname -f
command to see it) is listed in the /etc/hosts
for 127.0.0.1/localhost.