Sun Application Server 中的 EJB 依赖项版本冲突
总结一下我遇到的问题,我有一个 EJB,它使用库的版本 A(我们称之为 dep-vA.jar)。 dep-vA.jar 打包在 EJB jar 文件的根目录中。应用程序服务器中的域 lib 文件夹包含同一库的版本 B(我们将其称为 dep-vB.jar)。调用 EJB 时,由于加载了 dep-vB.jar 文件而不是 dep-vA.jar,我收到错误。
我想这个问题的第一部分是,Sun One Application Server v9.1 是否将 EJB 彼此隔离?我的印象是确实如此。但似乎另一个应用程序加载了 dep-vB.jar 并且该 EJB 直接使用它而没有加载自己的应用程序。
第二个问题是,如果应用程序服务器确实隔离了 EJB,那么它是否会在查看应用程序服务器的 lib 文件夹之前从 EJB 的 jar 文件加载依赖项?我的印象是这也是正确的,但也许不是...
是否有人足够熟悉Sun应用程序服务器来解释为什么加载dep-vB.jar而不是dep-vA.jar?有什么方法可以让它加载 dep-vA.jar 而不更改应用程序服务器的 lib 文件夹中的内容? (我会犹豫是否做任何可能影响服务器上其他应用程序的事情)
谢谢。
To summarize the issue I'm encountering, I have an EJB which uses version A of a library (let's call it dep-vA.jar). dep-vA.jar is packaged in the root of the EJB's jar file. The domain lib folder in the application server contains version B of the same library (let's call it dep-vB.jar). When calling the EJB, I get an error due to dep-vB.jar file being loaded rather than dep-vA.jar.
I guess the first part of this question is, does Sun One Application Server v9.1 isolate EJBs from each other? I was under the impression that it does. But it seems like another application loaded dep-vB.jar and this EJB is directly using it without loading its own.
The second question is, if the app server does isolate EJBs, does it load dependencies from the EJB's jar file before looking in the application server's lib folders? I was under the impression that this is also true, but maybe not...
Is anyone familiar enough with Sun application servers to explain why dep-vB.jar is being loaded rather than dep-vA.jar? Is there any way to get it to load dep-vA.jar without changing what's in the application server's lib folders? (I would hesitate to do anything that might affect other applications on the server)
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 Sahoo(GlassFish 开发人员),< em>Java EE 规范不强制要求单耳模块之间的类加载隔离,因此一个应用程序服务器与另一个应用程序服务器的行为可能不同。对于 Sun ONE,我对 的理解文档 的特点是 EJB-JAR 是隔离的。
这是一种家长优先的策略(据我所知,Sun ONE 允许更改仅适用于 Web 应用程序的委派模式)。
话虽这么说,如果您在 EJB 的
MANIFEST.MF
的Class-Path
条目中列出dep-vA.jar
,会发生什么情况?罐?另请参见
According to Sahoo (which is a GlassFish developer), the Java EE spec does not mandate class loading isolation among modules of a single ear so the behavior can be different from one app server to another. With Sun ONE, my understanding of the documentation is that EJB-JARs are isolated.
It's a parent-first strategy (and to my knowledge, Sun ONE allows to change the delegating mode for webapps only).
That being said, what happens if you list
dep-vA.jar
in theClass-Path
entry of theMANIFEST.MF
of the EJB-JAR?See also
我没有使用过那个特定的服务器,但我知道在 WebSphere 中,有一个选项可以使用 PARENT_FIRST 或 PARENT_LAST 类加载。您将寻找 PARENT_LAST 的等效项,其中类首先从 EAR 加载,然后再加载到服务器。
我假设这样的配置在任何应用程序服务器中都是可能的,因为您应该始终能够强制您的应用程序特定的 jar 加载到任何其他应用程序服务器上。
I haven't used that particular server, but I do know that in WebSphere, there is an option to use PARENT_FIRST or PARENT_LAST classloading. You would be looking for an equivalent of PARENT_LAST where the classes are loaded from the EAR first before going up to the server.
I would assume that such a configuration is possible in any app server, as you should always be able to enforce your application specific jars to be loaded over any others.