Patching glassfish

Some time ago we finally moved one of our critical java apps from being hosted on Borland Enterprise Server (BES or BAS as it's known) for which we seemed to be practically the only customer in Europe. We decided to migrate to oracle glassfish (not 100% sure of the reasoning behind that) but about 5 seconds after that decision is seems oracle decided to discontinue support going forward - brilliant......

Anyway we're stuck with it for now so we'd better patch it up to the latest version of 3 (4 is out but only as an opensource community project) as this is the best we can do with support from Oracle.

We were on the base version you get from so we wanted to being that up to the latest path version possible (so from to to be exact).

Now finding out this is what we wanted to patch was something of a minefield - the version numbering scheme seems all over the place and is very confusing - but we eventually found out what we needed from the oracle support site.

The next problem we had is that out linux servers are not connected to the evil internet so we had to upgrade them following the document that deals with patching in a 'closed network'.

Here is a summary of what that entailed:

Step 1
download the latest version of the pkg toolkit (this is the tool used to do the actual patching) for your platform. In my case this file

i then did the following

cd /glassfish
mkdir repo
cp /glassfish/repo
cd repo

Step 2
download the latest glassfish files and make them available as a patch repository so other servers can patch from it. In my case

i then did the following

cd /glassfish
mkdir patch
cd patch
cp /glassfish/patch
cd 147904-14

Right - quick summary so far - the first step was just to get the latest version of the pkg tool used for updates, the second step was to download and unzip the latest version of the glassfish files.

Now i need to use bits from step 1 and step 2 to actually do the update.

Step 3
Now we make the software available as a resource that pkg can connect to and use to update - we are essentially setting up the same service that would normally be connected to over the internet

to start this up we do the following

cd /glassfish/repo/pkg-toolkit-linux-i386/pkg/bin
./pkg.depotd -d /glassfish/patch/147904-14/linux-i386 -p 30000
[16/Feb/2015:09:39:04] INDEX Search Available
[16/Feb/2015:09:39:04] ENGINE Listening for SIGHUP.
[16/Feb/2015:09:39:04] ENGINE Listening for SIGTERM.
[16/Feb/2015:09:39:04] ENGINE Listening for SIGUSR1.
[16/Feb/2015:09:39:04] ENGINE Bus STARTING
[16/Feb/2015:09:39:04] ENGINE Started monitor thread '_TimeoutMonitor'.
[16/Feb/2015:09:39:05] ENGINE Serving on
[16/Feb/2015:09:39:05] ENGINE Bus STARTED

This advertises the software from the /glassfish/patch/147904-14/linux-i386 directory over port 30000 using the pkg.depotd program that comes as a utility with the software we got in step 1

Now when we come to patch we can point at this location

Step 4
Now we stop glassfish and tell it the location of the patch repo then do the patch

asadmin stop-domain

/glassfish/repo/pkg-toolkit-linux-i386/pkg/bin/pkg -R/glassfish/glassfish set-publisher -P --enable -O http://localhost:30000

That long second command is associating the new repo with the installed software giving this as a location for patching

Now we have to be in the /glassfish/glassfish (or your equivalent install location) for the next steps

To check the new location is available to patch from we run

/glassfish/repo/pkg-toolkit-linux-i386/pkg/bin/pkg publisher
PUBLISHER                             TYPE     STATUS   URI (preferred)  origin   online   http://localhost:30000/              origin   online                 origin   online

So looking good - now all we need to do is patch....

And this is where it got messy - i'm not going to go all over the trial and error i had to make this work - suffice to say there is an issue patching from the base version - there are some explicit steps you have to do first - so i'll just list those and pretend all went well from the start.....

-- first we deinstall a component
 /glassfish/repo/pkg-toolkit-linux-i386/pkg/bin/pkg uninstall glassfish-enterprise-web-profile
PHASE                                        ACTIONS
Removal Phase                                  19/19
PHASE                                          ITEMS
Reading Existing Index                           8/8
Indexing Packages                                1/1
Optimizing Index...
PHASE                                          ITEMS
Indexing Packages                              63/63

-- then another component
/glassfish/repo/pkg-toolkit-linux-i386/pkg/bin/pkg uninstall oracle-glassfish-web-incorporation
PHASE                                        ACTIONS
Removal Phase                                  18/18
PHASE                                          ITEMS
Reading Existing Index                           8/8
Indexing Packages                                1/1
Optimizing Index...
PHASE                                          ITEMS
Indexing Packages                              62/62

-- now we can patch everything
 /glassfish/repo/pkg-toolkit-linux-i386/pkg/bin/pkg image-update
DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                                26/26     127/127    12.3/12.3

PHASE                                        ACTIONS
Removal Phase                                  11/11
Install Phase                                  14/14
Update Phase                                 156/156
PHASE                                          ITEMS
Reading Existing Index                           8/8
Indexing Packages                              26/26
Optimizing Index...
PHASE                                          ITEMS
Indexing Packages                              62/62

Now everything is patched OK....

Now we start everything back up
At which point i got this

INFO: Updated bundle 253 from /glassfish/glassfish/glassfish/modules/glassfish-corba-omgapi.jar
Feb 16, 2015 11:45:48 AM OSGiFrameworkLauncher launchOSGiFrameWork
INFO: Updating system bundle
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(
        at com.sun.enterprise.glassfish.bootstrap.ASMain.main(
Caused by: org.glassfish.embeddable.GlassFishException: java.lang.IllegalStateException: Invalid BundleContext.
        at org.glassfish.embeddable.GlassFishRuntime._bootstrap(
        at org.glassfish.embeddable.GlassFishRuntime.bootstrap(
        at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(
        ... 6 more
Caused by: java.lang.IllegalStateException: Invalid BundleContext.
        at org.apache.felix.framework.BundleContextImpl.checkValidity(
        at org.apache.felix.framework.BundleContextImpl.getBundle(
        at com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner.getBundle(
        at com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner.startBundles(
        ... 9 more
Error stopping framework: java.lang.NullPointerException
        at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher$

aargh - so i try again

And second time round it works fine.....

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

bizarre - anyway - it looks all good now - we'll move on to UAT next and hopefully should be more straightforward.

Patching over the internet might be easier - but i think you still get the issues i hit if it's the first time you are patching. An x-windows gui is also available but i ignored that and stuck with the command line.


Post a Comment