OpenEJB 上的 EJB 2.0 - 在哪里放置所需的 jar?

发布于 2024-09-27 02:18:11 字数 444 浏览 1 评论 0原文

到目前为止,我们一直在使用 WAS 6.1 来部署我们的 Web 应用程序。现在我们需要迁移到经济的 Tomcat + OpenEJB 解决方案。 OpenEJB 3.1.2 容器已插入 Tomcat 6.18,这里没有独立的 OpenEJB 服务器。

所以我在这里尝试将我的 EJB 2.1 对象部署到 OpenEJB 中...

我的问题是 EJB 代码需要外部 .jar 库,并且我不知道将它们放在哪里以便实际上将它们考虑在内容器的类路径。它在 catalina.home/lib 中运行良好,在 openejb.home/lib 中也运行良好。但我仍然宁愿找到一种打包 EJB 的方法,以便可以轻松部署它们,并将其链接的 .jar 直接放到适当的位置以供 OpenEJB 容器使用。

它可以包括使用正确的描述符文件构建 .ear 或 .jar...任何有效的解决方案对我来说都足够好了。

有人可以帮忙吗?

We've been using WAS 6.1 so far to deploy our web apps. Now we need to migrate to an economics-savvy Tomcat + OpenEJB solution. The OpenEJB 3.1.2 container is plugged into Tomcat 6.18, no standalone OpenEJB server here.

So here I am, trying to deploy my EJB 2.1 objects into OpenEJB...

My problem is that the EJBs code requires external .jar libraries, and I don't know where to put them so that they are actually taken into account into the container's classpath. It works fine into catalina.home/lib, so it does into openejb.home/lib. But still I'd rather find out a way to package the EJBs so that they are easy deployed with their linked .jar dropped right into place to be used by the OpenEJB container.

It can include building up an .ear or a .jar with the right descriptor files... Any solution that works is good enough for me.

Can possibly anyone help?

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

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

发布评论

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

评论(2

笑忘罢 2024-10-04 02:18:11

Ear Approach

您只需将其放入 Tomcat webapps/ 目录中,它就会被拾取。

示例ear(有效):

myapplication.ear
  lib/
  lib/libraryOne.jar
  lib/libraryTwo.jar
  redEjbs.jar
  blueEjbs.jar

常见错误(无效):

myapplication.ear
  libraryOne.jar  (err. not a javaee module)
  libraryTwo.jar  (err. not a javaee module)
  redEjbs.jar
  blueEjbs.jar

根目录下只允许使用Java EE 模块。这些是 EJB jar、.war 文件、连接器 .rar 文件和应用程序客户端 jar。在 Java EE 5 之前,必须在 application.xml 文件中显式列出库。 Java EE 5 及更高版本可以将它们添加到 lib/ 目录中,并被理解为只是普通的 jar,而不是 Java EE 模块。

崩溃的 EAR 方法

在 OpenEJB/Tomcat 中,您可以将所有库放入 war 文件中,并且摆脱 Ear 概念。现在这是 Java EE 6 的一部分。

mywebapp.war
  WEB-INF/lib/libraryOne.jar
  WEB-INF/lib/libraryTwo.jar
  WEB-INF/lib/redEjbs.jar
  WEB-INF/lib/blueEjbs.jar

常见错误,包括规范:

mywebapp.war
  WEB-INF/lib/javax.ejb.jar   (err. clashes with the related system library)
  WEB-INF/lib/libraryOne.jar
  WEB-INF/lib/libraryTwo.jar
  WEB-INF/lib/redEjbs.jar
  WEB-INF/lib/blueEjbs.jar

听起来这不是问题,但为了完整性而添加。

常见错误,损坏的依赖关系:

tomcat/lib/libraryTwo.jar

mywebapp.war
  WEB-INF/lib/libraryOne.jar
  WEB-INF/lib/redEjbs.jar
  WEB-INF/lib/blueEjbs.jar

从规范的角度来看,上述内容并非无效,并且服务器不可能检测到,但仍然可能导致应用程序无法正确加载。如果libraryTwo.jar需要libraryOne.jar中的类,那么这个应用程序将永远不会工作,因为Tomcat“lib”类加载器无法看到“webapp”类加载器中的类,因此libraryTwo.jar中的类永远不会成功加载。不幸的是,虚拟机几乎永远不会说出丢失的实际类,而是报告导致需要丢失的类的事件链中的第一个类。这几乎总是 bean 或 servlet 类。

Ear Approach

You can just drop it into the Tomcat webapps/ directory and it will be picked up.

Example ear (valid):

myapplication.ear
  lib/
  lib/libraryOne.jar
  lib/libraryTwo.jar
  redEjbs.jar
  blueEjbs.jar

Common mistake (invalid):

myapplication.ear
  libraryOne.jar  (err. not a javaee module)
  libraryTwo.jar  (err. not a javaee module)
  redEjbs.jar
  blueEjbs.jar

Only Java EE modules are allowed at the root. These are EJB jars, .war files, Connector .rar files and Application Client jars. Prior to Java EE 5, libraries had to be explicitly listed in an application.xml file. Java EE 5 and forward they can be added to a lib/ directory and be understood to be just plain jars as opposed to a Java EE module.

Collapsed EAR approach

In OpenEJB/Tomcat you can put all your libraries into the war file and be free of the ear concept. This is now part of Java EE 6.

mywebapp.war
  WEB-INF/lib/libraryOne.jar
  WEB-INF/lib/libraryTwo.jar
  WEB-INF/lib/redEjbs.jar
  WEB-INF/lib/blueEjbs.jar

Common mistake, including specs:

mywebapp.war
  WEB-INF/lib/javax.ejb.jar   (err. clashes with the related system library)
  WEB-INF/lib/libraryOne.jar
  WEB-INF/lib/libraryTwo.jar
  WEB-INF/lib/redEjbs.jar
  WEB-INF/lib/blueEjbs.jar

Doesn't sound like that is the issue, but adding for completeness.

Common mistake, broken dependencies:

tomcat/lib/libraryTwo.jar

mywebapp.war
  WEB-INF/lib/libraryOne.jar
  WEB-INF/lib/redEjbs.jar
  WEB-INF/lib/blueEjbs.jar

The above is not invalid from a spec perspective and is impossible for the server to detect, but still can lead to apps not loading correctly. If libraryTwo.jar needs classes in libraryOne.jar then this app will never work as the Tomcat "lib" classloader cannot see classes from the "webapp" classloader, so classes from libraryTwo.jar will never successfully load. Unfortunately, the vm will almost never say the actual class that was missing and instead will report the first class in the chain of events that lead to needing a class that was missing. This is almost always a bean or servlet class.

千纸鹤 2024-10-04 02:18:11

谢谢大卫。
我尝试了以上所有方法,但仍然没有运气。
我猜 Collapsed EAR 方法对我不起作用,因为据我所知 Tomcat 6.0.18 不符合 J2EE 6 规范。也许我错了,但我尝试过,但还是没用。那么回到标准 EAR 方法。

我的 EAR 的组织方式与您第一个示例中描述的完全一样。一个 Ejb jar,/lib 中的两个库 jar,仅此而已。 Tomcat 仍然无法实例化我的 EJB,因为 EJB 类与 Library Jar Two 中无法访问的类相关。

我简化了 application.xml 文件,使其仅声明一个 EJB:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ...>
<application>
  <display-name>ProxyaEAR</display-name>
  <module id="EjbModule">
     <ejb>ProxyaEJB.jar</ejb>
  </module>
</application>

还有其他想法吗?

Thanks David.
I tried all of the above, but still no luck.
The Collapsed EAR approach wouldn't work for me I guess, as I far as I know Tomcat 6.0.18 doesn't comply to the J2EE 6 specs. Maybe I'm wrong , but I tried and it didn't work anyway. So back to the standard EAR approach.

My EAR is organized exactly as described in your very first example. One Ejb jar, two library jars in /lib, and that's it. Tomcat still can't instanciate my EJB because the EJB class relates to an unreachable class from Library Jar Two.

I simplified my application.xml file so that it only declares one single EJB:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ...>
<application>
  <display-name>ProxyaEAR</display-name>
  <module id="EjbModule">
     <ejb>ProxyaEJB.jar</ejb>
  </module>
</application>

Any other thoughts??

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