Moving On Up: Upgrading to GlassFish 3.1

GlassFish 3.1 is here, and once you're done playing around with it, it might be time to do some work. If you already have an earlier GlassFish installation working for you, this blog will walk you through the steps to upgrade it to GlassFish 3.1. Specifically, I'm going to upgrade a v2.1.1 installation with a two-instance cluster.

If you're upgrading from a v2 developer profile or a 3.0.1 installation, then the upgrade process is mostly the same. You're just done after the upgrade tool exits, since you won't have cluster instances to recreate. If you're upgrading from a v2 enterprise edition installation, then please see the Upgrade Guide for more information. The upgrade process is the same, but there are some manual steps you will need to perform because GlassFish 3.1 does not support NSS.

All of the steps in this example are included in this video, and I'll describe them below:

Step 1: Upgrade the DAS

First, make sure the DAS, node agent, and instances are all stopped. If you have any 3rd-party libraries installed in glassfish/lib (not domainX/lib), you'll need to copy those over to the 3.1 installation. Then you can use the upgrade tool located in the bin directory: bin/asadmin/asupgrade. While you don't need to give it any options, the following are the most useful (use --help for the full list):

  • -c or --console This will start the tool in console mode instead of GUI mode.
  • -s or --source This will specify the source domain to be upgraded.
  • -t or --target This will specify the target domains directory into which the source domain will be copied. This is only really needed when using the console mode. In the GUI mode, it is filled in for you.

When we say "upgrading the DAS," what you're really doing is upgrading the domain that is running in the DAS. This process hasn't really changed since GlassFish v3. Later, this information will be synchronized with the cluster instances. What the upgrade tool does for you is copy the old domain to the 3.1 server, and then it runs asadmin start-domain --upgrade <domain_name> to upgrade the configuration in the domain. Just like with GlassFish v3, the server itself performs the upgrade duties.

Step 2: Recreate the Cluster Instances

Because the cluster information is stored in domain.xml, we don't have to do any other steps to create the 3.1 cluster. However, we need to recreate the instances. I'm using the asadmin create-local-instance command to create my instances. See Jennifer's blog for more information on the command.

In the video, I specify the --node and --cluster options when creating the instances. These values, along with the instance name, match the node agent, cluster name, and instance names that were used in the v2 cluster. When the cluster is started, all of the configuration and application data in the DAS will be synchronized with the instances. The original instances do not store any per-instance data (with one exception below), so there is no separate "upgrade instances" step.

The one extra step you need before starting up the cluster is to copy the IMQ directories from the old instances to the newly-created ones. This persistent JMS information is not part of the domain configuration, and you don't want to lose it during the upgrade process. For instance, copy the directory:




Then you're ready to start everything up with asadmin start-cluster <cluster_name> and the upgrade of your cluster is complete. Please see the upgrade guide linked above for full information. Happy upgrading!


I found that I had to delete the osgi-chace directory (<path_to_gf_root>/glassfish/domains/domain1/osgi-cache) before I was able to evoke the "asadmin start-domain --upgrade domain1" command.

Posted by mpirretti on March 09, 2011 at 12:38 AM EST #

It's not supposed to work that way. See this for more information:

Can you send email to the email list and tell us what version you're upgrading from, along with the error message you're seeing? Note that the above bug fix applies to GlassFish 3.1. If you're trying to upgrade from, for instance, v3 to 3.0.1, then you may have to remove the osgi cache.

I just tried this with a 3.0.1 installation: used update center, then 'asadmin start-domain --upgrade', then started up normally, and it all worked for me.

Posted by Bobby Bissett on March 09, 2011 at 03:40 AM EST #

Note: I just realized that I had the wrong URL for the upgrade guide in the blog. I've updated it to point to the correct location:

Posted by Bobby Bissett on March 09, 2011 at 03:52 AM EST #

Unfortunately, I didn't save the error. I'll see if I can recreate on another instance of GF later today. For what it is worth, I was upgrading from 3.0.1 to 3.1. If I can re-create the error I'll post to the email list.

Posted by mpirretti on March 09, 2011 at 05:05 AM EST #

Ok, I've figured out how to recreate the problem. My operating environment is a developer machine (running on x86 Windows XP).

1) Run the updatetool command and have it update the server instance to the 3.1 packages.
2) Next I attempted to have Netbeans build, deploy, and run a maven-based war archive. (I admit this is a bit of user error in that I should have run "asadmin start-domain --upgrade domain1" first). At this point the server cannot start and provides a lengthy stacktrace.
3) Then I attempted to run "asadmin start-domain --upgrade domain1" and at this point it fails with the following error:
UTIL6046: Attempt to rename C:\\glassfishv3_del\\glassfish\\domains\\domain1\\osgi-cache to C:\\glassfishv3_del\\glassfish\\domains\\domain1\\osgi-cache-1299778187466 failed after 6 retries
Failed to rename OSGi persistence store from C:\\glassfishv3_del\\glassfish\\domains\\domain1\\osgi-cache to C:\\glassfishv3_del\\glassfish\\domains\\domain1\\osgi-cache-1299778187466
Command start-domain failed.

To remedy the issue I deleted the osgi-cache and re-ran the"asadmin start-domain --upgrade domain1" command and was good to go. Perhaps some of the server state gets messed up by the server not being able to fully start up.

Posted by mpirretti on March 10, 2011 at 04:43 AM EST #

I think I've reproduced your issue. I'm not sure how NetBeans starts GlassFish, but it ideally should give you a message saying that the domain needs to be upgraded and let you do that. I've sent email to the team about it. You can follow along here:

Thanks for letting me know about the problem.

Posted by Bobby Bissett on March 10, 2011 at 05:59 AM EST #

Glad to be able to help.

I'm not certain how NetBeans starts Glassfish either. That's always the downside of using an IDE - the lack of transparency.

Posted by mpirretti on March 11, 2011 at 02:45 AM EST #

Post a Comment:
Comments are closed for this entry.

Whatever part of GlassFish or the Java EE world that catches my attention. (Also, go Red Sox.)


« July 2016