如何在glassfish中使用第三方库? [英] How to use 3rd party libraries in glassfish?

查看:123
本文介绍了如何在glassfish中使用第三方库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从我的EJB3应用程序连接到一个MongoDB实例,运行在glassfish 3.0.1上。 Mongo项目提供了一组驱动程序,我可以在独立的Java应用程序中使用它们。

I need to connect to a MongoDB instance from my EJB3 application, running on glassfish 3.0.1. The Mongo project provides a set of drivers, and I'm able to use them in a standalone Java application.

我如何在Java EE应用程序中使用它们?或者也许更好的措辞:当我的应用程序运行在EJB容器中时,如何使第三方库可用?

How would I use them in a Java EE application? Or maybe better phrasing: how would I make a 3rd party library available to my application when it runs in an EJB container?

目前,我得到一个java .lang.NoClassDefFoundError当部署一个
尝试从库中导入的bean时:

At the moment, I'm getting a java.lang.NoClassDefFoundError when deploying a bean that tries to import from the library:

[#|2010-03-24T11:42:15.164+0100|SEVERE|glassfishv3.0|global|_ThreadID=28;_ThreadName=Thread-1;|Class [ com/mongodb/DBObject ] not found. Error while loading [ class mvs.core.LocationCacheService ]|#]
[#|2010-03-24T11:42:15.164+0100|WARNING|glassfishv3.0|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=28;_ThreadName=Thread-1;|Error in annotation processing: java.lang.NoClassDefFoundError: com/mongodb/DBObject|#]

[#|2010-03-24T11:42:15.259+0100|SEVERE|glassfishv3.0|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=28;_ThreadName=Thread-1;|Exception while loading the app
org.glassfish.deployment.common.DeploymentException: java.lang.NoClassDefFoundError: com/mongodb/DBObject
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:171)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:125)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:224)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:338)

我尝试添加它到网络Beans项目(属性 - >库 - >编译 - >添加Jar,启用'Package'),我也尝试手动将jar文件复制到$ GF_HOME / glassfish / domains / domain1 / lib(其中mysql连接器已经驻留) 。

I tried adding it to the NetBeans project (Properties -> Libraries -> Compile -> Add Jar, enable 'Package'), and I also tried manually copying the jar file to $GF_HOME/glassfish/domains/domain1/lib (where the mysql-connector already resides).

我需要向容器注册库吗?通过注释引用它?扩展容器的类路径以包含库?

Do I need to 'register' the library with the container? Reference it via Annotation? Extend the classpath of the container to include the library?

推荐答案

嗯...不应该把这个驱动程序放入 glassfishv3 / glassfish / domains / domain1 / lib / ext

Hmm... Shouldn't you put this "driver" in glassfishv3/glassfish/domains/domain1/lib/ext?

这篇关于如何在glassfish中使用第三方库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆