Skip to main content

Running osgi shell commands with asadmin in Glassfish

Posted by bhaktimehta on November 20, 2012 at 12:24 PM PST

GlassFish comes preconfigured with Apache Felix Gogo, which is an implementation of OSGi RFC 147, and is a proposed standard shell for OSGi environments.

For Glassfish 4.0 there is no longer need to open a separate port to access the shell. The OSGi shell commands are integrated with asadmin, so you can now access the OSGi shell
commands via asadmin tool.

There is a remote command called osgi which accepts subcommands which are fed to the OSGi shell and their result returned via asadmin.

This integration allows you to secure the OSGi commands using GlassFish admin credentials as well.
If you have turned on “secure admin” feature in GlassFish, then you can even access the shell via asadmin osgi command from remote hosts.

To try this feature download the latest glassfish bits from here

asadmin osgi subcommand
You can use the subcommand you would have used after telnetting to osgi shell here

%asadmin osgi lb -l  
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (4.0.2)
    1|Active     |    1|javax.annotation API v.1.1 (4.0.0.SNAPSHOT)
    2|Active     |    1|jaxb-api (2.2.7)
    3|Active     |    1|Metro Web Services API OSGi Bundle (2.3.0.b100)
    4|Active     |    1|OSGi resource locator bundle - used by various API providers that rely on META-INF/services mechanism to locate providers. (1.0.1)
    5|Installed  |    1|ACC Config Classes (JAXB) (4.0.0.SNAPSHOT)
    6|Active     |    1|admin-cli (4.0.0.SNAPSHOT)
    7|Installed  |    1|admin-core (4.0.0.SNAPSHOT)
    8|Active     |    1|admin-util (4.0.0.SNAPSHOT)
    9|Installed  |    1|AMX V3 Core (4.0.0.SNAPSHOT)
   10|Installed  |    1|AMX V3 Java EE Management (JSR 77) API and Implementation (4.0.0.SNAPSHOT)
   11|Resolved   |    1|GlassFish Java EE Annotation Framework (4.0.0.SNAPSHOT)
   12|Resolved   |    1|Ant repackaging (4.0.0.SNAPSHOT)
Related Topics >>


Thanks for taking time to write this up. Very nice.

Thanks for taking time to write this up. Very nice.