如何配置 EAR 来访问现有的 Websphere 共享库?

发布于 2024-11-26 15:19:37 字数 445 浏览 1 评论 0原文

我将 JSF2 与 Websphere 7 一起使用。我已经成功创建了一个共享库,并使用 Webpsphere 管理控制台指向了应用程序,并且它工作成功。但我们真正想做的是不必通过 WAS 管理控制台指向该共享库,而是在部署.xml 等中进行某种应用程序级别配置,我们可以指向该共享隔离库的名称并使用它。我已经浏览过SO和谷歌,但没有发现任何事情可以做到这一点。然而,我知道有商业应用程序在这样做,但不知道如何做。
这个问题来自如何在 Websphere 6.1 部署描述符中的 Web 模块级别指定共享库引用? 正是我所追求的,但我不想指定版本号或 jar 名称,因为答案指出

I am using JSF2 with Websphere 7 . I have created a shared lib successfully and have pointed application using Webpsphere Admin Console and it works successfully . But what we really want to do is to not have to point to that Shared Lib via WAS Admin Console but have some sort of application level configuration e.g in deployment.xml etc which we can point to the name of that Shared Isolated Lib and use it . I have gone through SO and google but not found any thing doing that . I however know that there are commercial application doing it but do not know how .
This question from How can I specify a shared library reference at the web module level in Websphere 6.1 deployment descriptors? is closely what I am after but I not want to specify version numbers or jar names as the answer states

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

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

发布评论

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

评论(3

囍孤女 2024-12-03 15:19:37

我通过简单地遵循 WAS Admin Console 实际执行的操作找到了一种方法。

如果您还没有 EAR 文件,请在 EAR 文件中创建一个 deployment.xml。
您将找到对类加载器的引用,如下所示

<classloader xmi:id="Classloader_1311552732281" mode="PARENT_FIRST">

修改它并添加对在服务器上创建的共享库的引用,如下所示

 <classloader xmi:id="Classloader_1311552732281" mode="PARENT_FIRST">
        <libraries libraryName="JSF2_SHARED_LIB" sharedClassloader="true"/>
 </classloader>

@dbreaux 也显示了一种方法。接受我自己的答案更适合我的需求,但也非常感谢 dbreaux 的建议。

I found a way by simply following what WAS Admin Console was actually doing.

Create a deployment.xml in your EAR file if you do not have one already .
You will find a reference to class loader like below

<classloader xmi:id="Classloader_1311552732281" mode="PARENT_FIRST">

Modify it and add reference to the shared Liberary created on server like below

 <classloader xmi:id="Classloader_1311552732281" mode="PARENT_FIRST">
        <libraries libraryName="JSF2_SHARED_LIB" sharedClassloader="true"/>
 </classloader>

@dbreaux has also shown a way .Accpeting my own answer as fits my needs better but big thanks to dbreaux too for advice.

爱给你人给你 2024-12-03 15:19:37

问题是否只是您不想单独配置每个应用程序,或者您根本不想使用管理控制台?您可以将共享库与整个服务器关联,这可能会比为每个应用程序都这样做更好。

创建这些应用程序关联的另一种方法是在特定于 WebSphere 的 .xmi 部署文件中。它们是在部署时创建的,但也可以包含在 WAR/EAR 文件中。我不知道这对你是否有帮助。如果可以,提前创建它们的官方方法是使用 部署工具,但由于它们只是 XML,因此您可以放心创建它们手动。

Is the issue just that you don't want to have to configure each application separately, or that you don't want to use the admin console at all? You can associate a shared library with an entire server, which might be preferable to doing it for each app.

The other way to create those application associations is in the WebSphere-specific .xmi deployment files. These are created when you deploy but can also be included in WAR/EAR files. I don't know if that would help you at all. If it would, the official way to create them ahead of time is using one of the Deployment Tools, but since they're just XML, you may feel comfortable creating them manually.

零時差 2024-12-03 15:19:37

在 Shahzeb 的回答中添加额外的细节:
我的环境:Websphere 8.5; Windows 7;(Eclipse Luna生成测试.war文件)

我已经通过websphere控制台在websphere服务器上安装了从eclipse导出的war文件。
然后再次导出并解压,看看websphere自动添加了什么来生成EAR。

[folder]META-INF
  [folder]ibmconfig
  [file]application.xml
  [file]ibm-application-bnd.xmi
  [file]ibm-application-runtime.props
  [file]MANIFEST.MF
  [file]was.module
  [file]was.policy
  [file]was.webmodule

[file]myWAR.war

并且文件deployment.xml放置在
..\ibmconfig\cells\defaultCell\applications\defaultApp\deployments\defaultApp\

其内容形式为


<?xml version="1.0" encoding="UTF-8"?>
<appdeployment:Deployment xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:appdeployment="http://www.ibm.com/websphere/appserver/schemas/5.0/appdeployment.xmi" xmi:id="Deployment_1417052686904">
  <deployedObject xmi:type="appdeployment:ApplicationDeployment" xmi:id="ApplicationDeployment_1417052686904" deploymentId="0" startingWeight="1" binariesURL="$(APP_INSTALL_ROOT)/[server service name]Cell/myWAR.ear" useMetadataFromBinaries="false" enableDistribution="true" createMBeansForResources="true" reloadEnabled="false" appContextIDForSecurity="href:[server service name]Cell/myWAR" filePermission=".*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755" allowDispatchRemoteInclude="false" allowServiceRemoteInclude="false" asyncRequestDispatchType="DISABLED" standaloneModule="true" enableClientModule="false">
    <targetMappings xmi:id="DeploymentTargetMapping_1417052686904" enable="true" target="ServerTarget_1417052686904"/>
    <classloader xmi:id="Classloader_1417052686904" mode="PARENT_FIRST"/>
    <modules xmi:type="appdeployment:WebModuleDeployment" xmi:id="WebModuleDeployment_1417052686904" deploymentId="1" startingWeight="10000" uri="myWAR.war" containsEJBContent="0">
      <targetMappings xmi:id="DeploymentTargetMapping_1417052686905" target="ServerTarget_1417052686904"/>
      <classloader xmi:id="Classloader_1417052686905"/>
    </modules>
    <properties xmi:id="Property_1417052686904" name="metadata.complete" value="true"/>
  </deployedObject>
  <deploymentTargets xmi:type="appdeployment:ServerTarget" xmi:id="ServerTarget_1417052686904" name="server1" nodeName="[server service name]"/>
</appdeployment:Deployment>

(因为我没有声誉,所以我必须全部以文本形式完成..)

To append extra details to Shahzeb's answer:
My environment: Websphere 8.5; Windows 7;(Eclipse Luna to generate testing .war file)

I have installed the war file exported from eclipse on websphere server by websphere console.
Then exported it again and unpack it to see what websphere automatically add to it to generate EAR.

[folder]META-INF
  [folder]ibmconfig
  [file]application.xml
  [file]ibm-application-bnd.xmi
  [file]ibm-application-runtime.props
  [file]MANIFEST.MF
  [file]was.module
  [file]was.policy
  [file]was.webmodule

[file]myWAR.war

And the file deployment.xml is placed in
..\ibmconfig\cells\defaultCell\applications\defaultApp\deployments\defaultApp\

whose content in form of


<?xml version="1.0" encoding="UTF-8"?>
<appdeployment:Deployment xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:appdeployment="http://www.ibm.com/websphere/appserver/schemas/5.0/appdeployment.xmi" xmi:id="Deployment_1417052686904">
  <deployedObject xmi:type="appdeployment:ApplicationDeployment" xmi:id="ApplicationDeployment_1417052686904" deploymentId="0" startingWeight="1" binariesURL="$(APP_INSTALL_ROOT)/[server service name]Cell/myWAR.ear" useMetadataFromBinaries="false" enableDistribution="true" createMBeansForResources="true" reloadEnabled="false" appContextIDForSecurity="href:[server service name]Cell/myWAR" filePermission=".*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755" allowDispatchRemoteInclude="false" allowServiceRemoteInclude="false" asyncRequestDispatchType="DISABLED" standaloneModule="true" enableClientModule="false">
    <targetMappings xmi:id="DeploymentTargetMapping_1417052686904" enable="true" target="ServerTarget_1417052686904"/>
    <classloader xmi:id="Classloader_1417052686904" mode="PARENT_FIRST"/>
    <modules xmi:type="appdeployment:WebModuleDeployment" xmi:id="WebModuleDeployment_1417052686904" deploymentId="1" startingWeight="10000" uri="myWAR.war" containsEJBContent="0">
      <targetMappings xmi:id="DeploymentTargetMapping_1417052686905" target="ServerTarget_1417052686904"/>
      <classloader xmi:id="Classloader_1417052686905"/>
    </modules>
    <properties xmi:id="Property_1417052686904" name="metadata.complete" value="true"/>
  </deployedObject>
  <deploymentTargets xmi:type="appdeployment:ServerTarget" xmi:id="ServerTarget_1417052686904" name="server1" nodeName="[server service name]"/>
</appdeployment:Deployment>

(Since I have no reputation, I have to do it all in text.. )

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