java 如何在 websphere 6.1(特别是 wsdl4j)中为 ear 配置类加载器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/689904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 13:23:57  来源:igfitidea点击:

How to configure classloader for ear in websphere 6.1 (specifically wsdl4j)

javaantwebsphere

提问by Gary McWilliams

I have a war file (actually not my own, it's Apache ODE 1.2) that fails to deploy into WAS 6.1 because of a classloader issue - and a specific incompatibility with wsdl4j. If I manually edit the classloader for ODE and create a shared-library for wsdl4j1.6.1 it's all fine.

我有一个 war 文件(实际上不是我自己的,它是 Apache ODE 1.2)由于类加载器问题而无法部署到 WAS 6.1 - 以及与 wsdl4j 的特定不兼容。如果我手动编辑 ODE 的类加载器并为 wsdl4j1.6.1 创建一个共享库,一切都很好。

However, the client has come back stating this is not acceptable and that I should provide an ear that is a self-contained install, with no manual steps involved.

然而,客户回来说这是不可接受的,我应该提供一个独立安装的耳朵,不涉及手动步骤。

I've been able to build the ear file that bundles the war, but I cannot find any relevant information on how to include a shared-lib within the ear - and have that used at the start of the classloader (needs to take preference over the wsdl4j bundled with WAS). Do I need to modify the ear file construct? Or the application.xml?

我已经能够构建捆绑War的耳朵文件,但是我找不到任何有关如何在耳朵中包含共享库的相关信息 - 并且在类加载器的开头使用了它(需要优先与 WAS 捆绑的 wsdl4j)。我需要修改ear文件结构吗?还是application.xml?

Can anyone offer any help? As you may guess, I am from a "tomcat just needs a war file" background, struggling to get to grips with ear files.

任何人都可以提供任何帮助吗?正如您可能猜到的,我来自“tomcat 只需要一个War文件”的背景,正在努力掌握耳朵文件。

My application.xml just contains: http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"> XXX ODE ode.war ode etc

我的 application.xml 只包含:http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">XXX ODE ode.war ode 等

采纳答案by Robin

You have three simple steps to accomplish this

您只需三个简单的步骤即可完成此操作

  1. Place the jar file in the ear, we typically create a lib directory, but that is not necessary.
  2. Update the manifest for the war to include this jar file.
  3. Set the classloading policy for your ear to PARENT_LAST. This is required to load your local (to the ear) classes before those loaded by the server.
  1. 将jar文件放在ear中,我们通常会创建一个lib目录,但这不是必需的。
  2. 更新War的清单以包含此 jar 文件。
  3. 将您耳朵的类加载策略设置为 PARENT_LAST。这是在服务器加载之前加载本地(耳边)类所必需的。

Edit: As an alternative, since you are only using the EAR to wrap the WAR and not actually sharing the jar file.

编辑:作为替代方案,因为您仅使用 EAR 来包装 WAR 而实际上并未共享 jar 文件。

  1. Put the jar in the lib directory of the WAR.
  2. Set the classloading policy for your ear to PARENT_LAST. This is required to load your local (to the ear) classes before those loaded by the server. I do this via RAD by editing the application.xml file. It is IBM specific configuration, so if you are not using RAD you will have to figure out what files to change manually.
  1. 将 jar 放在 WAR 的 lib 目录中。
  2. 将您耳朵的类加载策略设置为 PARENT_LAST。这是在服务器加载之前加载本地(耳边)类所必需的。我通过 RAD 编辑 application.xml 文件来做到这一点。这是 IBM 特定的配置,因此如果您不使用 RAD,您将必须弄清楚要手动更改哪些文件。

This should leave you with a consistent war between app servers.

这应该会让您在应用服务器之间进行持续的War。