我可以在 ibm-web-bnd.xmi 文件中设置 WebSphere 的类加载器策略吗?
我有一个在 WAS 6 上运行的 JEE 应用程序。它需要将类加载器顺序设置为“首先使用应用程序类加载器加载的类”,并将 WAR 类加载器策略选项设置为“应用程序的单个类加载器”。
是否可以在 EAR 文件中指定这些选项,无论是在 ibm-web-bnd.xmi 文件还是其他文件中,以便管理员不需要手动更改这些设置?
由于该应用程序是通过自动化脚本部署的,并且负责部署的人员不在现场,而且还出于其他一些政治原因,这将非常有帮助!
I have a JEE application that runs on WAS 6. It needs to have the class loader order setting to "Classes loaded with application class loader first", and the WAR class loader policy option set to "Single class loader for application".
Is it possible to specify these options inside the EAR file, whether in the ibm-web-bnd.xmi file or some other file, so the admin doesn't need to change these setting manually?
Since the app is deployed via an automated script, and the guy who is in charge of deployment is off site, and also for some other political reasons, this would greatly help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
感谢@Matthew Murdoch 的回答,我能够想出一个解决方案。 就在这里,以防对其他人有帮助。
我创建了一个如下的deployment.xml:
确保更改 WAR 文件的名称以匹配(我的文件名为 AGS.war)。
我还更改了 xmi:id 属性中的数字,以确保它们是唯一的,尽管我不确定它们在应用程序中是唯一的是否真的很重要。
然后,我通过 ANT 将部署.xml 文件放入 EAR 文件的根目录中:
Thanks to @Matthew Murdoch's answer, I was able to come up with a solution. Here it is, in case it helps someone else.
I created a deployment.xml like this:
Make sure to change the name of your WAR file(s) to match (mine is called AGS.war).
I also changed the numbers in the
xmi:id
attributes, to be sure they are unique, though I'm not sure it it really matters that they be unique across applications.Then, I put the deployment.xml file in the root of my EAR file, via ANT:
编辑 (2): WebSphere Application Server Toolkit (AST) 是一个工具,您可以使用此信息来增强 EAR 文件(例如,请参阅 '配置本文档中的“增强型 EAR”部分)。
编辑 (1): 这篇文章 建议可以在 EAR 内的 deployment.xml 文件中设置“首先使用应用程序类加载器加载的类”(PARENT_LAST 设置)。
如果您可以控制自动部署脚本,则可以完成此操作。 下面是一些 wsadmin jython 代码,用于将 Web 模块类加载器顺序设置为“首先使用应用程序类加载器加载的类”(有趣的是,该设置称为 PARENT_LAST,这就是它在以前版本的管理控制台中的标签...)。
wsadmin 示例(jython):
Edit (2): The WebSphere Application Server Toolkit (AST) is a tool you can use to enhance an EAR file with this information (see for example the 'Configure an Enhanced EAR' section in this document).
Edit (1): This post suggests that the 'Classes loaded with application class loader first' (the PARENT_LAST setting) can be set in the deployment.xml file within the EAR.
If you have control over the automated deployment scripts this can be done. Below is some wsadmin jython code for setting the web module class loader order to 'Classes loaded with application class loader first' (interestingly the setting is called PARENT_LAST which is what it was labelled in previous versions of the admin console...).
wsadmin example (jython):
查看此链接。 根据您的服务器版本,使用 Jython 设置类加载器策略有不同的方法 -
http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Frxml_7libapp4.html
Check out this link. There are different ways to set class loader policy using Jython based on your server version -
http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Frxml_7libapp4.html
与 pkaeding 的答案类似,我发现如下,不是特定于名称的特定 .war,但在应用于 .ear 文件中的默认 .war 时很有用。 (其中包含一个 .war 文件的 .ear 文件仅包含该 .war,因此无需在条目中命名 .war。)此方法可能适用于您可能需要重新命名 .war 的情况由于某种原因稍后会重新启动项目,因此您无需担心更新
deployment.xml
文件。 我发现deployment.xml
文件隐藏在单元引用目录路径中; 不知道当文件放置在目录级别META-INF
且不更深时,是否可以如图所示。在我的特定情况下,我在 .ear 项目中找到了
deployment.xml
:文件的内容看起来很像:
该行:
最初读为:
注意没有引用任何 .war。 正如 pkaeding 提到的,您不应该期望不同的 ID 号对您来说是相同的。
Similar to the answer from pkaeding, I discovered as follows, not specific to a particular .war by name, but useful when applying to whatever is the default .war in the .ear file. (.ear files with one .war file in them have only that .war, so naming the .war isn't necessary in the entry.) This approach may be good for situations where you may need to re-name of the .war project later for some reason, and so you wouldn't need to worry about updating the
deployment.xml
file. I found thedeployment.xml
file buried inside a cell reference directory trail; dunno if it's fine as shown when the file is placed at directory levelMETA-INF
and no deeper.In my particular case, I found
deployment.xml
in my .ear project at:<project_root>\META-INF\ibmconfig\cells\defaultCell\applications\defaultApp\deployments\defaultApp\
The content of the file looks a lot like:
The line:
originally read:
Note no reference to any .war is being made. As pkaeding mentioned, you shouldn't expect the various id numbers to be the same for you.