Thursday Aug 04, 2011

Quick tip Felix shell and Glassfish

Here is a quick tip from Tom Mueller on how to inspect dependencies for jars using the felix gogo shell in Glassfish. Documenting for quick reference in future.

Install glassfish v3.x ( I have tried this with the 3.2 trunk)

telnet localhost 6666


lb -l | grep dol.jar (say I am looking for depencies for dol.jar which is  a resolved osgi module)
inspect p c 106

(where 106 is the bundle number for dol.jar from the previous command.)

More information is also available here

Wednesday Apr 20, 2011

Classloader.getResources() and IBM JDK

Kinman Chung and I  had a nice debugging session discovering an interesting difference in the classloading behavioural differences on Sun/Oracle vs IBM J2SE. Writing a small summary of our findings incase this may help someone in the future.

We are working on GlassFish Server Open Source Edition 3.1.1, a minor update release to the just released 3.1 version . One of the key features of 3.1.1 is improved Platform Support for AIX .

When debugging issues we ran into an error as shown below

javax.validation.ValidationException: Unable to find a default provider
at javax.validation.Validation$GenericBootstrapImpl.configure(

So we got the bean validation sources to see what was going wrong.

We noticed a difference with respect  to the bean validation   In Source code for there is a line 317 which looks for the META-INF/services/javax.validation.spi.ValidationProvider

Enumeration<URL> providerDefinitions = classloader.getResources( SERVICES_FILE )

The above line has no elements on IBM JDK but was returning proper values on Sun/Oracle JDK

Kinman and I were debugging this with respect to IBM vs Sun/Oracle classloader and to give you some info this is what IBM J2SE ClassLoader.getResources() does

ClassLoader up = this;
do {
       Enumeration e = up.findResources(resName);
       if (e != null && e.hasMoreElements()) resources.addElement(e);
       if (up == systemClassLoader) break;
       up = up.parent;
       if (up == null) up = systemClassLoader;
   } while (true);

So in IBM jdk the getResources goes up the classloader chain and looks for the findResources()

This is what is done in Sun/Oracle JDK

Enumeration[] tmp = new Enumeration[2];
   if (parent != null) {
       tmp[0] = parent.getResources(name);
   } else {
       tmp[0] = getBootstrapResources(name);
   tmp[1] = findResources(name);

The problem was this class org.jvnet.hk2.osgiadapter.OSGIModuleImpl whose Classloader has a getResources but not findResources overriden. 

This worked  for the non IBM JDK case.

The fix was to add a findResources implementation in our classloader which Sahoo fixed by adding  a findResources implementation in core/kernel/src/main/java/com/sun/enterprise/v3/server/

Also this means in future every classloader should have findResources implementation to work with  IBM JDK.

Monday Feb 28, 2011

change-master-password command in Glassfish 3.1

 Glassfish 3.1 has released!! You can find more information at this link.

Today we will cover one of the commands of 3.1 change-master-password and some changes we made with respect to 2.1.

The master password is the password that is used to encrypt the DAS (and instances) keystore. Therefore the DAS and associated server instances need the password to open the keystore at startup.The master password is the same for the DAS and all instances in the domain. The default master password is "changeit". The master password can be saved in a master-password file:

This is the location of the master-password file

  1. DAS: domains/domainname/master-password
  2. Instance: nodes/node-name/agent/master-password

A master password can be set during domain or instance creation by entering it interactively. It is saved to the master-password file if the --savemasterpassword option is used. This is supported by:

  1. create-domain
  2. create-local-instance

A master password is provided during domain or instance startup via the master-password file or by entering it interactively. This is supported by:

  1. start-domain
  2. start-local-instance

The change-master-password command is a local command which is used to change the master-password .The master-password may be changed on the DAS by running change-master-password. The DAS must be down to run this command. change-master-password supports the --savemasterpassword option so that the master password can be saved in a master-password file. The same command can be used to change the master-password file on an instance

Options for change-master-password


This option indicates whether the master password should be written to the file system. This is necessary so that start-domain and start-local-instance can start the server without having to prompt the user for password.Defaults to false

NOTE: if savemasterpassword is not set, the master password file, if it exists, will be deleted.


           This option is used when changing the master password for a node. You can specify a nodedir which is your <gf>/nodes. If the option is omitted, then it defaults to <installdir>/glassfish/nodes. Omitting it doesn't cause the change to be applied to the whole domain


          This option is used when changing the master password for the DAS. Typically this is <gf>/domains. It is an error to specify both domaindir and nodedir together.



This is the domain name whose password is to be changed.


This is the name of the node agent whose password is to be changed.

For the first instance created on a node, you can't start it until the master password is set
and saved to the file.

From that point on you should be able to create new instances and start
existing instances on the node.

Please refer to the following screencast for more information .




Top Tags
« July 2016