Glassfishv3 未将耳朵中的 jar 添加到类路径中

发布于 2024-10-14 22:58:13 字数 1175 浏览 7 评论 0原文

我已经研究这个问题一整天但徒劳无功,没有任何有效的解决方案。

我有一个用 ejb 和一些 jar 文件(包括 hibernate 和其他依赖的 jar 文件)打包的ear文件。ejb是无状态的并且作为Web服务启用。

Ear文件已使用maven打包,结构如下:

ear->projectrelatedejb.jar

->hibernate.jar

->otherdependent。 jar

->META-INF/application.xml

->META-INF/manifest.mf

application.xml和manifest文件是我做打包时maven自动生成的。

当我在 glassfish 上部署这个 Ear 文件时,它会使用可使用 Web 服务访问的 ejb 方法进行部署。但是,当访问应用程序(使用soapui)时, 使用 hibernate 执行某些数据库功能的 ejb 方法在运行时会为 hi​​bernate api 抛出 java.lang.NoClassDefFoundError 。

从错误中可以明显看出,hibernate jar 在运行时不在类路径上,但由于 jar 在耳朵内 Glassfish 应该有 将其添加到应用程序类路径中。

我尝试了各种选项,例如在打包期间将类路径条目添加到manifest.mf(通过使用带有maven-ear-plugin的元素addClasspath),但没有任何好处。此外,使用Glassfish,我们无法将依赖的jar添加为模块到 application.xml 除非 jar 是应用程序客户端 jar (如果 application.xml 具有声明为模块的依赖 jar,Glassfish 将不会部署 Ear 文件)。

我还尝试将 jar 放在耳朵内的 lib 目录中(实际上不是必需的),并使用清单类路径标头引用 lib 目录中的 jar,但这也没有解决问题。

为了让这个工作正常进行,我可以做的快速而肮脏的修复是将 hibernate 和其他依赖的 jar 放在 Glassfish 的 lib 目录中。但是,这是一个不好的做法 而我却有些不愿意这样做。

如果有人能为我提供解决这个问题的可行解决方案,我将非常感激。我已经通过网络寻找这个问题 但找不到任何解决方案。

想知道玻璃鱼是否有虫子,或者玻璃鱼是否需要特殊的东西来参考耳朵里的罐子。

提前致谢。

I have been working on this problem for one whole day but in vain without any effective solution.

I have an ear file packaged with an ejb and a handful of jar files (including hibernate and the other dependent jar files).The ejb is stateless and enabled as a web service.

The ear file has been packaged using maven and has the below structure

ear->projectrelatedejb.jar

->hibernate.jar

->otherdependent. jar

->META-INF/application.xml

->META-INF/manifest.mf

The application.xml and manifest file are automatically generated by maven when I do a package.

When I deploy this ear file on glassfish it gets deployed with the ejb methods being accessible using web services. However when accessing the application (using soapui),
the ejb methods that perform some database functionality using hibernate throw java.lang.NoClassDefFoundError for the hibernate api during runtime.

It is obvious from the error that the hibernate jars are not on the classpath during runtime but since the jars are within the ear Glassfish should have
added it to the application classpath.

I tried various options like adding the classpath entries to the manifest.mf during the package (by using the element addClasspath with the maven-ear-plugin) which didn't do any good.Also with Glassfish we cannot add the dependent jars as modules to the application.xml unless the jars are application client jars
(Glassfish wouldn't deploy the ear file if the application.xml has the dependent jars declared as modules).

I also tried placing the jars in the lib directory within the ear (which isn't actually required) and with the manifest Class-Path header referencing the jars in the lib directory which also didn't fix the problem.

The quick and dirty fix which I can do to get this working is to place the hibernate and the other the dependent jars in Glassfish's lib directory.However,this is a bad practice
and I am somewhat reluctant to do it.

I would really appreciate if someone can provide me with a working solution to this problem.I have gone through the net looking for this problem
but couldn't find any solution.

Wondering if its a bug with glassfish or does glassfish need something special to reference the jars in an ear.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

謌踐踏愛綪 2024-10-21 22:58:13

我发现了一个类似的问题,在这里讨论: http://www.tricoder.net/blog/ ?p=59

简而言之,尝试将库放在 EAR/lib 目录中,根据 JEE5 规范,glassfish 会自动将它们添加到类路径中。

I found a similar problem which is discussed here: http://www.tricoder.net/blog/?p=59.

Simply put, try putting the libraries in EAR/lib directory and according to JEE5 spec, glassfish will add them to class path automatically.

半仙 2024-10-21 22:58:13

我使用 Server Library 选项来部署应用程序 JAR,它对我有用。
右键单击您的 EAR->属性->图书馆->添加库->创建 -> 指定名称并将Library Type 中的类型更改为Server Libraries,然后添加应部署的 JAR 并确认。

我使用 NetBeans 7.0.1 和 GlassFish 服务器 3.1

I used Server Library option to deploy application JARs and it worked for me.
Right click on your EAR-> Properties -> Libraries-> Add Library -> Create -> give name and change type in Library Type to Server Libraries then add JARs that should be deployed and confirm.

I work with NetBeans 7.0.1 and GlassFish server 3.1

半山落雨半山空 2024-10-21 22:58:13

当您说您将类路径条目添加到manifest.mf时,您指的是哪个manifest.mf? Ear-root/META-INF/manifest.mf 中的那个?尝试使用类路径条目将 META-INF/MANIFEST.MF 添加到您的 ejb 模块!

When you say you added classpath entries to manifest.mf, which manifest.mf do you refer to? The one in ear-root/META-INF/manifest.mf ? Try adding a META-INF/MANIFEST.MF to your ejb module with Class-Path entries!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文