简体   繁体   English

将外部库配置为Glassfish模块

[英]Configure external libraries as Glassfish modules

I have several OSGI bundles and WAR packages which use external libraries: 我有几个使用外部库的OSGI捆绑包和WAR包:

       <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. 可以将这些库复制到Glassfish服务器的/ modules目录中,而不是将库构建到每个OSGI捆绑包和WAR软件包中。 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: 我发现可以使用以下命令在Glassfish中将这些库部署为模块:

[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? [root@Testserver bin]# sh asadmin add-library /opt/primefaces.jar但是,例如,在一个简单的WAR包中,为了使用Glassfish模块,我需要修改什么? The WAR package must be configured to use external libraries I suppose? 我必须将WAR软件包配置为使用外部库吗?

You can take a look at this section of glassfish documentation, called Module and Application Versions : 您可以查看Glassfish文档的这一部分,称为模块和应用程序版本

http://docs.oracle.com/cd/E26576_01/doc.312/e24929/overview.htm#gkhhv 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. " 应用程序和模块版本控制允许在GlassFish Server域中存在同一应用程序的多个版本,从而简化了升级和回滚任务。在给定的时间,最多可以在服务器上启用一个应用程序或模块的版本。版本控制提供了对用于部署,查看和管理模块和应用程序的多个版本的工具,包括管理控制台和与部署相关的asadmin子命令,同一模块或应用程序的不同版本可以具有相同的上下文根或JNDI名称,版本控制是可选的。

I don't think the problem is in your war file, but to be sure you can check the MANIFEST file. 我认为问题不在您的war文件中,但请确保您可以检查清单文件。 If the Import-Package headers are correct, there isn't anything you can do from the war file. 如果Import-Package标头正确,则war文件无法执行任何操作。 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). 在这种情况下,必须有一种方法可以说服Glassfish使某个模块对Web应用程序可见(我不是Glassfish专家,对不起)。

Otherwise, fix the Import-Package headers (you can do that manually for now). 否则,请修复Import-Package标头(您现在可以手动执行此操作)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM