Configuring External Libraries as Glassfish Modules

I have several OSGI packages and WAR packages that 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 creating libraries in each OSGI package and WAR package, you can copy these libraries to the / modules directory of the Glassfish server. I believe that only one copy can be used without any problems?

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 do I need to change to use Glassfish modules? Is the WAR package supposed to be configured to use external libraries?

+4
source share
2 answers

I do not think the problem is in your war file, but you can check the MANIFEST file. If the Import-Package headers are correct, there is nothing you can do in the war file. If so, there should be a way to convince Glassfish to make the module visible to the webapp (I'm not a Glassfish expert, sorry).

Otherwise, correct the Import-Package headers (you can now do this manually).

+1
source

You can read this section of the glass documentation called the Module and Application Versions :

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

"Versioning applications and modules allows you to use multiple versions of the same application in the GlassFish Server domain, which simplifies the task of updating and rolling back. At any time, no more than one version of the application can be allowed on the server. Provides extensions for tools for deployment, viewing and managing multiple versions of modules and applications, including administrative consoles and related to the deployment of the asadmin subcommand. Different versions of the same module or application may have one and from the same root as the name of the context or JNDI. is optional. "

+1
source

Source: https://habr.com/ru/post/1414986/


All Articles