Thursday Jun 09, 2011

Running Java Web Start From a Zone

As indicated in my previous entry, I run my VPN software within a zone to connect to the Oracle intranet. Another component I need to access is the Solaris bug tracking system, which is launched via Java Web Start. To my disappointment, this also required a bit of troubleshooting. As my example here, I'll use one of my favorite Java Web Start applications, JDiskReport.

Assuming you left off with getting Firefox running from a zone, if you attempted to Web Start JDiskReport, the first problem is that Java Web Start isn't even installed on the system:

This is easy enough to fix:

root@myzone:~# pkg install java
               Packages to install:     5
           Create boot environment:    No
               Services to restart:     1
DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                                  5/5     779/779    34.4/34.4

PHASE                                        ACTIONS
Install Phase                              1179/1179 

PHASE                                          ITEMS
Package State Update Phase                       5/5 
Image State Update Phase                         2/2 

With Java installed, Firefox properly detects Java Web Start:

However, when you try to launch JDiskReport now, nothing happens at all. This is the most frustrating kind of error.

If you select the option to save the jdiskreport.jnlp file to your home directory and try to launch it from there, you'll see we're dumping core again:

bleonard@myzone:~$ javaws jdiskreport.jnlp 
Segmentation Fault (core dumped)

Unlike with Firefox however, we're not given anything else to work with. Using truss and digging into the stack trace, I was able to determine we also need the packages utf-8 and libxtst:

root@myzone:~# pkg install utf-8 libxtst
               Packages to install:     1
           Create boot environment:    No
DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                                  1/1   2674/2674    10.4/10.4

PHASE                                        ACTIONS
Install Phase                              2722/2722 

PHASE                                          ITEMS
Package State Update Phase                       1/1 
Image State Update Phase                         2/2 

Once these 2 packages are installed, you're in business with Java Web Start:

It's worth noting what a small footprint my zone has - less than 1 GB. Pretty cool, huh? Even more impressive is that it's actually only consuming 400 MB of space in my global zone because it's on a zfs dataset with compression turned on:

bleonard@solaris:~/Desktop$ zfs get all rpool/zones/myzone
NAME                PROPERTY                        VALUE                           SOURCE
rpool/zones/myzone  type                            filesystem                      -
rpool/zones/myzone  creation                        Wed Jun  8 11:31 2011           -
rpool/zones/myzone  used                            388M                           -
rpool/zones/myzone  available                       14.7G                           -
rpool/zones/myzone  referenced                      33K                             -
rpool/zones/myzone  compressratio                   1.89x  
...                         -

And while we're on the subject of resource consumption, look at zonestat:

bleonard@solaris:~$ zonestat 5 1
Collecting data for first interval...
Interval: 1, Duration: 0:00:05
SUMMARY                    Cpus/Online: 1/1   Physical: 1535M    Virtual: 2512M
                    ----------CPU---------- ----PHYSICAL----- -----VIRTUAL-----
               ZONE  USED %PART  %CAP %SHRU  USED   PCT  %CAP  USED   PCT  %CAP
            [total]  0.31 31.8%     -     - 1141M 74.3%     - 1369M 54.5%     -
           [system]  0.12 12.7%     -     -  302M 19.6%     -  643M 25.6%     -
             global  0.15 15.5%     -     -  604M 39.3%     -  529M 21.0%     -
             myzone  0.03 3.57%     -     -  234M 15.2%     -  196M 7.81%     -

Only 234M of RAM. Like I said in the previous post, you can't achieve numbers like that with a VirtualBox VM.

Wednesday Jul 29, 2009


If you're planning to use OpenSolaris as an RMI server, this little tip could save you some time. As a simple test I was following the Getting Started Using Java RMI tutorial. However, when I attempted to connect to the OpenSolaris server from the client, I was getting the following exception:

Client exception: java.rmi.ConnectException: Connection refused to host:; nested exception is: Connection refused: connect

Why was RMI trying to connect to I wasn't even using a hostname, I was directly connecting with my server's IP address ( After doing a bit of debugging, it turns out I was successfully connecting to the RMI registy and getting the stub, however, the IP address placed in the remote stub was What's up with that?

After a bit more research it turns out the RMI registry is using InetAddress.getLocalHost() to determine the IP address to put in the stub. This simple program shows what is returned by that method call:


public class Main {
    public static void main(String[] args) throws Exception {
        System.out.println("getLocatHost: " + InetAddress.getLocalHost());

And Here's the output:

getLocatHost: opensolaris/ 

Looking at the source code for InetAddress.getLocalHost(), a private method getAddressFromNameService() is called. The /etc/nsswitch.conf file is used by OpenSolaris for configuring the address name service. Looking at my setting for hosts:

hosts: files dns # Added by DHCP

So the name service's first place to look is files, and the file that is being looked at is /etc/hosts, which contains the following for my hostname 'opensolaris':	opensolaris opensolaris.local localhost loghost

So one solution to this problem is to add my IP address to the /etc/hosts file as follows:	opensolaris opensolaris.local localhost loghost	opensolaris

Now running my test class above returns:

getLocatHost: opensolaris/

Which will also allow my RMI client to successfully connect.

If you don't want to mess with your /etc/hosts file, another option is to tell the RMI server which hostname to use by using the java.rmi.server.hostname JVM property. My complete command to start the server now looks as follows (note, I'm running the script from my build directory):

java -classpath `pwd` -Djava.rmi.server.codebase=file:`pwd`/ -Djava.rmi.server.hostname= example.hello.Server

Overall, it's upsetting that the RMI Server isn't initially getting the proper IP address, but at least now I understand why.

Monday Jul 21, 2008

Java Web Start

I went to start a Java Web Start application today and was disappointed that it didn't work. The default operation is to open the jnlp file in Firefox, which only causes the dialog to appear again.

I recalled seeing a comment on Gregg's Getting Java blog from Simon Phipps who was having the same problem. The solution is to select "Other..." from the Open with drop down and then browse to /usr/bin/javaws. Also select "Do this automatically for files like this from now on.":

This is already tracked as a defect: Firefox needs a default MIME association for Java Web Start (JNLP).

Monday Jun 30, 2008

JVM Process Status (jps)

I frequently use jps to list my Java processes and was a bit dismayed when it didn't work on OpenSolaris. For some reason the Solaris installer doesn't create a link to the process. This fix is easy enough, from the command line enter:

pfexec ln -s /usr/java/bin/jps /usr/bin/jps

Now jps works like a charm:

bleonard@opensolaris:~$ jps -l
2100 org.jruby.Main
2078 org.netbeans.Main
1607 com.sun.javaws.Main

Wednesday Jun 25, 2008

Installing NetBeans 6.1

Last week I wrote an entry over on on how to install NetBeans 6.1. The first step in that entry was an overcomplicated series of steps to install the JDK. I swear I first looked in the Package Manager, and was surprised to not find the JDK, but I must have just searched on "Java". Sure enough, as Gregg points out in Getting Java, searching on "JDK" does show all of the packages needed.

Update: NetBeans 6.1 is now in the IPS repository. Here are the new installation instructions.

Getting Java

OpenSolaris 2008.05 includes the Java Runtime Environment, but not the full Java Development Kit (JDK).  It is easy enough to install it, however, from the repository.  The key is to use the correct search term.

[Read More]

The Observatory is a blog for users of Oracle Solaris. Tune in here for tips, tricks and more as we explore the Solaris operating system from Oracle.


« July 2016