users@glassfish.java.net

Configure external libraries as Glassfish modules

From: Peter Penzov <peter.penzov_at_gmail.com>
Date: Wed, 6 Jun 2012 20:22:33 +0300

I have several OSGI bundles and WAR packages which use external libraries:

<dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>4.2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.compendium</artifactId>
            <version>4.2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>osgi-cdi-api</artifactId>
            <version>3.1-b41</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>

Instead of building the libraries into every OSGI bundle and WAR package
 is it possible to copy these libraries into /modules directory of the
Glassfish server. I suppose that it's possible to use only one copy
without any problem?

I found that these libraries can be deployed as modules in Glassfish with
the command:

[root_at_Testserver bin]# sh asadmin add-library /opt/primefaces.jar

But then for example in a simple WAR package what I need to modify in order
to use Glassfish modules? The WAR package must be configured to use
external libraries I suppose?


Best Wishes

Peter