user1285928
user1285928

Reputation: 1476

Configure external libraries as Glassfish modules

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?

EDIT

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

[root@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?

Upvotes: 3

Views: 2983

Answers (2)

Frank Lee
Frank Lee

Reputation: 2748

I don't think the problem is in your war file, but to be sure you can check the MANIFEST file. If the Import-Package headers are correct, there isn't anything you can do from the war file. If that's the case, there must be a way to convince Glassfish to make a module visible to a webapp (I'm no Glassfish expert, sorry).

Otherwise, fix the Import-Package headers (you can do that manually for now).

Upvotes: 1

Eduardo Andrade
Eduardo Andrade

Reputation: 966

You can take a look at this section of glassfish documentation, called Module and Application Versions:

http://docs.oracle.com/cd/E26576_01/doc.312/e24929/overview.htm#gkhhv

"Application and module versioning allows multiple versions of the same application to exist in a GlassFish Server domain, which simplifies upgrade and rollback tasks. At most one version of an application or module can be enabled on a server any given time. Versioning provides extensions to tools for deploying, viewing, and managing multiple versions of modules and applications, including the Administration Console and deployment-related asadmin subcommands. Different versions of the same module or application can have the same context root or JNDI name. Use of versioning is optional."

Upvotes: 1

Related Questions