如何更改 application.xml 文件中的类加载器以支持已部署 jar 的首选项加载

发布于 2024-09-26 20:52:51 字数 1078 浏览 2 评论 0原文

我使用 Tomcat 6 作为容器构建了一个 Web 应用程序。我使用了 Tomcat 的几个 Jars,并从我在 Eclipse 中构建的 ant 引用了它们。

我编写了另一个 ant 构建来将我的应用程序部署到 .war 中,然后与 application.xml 部署描述符一起部署到 .ear 中以部署到 WAS 7。为了支持这一点,我将这些 jar 放入我的 war 中所以我知道它们将可用于通过 Tomcat 运行的应用程序。

我知道我需要在 application.xml 文件中放入一些内容,以使类加载器使用我拉入的 jar,而不是 WAS 的,但我一生都找不到合适的资源来阅读application.xml 文件中存在哪些完整的选项,更不用说我需要输入什么来放入此(PARENT_LAST?)文本了。1

)任何人都可以向我指出一个完整的在线文档,其中列出了我可以放入的所有内容我的 application.xml 来控制我的 .ear

2) 任何人都可以发布一个修改以下 xml 的列表,以便当 xml 文件包含在 .ear 中时,它可以部署到 WAS,以便 WAS 容器使用随附的 war 中的 jar而不是 WAS 设置中的那些。

我将永远感激不已。

<?xml version="1.0" encoding="UTF-8"?>
<application id="Client">
   <display-name>Client</display-name>
   <description>Web application supporting the configuration and management of server components</description>
   <module id="Client">
      <web>
         <web-uri>Client.war</web-uri>
         <context-root>client</context-root>
      </web>
   </module> 
</application>

I have built a web app using Tomcat 6 as a container. I was using a couple of Jars of Tomcat's and referring to them from my ant build in Eclipse.

I've written another ant build to deploy my app into a .war and then together with an application.xml deployment descriptor into an .ear for deploying to WAS 7. In order to support this, I've pulled the jars into my war so I know they'll be available to the app which worked through Tomcat.

I know that I need to put something into the application.xml file to cause the class loader to use the jars I've pulled in and not WAS's but for the life of me I can't even find a decent resource to read up on what full range of options exist in an application.xml file let alone exactly what I need to type to put this (PARENT_LAST?) text in.

1) Can anyone point me to a full online document listing all the things that I can put into my application.xml to control my .ear

2) Can anyone post a listing which modifies the below xml such that when the xml file is included in a .ear it can deploy to WAS such that the WAS container uses the jars in the enclosed war rather than the ones in the WAS setup.

I will be eternally grateful.

<?xml version="1.0" encoding="UTF-8"?>
<application id="Client">
   <display-name>Client</display-name>
   <description>Web application supporting the configuration and management of server components</description>
   <module id="Client">
      <web>
         <web-uri>Client.war</web-uri>
         <context-root>client</context-root>
      </web>
   </module> 
</application>

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

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

发布评论

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

评论(1

宁愿没拥抱 2024-10-03 20:52:51

PARENT_LAST 不太可能对您有帮助,更不用说我不会用 10 英尺长的杆子碰这个选项,因为我一直认为它是一种黑客行为。

您正在寻找的行为是默认提供的 - 这实际上是根据 J2EE 规范的“正确”工作方式。您能否向我们提供 EAR 文件、WAR 文件以及两者的 MANIFEST.MF 文件的确切组成?

[编辑添加以下内容]

下面的评论也是正确的(谢谢) - 如果您在 Web 应用程序中包含了来自 Tomcat 的 JAR 文件,那么您已经在做一些非常错误的事情,并且很可能是不可移植的。

  • 与J2EE规范相关的JAR文件(例如包含J2EE API的JAR文件)由应用服务器供应商提供;您应该将它们从可部署模块(EAR、WAR)中排除。
  • 与特定 Tomcat 功能相关的 JAR 文件...好吧,这些文件在 Tomcat 之外无法运行,因此 WebSphere 迁移的整个主题没有实际意义。

PARENT_LAST is not likely to help you, not to mention that I wouldn't touch that option with a 10-foot pole as I always considered it a hack.

The behavior you're looking for is provided by default - that's actually the "correct" way of working according to the J2EE spec. Can you provide us with the exact composition of your EAR file, your WAR file, and the MANIFEST.MF file of both?

[Edited to add the following]

The comment below is correct as well (thanks) - if you included JAR files from Tomcat inside your Web application, then you're already doing something very wrong and most likely unportable.

  • JAR files pertaining to the J2EE specification (such as JAR files containing the J2EE API) are provided by application server vendors; you should exclude them from your deployable module (EAR, WAR).
  • JAR files pertaining to specific Tomcat functionality... Well, those wouldn't function outside of Tomcat so the entire subject of WebSphere migration is moot.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文