Skip to main content

TOTD #36: Deploy OSGi bundles in GlassFish using maven-bundle-plugin

Posted by arungupta on June 26, 2008 at 6:15 AM PDT



GlassFish v3
is a modular (OSGi
compliant), embeddable (runs in-VM) and extensible (supports non-Java
apps) Application Server.



The extensible part is href="http://blogs.sun.com/arungupta/entry/tic_tac_toe_using_rails">demonstrated
by deployment of Rails and Grails applications. An example of
embeddability is an href="http://blogs.sun.com/arungupta/entry/embeddable_glassfish_in_action_servlet">in-VM
Servlet. This blog demonstrates how a simple OSGi bundle
can be easily created using href="http://felix.apache.org/site/maven-bundle-plugin-bnd.html">Maven
Bundle Plugin and deployed on v3 trunk.

  1. Generate a simple Maven project using the command as shown
    below:


    cellpadding="2" cellspacing="2">
    style="font-family: monospace;">~/samples/v3 > style="font-weight: bold; font-family: monospace;">mvn
    archetype:create -DarchetypeGroupId=org.apache.maven.archetypes
    -DgroupId=org.glassfish.samples.osgi.helloworld -DartifactId=helloworld style="font-family: monospace;">
    [INFO]
    Scanning for projects...
    style="font-family: monospace;">
    [INFO]
    Searching repository for plugin with prefix: 'archetype'.
    style="font-family: monospace;">
    [INFO]
    Ignoring available plugin update: 2.0-alpha-3 as it requires Maven
    version 2.0.7


    [INFO]
    Ignoring available plugin update: 2.0-alpha-2 as it requires Maven
    version 2.0.7


    [INFO]
    Ignoring available plugin update: 2.0-alpha-1 as it requires Maven
    version 2.0.7


    [INFO]
    ----------------------------------------------------------------------------
    style="font-family: monospace;">
    [INFO]
    Building Maven Default Project
    style="font-family: monospace;">
    [INFO]   
    task-segment: [archetype:create] (aggregator-style)
    style="font-family: monospace;">
    [INFO]
    ----------------------------------------------------------------------------
    style="font-family: monospace;">
    [INFO]
    Setting property: classpath.resource.loader.class =>
    'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
    style="font-family: monospace;">
    [INFO]
    Setting property: velocimacro.messages.on => 'false'.
    style="font-family: monospace;">
    [INFO]
    Setting property: resource.loader => 'classpath'.
    style="font-family: monospace;">
    [INFO]
    Setting property: resource.manager.logwhenfound => 'false'.
    style="font-family: monospace;">
    [INFO]
    **************************************************************
    style="font-family: monospace;">
    [INFO]
    Starting Jakarta Velocity v1.4
    style="font-family: monospace;">
    [INFO]
    RuntimeInstance initializing.
    style="font-family: monospace;">
    [INFO]
    Default Properties File:
    org/apache/velocity/runtime/defaults/velocity.properties
    style="font-family: monospace;">
    [INFO]
    Default ResourceManager initializing. (class
    org.apache.velocity.runtime.resource.ResourceManagerImpl)
    style="font-family: monospace;">
    [INFO]
    Resource Loader Instantiated:
    org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader
    style="font-family: monospace;">
    [INFO]
    ClasspathResourceLoader : initialization starting.
    style="font-family: monospace;">
    [INFO]
    ClasspathResourceLoader : initialization complete.
    style="font-family: monospace;">
    [INFO]
    ResourceCache : initialized. (class
    org.apache.velocity.runtime.resource.ResourceCacheImpl)
    style="font-family: monospace;">
    [INFO]
    Default ResourceManager initialization complete.
    style="font-family: monospace;">
    [INFO]
    Loaded System Directive: org.apache.velocity.runtime.directive.Literal
    style="font-family: monospace;">
    [INFO]
    Loaded System Directive: org.apache.velocity.runtime.directive.Macro
    style="font-family: monospace;">
    [INFO]
    Loaded System Directive: org.apache.velocity.runtime.directive.Parse
    style="font-family: monospace;">
    [INFO]
    Loaded System Directive: org.apache.velocity.runtime.directive.Include
    style="font-family: monospace;">
    [INFO]
    Loaded System Directive: org.apache.velocity.runtime.directive.Foreach
    style="font-family: monospace;">
    [INFO]
    Created: 20 parsers.


    [INFO]
    Velocimacro : initialization starting.
    style="font-family: monospace;">
    [INFO]
    Velocimacro : adding VMs from VM library template : VM_global_library.vm
    style="font-family: monospace;">
    [ERROR]
    ResourceManager : unable to find resource 'VM_global_library.vm' in any
    resource loader.


    [INFO]
    Velocimacro : error using  VM library template
    VM_global_library.vm :
    org.apache.velocity.exception.ResourceNotFoundException: Unable to find
    resource 'VM_global_library.vm'
    style="font-family: monospace;">
    [INFO]
    Velocimacro :  VM library template macro registration complete.
    style="font-family: monospace;">
    [INFO]
    Velocimacro : allowInline = true : VMs can be defined inline in
    templates


    [INFO]
    Velocimacro : allowInlineToOverride = false : VMs defined inline may
    NOT replace previous VM definitions
    style="font-family: monospace;">
    [INFO]
    Velocimacro : allowInlineLocal = false : VMs defined inline will
    be  global in scope if allowed.
    style="font-family: monospace;">
    [INFO]
    Velocimacro : initialization complete.
    style="font-family: monospace;">
    [INFO]
    Velocity successfully started.
    style="font-family: monospace;">
    [INFO]
    [archetype:create]


    [INFO]
    Defaulting package to group ID: org.glassfish.samples.osgi.helloworld
    style="font-family: monospace;">
    [INFO]
    ----------------------------------------------------------------------------
    style="font-family: monospace;">
    [INFO]
    Using following parameters for creating Archetype:
    maven-archetype-quickstart:RELEASE
    style="font-family: monospace;">
    [INFO]
    ----------------------------------------------------------------------------
    style="font-family: monospace;">
    [INFO]
    Parameter: groupId, Value: org.glassfish.samples.osgi.helloworld
    style="font-family: monospace;">
    [INFO]
    Parameter: packageName, Value: org.glassfish.samples.osgi.helloworld
    style="font-family: monospace;">
    [INFO]
    Parameter: basedir, Value: /Users/arungupta/samples/v3
    style="font-family: monospace;">
    [INFO]
    Parameter: package, Value: org.glassfish.samples.osgi.helloworld
    style="font-family: monospace;">
    [INFO]
    Parameter: version, Value: 1.0-SNAPSHOT
    style="font-family: monospace;">
    [INFO]
    Parameter: artifactId, Value: helloworld
    style="font-family: monospace;">
    [INFO]
    ********************* End of debug info from resources from generated
    POM ***********************
    style="font-family: monospace;">
    [INFO]
    Archetype created in dir: /Users/arungupta/samples/v3/helloworld
    style="font-family: monospace;">
    [INFO]
    ------------------------------------------------------------------------
    style="font-family: monospace;">
    [INFO]
    BUILD SUCCESSFUL


    [INFO]
    ------------------------------------------------------------------------
    style="font-family: monospace;">
    [INFO]
    Total time: 1 second


    [INFO]
    Finished at: Wed Jun 25 10:07:27 PDT 2008
    style="font-family: monospace;">
    [INFO]
    Final Memory: 5M/10M


    [INFO]
    ------------------------------------------------------------------------
  2. Change the generated App class in
    "src/main/java/org/glassfish/samples/osgi/helloworld" folder so that it
    looks like:


    cellpadding="2" cellspacing="2">
    style="font-family: monospace;">package
    org.glassfish.samples.osgi.helloworld;



    import
    org.osgi.framework.BundleActivator;
    style="font-weight: bold;">
    import
    org.osgi.framework.BundleContext;
    style="font-weight: bold;">


    /**

     * Hello world!

     *

     */

    public class App implements
    BundleActivator
    {

       
    public void start(BundleContext context) throws Exception {
    style="font-weight: bold;">
           
    System.out.println("Hey!");
    style="font-weight: bold;">
       
    }


       
    public void stop(BundleContext context) throws Exception {
    style="font-weight: bold;">
           
    System.out.println("Bye!");
    style="font-weight: bold;">
       
    }


    } style="font-weight: bold; font-family: monospace;">




    This is a trivial Activator class but sitll shows the key methods. The
    changes are highlighted in bold.

  3. Update "pom.xml" with the following changes:
    1. Change the <packaging> to "bundle" from the
      default value of "jar".
    2. Add the <dependency> on "org.osgi.core".
    3. Add the <plugin> maven-bundle-plugin and
      provide <instructions> to generate the appropriate
      MANIFEST.MF.



    The updated "pom.xml" with changes highlighted in style="font-weight: bold;">bold are shown below:


    cellpadding="2" cellspacing="2">
    style="font-family: monospace;"><project
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" style="font-family: monospace;">
     
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/maven-v4_0_0.xsd">
    style="font-family: monospace;">
     
    <modelVersion>4.0.0</modelVersion>
    style="font-family: monospace;">
     
    <groupId>org.glassfish.samples.osgi.helloworld</groupId>
    style="font-family: monospace;">
     
    <artifactId>helloworld</artifactId>
    style="font-family: monospace;">
     
    <packaging>
    style="background-color: rgb(204, 204, 255); font-weight: bold; font-family: monospace;">bundle style="font-family: monospace;"></packaging> style="font-family: monospace;">
     
    <version>1.0-SNAPSHOT</version>
    style="font-family: monospace;">
     
    <name>helloworld</name>
    style="font-family: monospace;">
     
    <url>http://maven.apache.org</url>
    style="font-family: monospace;">
     
    <dependencies>
    style="font-family: monospace;">
       
    <dependency>
    style="font-family: monospace;">
         
    <groupId>junit</groupId>
    style="font-family: monospace;">
         
    <artifactId>junit</artifactId>
    style="font-family: monospace;">
         
    <version>3.8.1</version>
    style="font-family: monospace;">
         
    <scope>test</scope>
    style="font-family: monospace;">
       
    </dependency>
    style="font-family: monospace;">
       
    style="background-color: rgb(204, 204, 255); font-weight: bold; font-family: monospace;"><dependency> style="background-color: rgb(204, 204, 255); font-weight: bold; font-family: monospace;">
    style="background-color: rgb(204, 204, 255); font-weight: bold; font-family: monospace;">     
    <groupId>org.apache.felix</groupId> style="background-color: rgb(204, 204, 255); font-weight: bold; font-family: monospace;">
    style="background-color: rgb(204, 204, 255); font-weight: bold; font-family: monospace;">     
    <artifactId>org.osgi.core</artifactId> style="background-color: rgb(204, 204, 255); font-weight: bold; font-family: monospace;">
    style="background-color: rgb(204, 204, 255); font-weight: bold; font-family: monospace;">     
    <version>1.0.0</version> style="background-color: rgb(204, 204, 255); font-weight: bold; font-family: monospace;">
    style="background-color: rgb(204, 204, 255); font-weight: bold; font-family: monospace;">   
    </dependency> style="font-family: monospace;">
     
    </dependencies>
    style="font-family: monospace;">
      style="font-weight: bold; font-family: monospace;"><build> style="font-weight: bold; font-family: monospace;">
       
    <plugins>
    style="font-weight: bold; font-family: monospace;">
         
    <plugin>
    style="font-weight: bold; font-family: monospace;">
           
    <groupId>org.apache.felix</groupId>
    style="font-weight: bold; font-family: monospace;">
           
    <artifactId>maven-bundle-plugin</artifactId>
    style="font-weight: bold; font-family: monospace;">
           
    <extensions>true</extensions>
    style="font-weight: bold; font-family: monospace;">
           
    <configuration>
    style="font-weight: bold; font-family: monospace;">
             
    <instructions>
    style="font-weight: bold; font-family: monospace;">
               
    <Export-Package>${pom.groupId}</Export-Package>
    style="font-weight: bold; font-family: monospace;">
               
    <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
    style="font-weight: bold; font-family: monospace;">
               
    <Bundle-Activator>${pom.groupId}.App</Bundle-Activator>
    style="font-weight: bold; font-family: monospace;">
             
    </instructions>
    style="font-weight: bold; font-family: monospace;">
           
    </configuration>
    style="font-weight: bold; font-family: monospace;">
         
    </plugin>
    style="font-weight: bold; font-family: monospace;">
       
    </plugins>
    style="font-weight: bold; font-family: monospace;">
     
    </build>
    style="font-family: monospace;">
    </project>
  4. Generate the OSGi bundle as shown below:


    cellpadding="2" cellspacing="2">
    style="font-family: monospace;">~/samples/v3/helloworld
    > style="font-weight: bold; font-family: monospace;">mvn
    install

    [INFO]
    Scanning for projects...
    style="font-family: monospace;">
    [INFO]
    ----------------------------------------------------------------------------
    style="font-family: monospace;">
    [INFO]
    Building helloworld


    [INFO]   
    task-segment: [install]
    style="font-family: monospace;">
    [INFO]
    ----------------------------------------------------------------------------
    style="font-family: monospace;">
    [INFO]
    [resources:resources]


    [INFO]
    Using
    default encoding to copy filtered resources.
    style="font-family: monospace;">
    [INFO]
    [compiler:compile]


    [INFO]
    Compiling 1 source file to
    /Users/arungupta/samples/v3/helloworld/target/classes
    style="font-family: monospace;">
    [INFO]
    [resources:testResources]
    style="font-family: monospace;">
    [INFO]
    Using
    default encoding to copy filtered resources.
    style="font-family: monospace;">
    [INFO]
    [compiler:testCompile]
    style="font-family: monospace;">
    [INFO]
    Compiling 1 source file to
    /Users/arungupta/samples/v3/helloworld/target/test-classes
    style="font-family: monospace;">
    [INFO]
    [surefire:test]


    [INFO]
    Surefire report directory:
    /Users/arungupta/samples/v3/helloworld/target/surefire-reports
    style="font-family: monospace;">


    ------------------------------------------------------- style="font-family: monospace;">
     T
    E
    S T S


    ------------------------------------------------------- style="font-family: monospace;">
    Running
    org.glassfish.samples.osgi.helloworld.AppTest
    style="font-family: monospace;">
    Tests run:
    1,
    Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.022 sec
    style="font-family: monospace;">


    Results : style="font-family: monospace;">


    Tests run:
    1,
    Failures: 0, Errors: 0, Skipped: 0
    style="font-family: monospace;">


    [INFO]
    [bundle:bundle]


    [INFO]
    [install:install]


    [INFO]
    Installing
    /Users/arungupta/samples/v3/helloworld/target/helloworld-1.0-SNAPSHOT.jar
    to
    /Users/arungupta/.m2/repository/org/glassfish/samples/osgi/helloworld/helloworld/1.0-SNAPSHOT/helloworld-1.0-SNAPSHOT.jar
    style="font-family: monospace;">
    [INFO]
    [bundle:install]


    [INFO]
    Parsing
    file:/Users/arungupta/.m2/repository/repository.xml
    style="font-family: monospace;">
    [INFO]
    Installing
    org/glassfish/samples/osgi/helloworld/helloworld/1.0-SNAPSHOT/helloworld-1.0-SNAPSHOT.jar
    style="font-family: monospace;">
    [INFO]
    Writing
    OBR metadata


    [INFO]
    ------------------------------------------------------------------------
    style="font-family: monospace;">
    [INFO]
    BUILD
    SUCCESSFUL


    [INFO]
    ------------------------------------------------------------------------
    style="font-family: monospace;">
    [INFO]
    Total
    time: 4 seconds


    [INFO]
    Finished at: Wed Jun 25 10:20:27 PDT 2008
    style="font-family: monospace;">
    [INFO]
    Final
    Memory: 22M/54M


    [INFO]
    ------------------------------------------------------------------------



    The generated "target/helloworld-1.0-SNAPSHOT.jar" has the following
    contents:


    cellpadding="2" cellspacing="2">
    style="font-family: monospace;">META-INF/MANIFEST.MF style="font-family: monospace;">
    META-INF/ style="font-family: monospace;">
    META-INF/maven/ style="font-family: monospace;">
    META-INF/maven/org.glassfish.samples.osgi.helloworld/ style="font-family: monospace;">
    META-INF/maven/org.glassfish.samples.osgi.helloworld/helloworld/ style="font-family: monospace;">
    META-INF/maven/org.glassfish.samples.osgi.helloworld/helloworld/pom.properties style="font-family: monospace;">
    META-INF/maven/org.glassfish.samples.osgi.helloworld/helloworld/pom.xml style="font-family: monospace;">
    org/ style="font-family: monospace;">
    org/glassfish/ style="font-family: monospace;">
    org/glassfish/samples/ style="font-family: monospace;">
    org/glassfish/samples/osgi/ style="font-family: monospace;">
    org/glassfish/samples/osgi/helloworld/ style="font-family: monospace;">
    org/glassfish/samples/osgi/helloworld/App.class



    And the generated "MANIFEST.MF" looks like:


    cellpadding="2" cellspacing="2">
    style="font-family: monospace;">Manifest-Version: 1.0 style="font-family: monospace;">
    Export-Package:
    org.glassfish.samples.osgi.helloworld;uses:="org.osgi.
    style="font-family: monospace;">
     framework" style="font-family: monospace;">
    Built-By:
    arungupta


    Tool:
    Bnd-0.0.255


    Bundle-Name:
    helloworld


    Created-By:
    Apache Maven Bundle Plugin
    style="font-family: monospace;">
    Bundle-Version:
    1.0.0.SNAPSHOT


    Build-Jdk:
    1.6.0_05


    Bnd-LastModified:
    1214414426851


    Bundle-ManifestVersion:
    2


    Bundle-Activator:
    org.glassfish.samples.osgi.helloworld.App
    style="font-family: monospace;">
    Import-Package:
    org.glassfish.samples.osgi.helloworld,org.osgi.framewo
    style="font-family: monospace;">
     rk;version="1.3" style="font-family: monospace;">
    Bundle-SymbolicName:
    helloworld

Now let's install this newly created bundle using Felix shell in
GlassFish v3. Check out and build GlassFish v3 workspace as explained
in href="http://blogs.sun.com/arungupta/entry/totd_33_building_glassfish_v3">TOTD
#33. Unzip
"~/workspaces/glassfish/v3/distributions/web/target/web.zip" and enable
Felix
TUI
as explained in href="http://blogs.sun.com/arungupta/entry/totd_34_using_felix_shell">TOTD
#34.

  1. Start GlassFish v3 as:


    cellpadding="2" cellspacing="2">
    style="font-family: monospace;">~/testbed/glassfish/v3/snapshot/glassfish
    >java -jar modules/glassfish-10.0-SNAPSHOT.jar style="font-family: monospace;">
    Jun 25,
    2008 4:09:19 PM com.sun.enterprise.glassfish.bootstrap.ASMain main
    style="font-family: monospace;">
    INFO:
    Launching GlassFish on Apache Felix OSGi platform
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:19 PM com.sun.enterprise.glassfish.bootstrap.ASMainOSGi
    getSharedRepos


    INFO:
    /Users/arungupta/testbed/glassfish/v3/snapshot/glassfish/domains/domain1/lib
    does not exist




    Welcome to
    Felix.


    ================= style="font-family: monospace;">


    Jun 25,
    2008 4:09:20 PM HK2Main start
    style="font-family: monospace;">
    INFO:
    contextRootDir =
    /Users/arungupta/testbed/glassfish/v3/snapshot/glassfish/modules
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:20 PM OSGiFactoryImpl initialize
    style="font-family: monospace;">
    INFO:
    Singleton already initialized as
    com.sun.enterprise.module.impl.HK2Factory@3d44d0c6
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:20 PM OSGiModuleImpl loadClass
    style="font-family: monospace;">
    INFO:
    Started bundle org.glassfish.common.glassfish-mbeanserver [19]
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:20 PM OSGiModuleImpl loadClass
    style="font-family: monospace;">
    INFO:
    Started bundle org.glassfish.core.kernel [51]
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:21 PM OSGiModuleImpl loadClass
    style="font-family: monospace;">
    INFO:
    Started bundle org.glassfish.common.glassfish-naming [8]
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:21 PM OSGiModuleImpl loadClass
    style="font-family: monospace;">
    INFO:
    Started bundle org.glassfish.admin.config-api [43]
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:21 PM OSGiModuleImpl loadClass
    style="font-family: monospace;">
    INFO:
    Started bundle org.glassfish.common.internal-api [33]
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:21 PM OSGiModuleImpl loadClass
    style="font-family: monospace;">
    INFO:
    Started bundle org.glassfish.deployment.deployment-common [10]
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:21 PM 
    style="font-family: monospace;">
    INFO:
    JMXMP connector server URL = service:jmx:jmxmp://localhost:8888
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:21 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    style="font-family: monospace;">
    INFO:
    Listening on port 8080
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:21 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    style="font-family: monospace;">
    INFO:
    Listening on port 8181
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:21 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    style="font-family: monospace;">
    INFO:
    Listening on port 4848
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:21 PM OSGiModuleImpl loadClass
    style="font-family: monospace;">
    INFO:
    Started bundle org.glassfish.common.container-common [21]
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:22 PM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter
    setContextRoot


    INFO:
    Admin Console Adapter: context root: /admin
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:22 PM com.sun.enterprise.v3.server.AppServerStartup run
    style="font-family: monospace;">
    INFO:
    Glassfish v3 started in 1789 ms
    style="font-family: monospace;">
    Jun 25,
    2008 4:09:22 PM 
    style="font-family: monospace;">
    INFO:
    ->


    Jun 25,
    2008 4:09:22 PM com.sun.enterprise.glassfish.bootstrap.ASMainFelix
    launchOSGiFW


    INFO:
    Framework successfully started
  2. Install the Hello World bundle as:


    cellpadding="2" cellspacing="2">
    style="font-weight: bold; font-family: monospace;">install
    file:///Users/arungupta/samples/v3/helloworld/target/helloworld-1.0-SNAP...


    Jun 25,
    2008 4:10:19 PM 
    style="font-family: monospace;">
    INFO:
    Bundle ID: 75


    Jun 25,
    2008 4:10:19 PM 
    style="font-family: monospace;">
    INFO:
    ->



    The command output shows "75" as the process id. This id is used to
    start/stop/uninstall the bundle later.

  3. Check the bundle status


    cellpadding="2" cellspacing="2">
    style="font-family: monospace;"> style="font-weight: bold;">ps     


    Jun 25,
    2008 4:10:27 PM 
    style="font-family: monospace;">
    INFO:
    START LEVEL 1


    Jun 25,
    2008 4:10:27 PM 
    style="font-family: monospace;">
    INFO:   
    ID  
    State        
    Level  Name


    Jun 25,
    2008 4:10:27 PM 
    style="font-family: monospace;">
    INFO:
    [   0]
    [Active     ]
    [    0] System Bundle (1.0.4)
    style="font-family: monospace;">
    Jun 25,
    2008 4:10:27 PM 
    style="font-family: monospace;">
    INFO:
    [   1]
    [Active     ]
    [    1] org.jvnet.tiger-types repackaged as
    module (0.3.2)


    Jun 25,
    2008 4:10:27 PM 
    style="font-family: monospace;">


    . . .



    INFO:
    [  71] [Installed  ] [   
    1] Web module command line interface (10.0.0.SNAPSHOT)
    style="font-family: monospace;">
    Jun 25,
    2008 4:10:27 PM 
    style="font-family: monospace;">
    INFO:
    [  72] [Installed  ] [   
    1] Admin GUI Web Container Plugin (10.0.0.SNAPSHOT)
    style="font-family: monospace;">
    Jun 25,
    2008 4:10:27 PM 
    style="font-family: monospace;">
    INFO:
    [  75] [Installed  ] [   
    1] helloworld (1.0.0.SNAPSHOT)
    style="font-family: monospace;">
    Jun 25,
    2008 4:10:27 PM 
    style="font-family: monospace;">
    INFO:
    ->



    The last log output shows the newly added process.

  4. Start the bundle as:


    cellpadding="2" cellspacing="2">
    style="font-weight: bold;">start 75

    Jun 25, 2008 4:10:32 PM 

    INFO: Hey!

    Jun 25, 2008 4:10:32 PM 

    INFO: ->



    This fragment shows "Hey!" output printed from the start method of
    Activator.

  5. Stop the bundle as:


    cellpadding="2" cellspacing="2">
    style="font-weight: bold;">stop 75

    Jun 25, 2008 4:10:35 PM 

    INFO: Bye!

    Jun 25, 2008 4:10:35 PM 

    INFO: ->



    This fragment shows "Bye!" output printed from the stop method of
    Activator.

  6. And finally uninstall the bundle as:


    cellpadding="2" cellspacing="2">
    style="font-weight: bold;">uninstall 75

    Jun 25, 2008 4:10:42 PM 

    INFO: ->

So following this blog you can deploy any of your OSGi bundles in
GlassFish v3.



Technorati: href="http://technorati.com/tag/glassfish">glassfish
v3 href="http://technorati.com/tag/osgi">osgi href="http://technorati.com/tag/maven">maven href="http://technorati.com/tag/mavenbundleplugin">mavenbundleplugin

Related Topics >>

Comments

Full automatic deployment ?

Hi Arun ! Many thanks for this article ! I was looking some time already for a way to build an osgi bundle by means of Maven. Just one question: I suspect the plugin "maven-bundle-plugin" is capable to deploy the bundle without the need of any manual intervention. Alas, I'm a bit new to all the osgi stuff and can't make much sense yet of the plugin's goals. You don't happen to know how I should use it to deploy a bundle right into glassfish ? Thanks ! Jan

Felix shell is started as part of v3 startup. v3 Prelude shows a message like: INFO: GlassFish v3 Prelude startup time : Felix(1732ms) startup services(1091ms) total(2823ms) It clearly shows how much time is taken to startup Felix. TOTD# 34 (http://blogs.sun.com/arungupta/entry/totd_34_using_felix_shell) shows how to start Felix shell. Are you looking for something else ?

There is something missing between step 5 and step 6. I believe that step 6, 7, 8, 9, 10 are all Felix shell command. How do I start Felix shell after I start Glassfish? In Felix standalone environment, I can start Felix shell by "java -jar bin/felix.jar". If I do the same for Felix under Glassfish. I will be prompted with profile name: I am using glassfishv3-prelude instead of building myself.

Please post your question to users@glassfish.dev.java.net and somebody may know.

is it possible to start glassfish in one process and start a separate process to manage osgi bundles. I would like to start/stop the osgi felix cli without having to start/stop glassfish itself. thank you

Vincent, OSGi bundles can be dropped in "modules" directory and will automatically get loaded.

Hi Arun, Thanks for sharing this. However I do have one question. Does glasfish does have some sort of pickup folder, which will load a bundle into felix once in this folder? Thanks. Regards Vincent