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

时间:2011-07-25 01:09:42

标签: java java-ee websphere

我正在使用JSF2和Websphere 7。我已成功创建了一个共享库,并使用Webpsphere管理控制台指向了应用程序,并且它可以成功运行。但我们真正想做的是不必通过WAS管理控制台指向共享库,而是具有某种应用程序级别配置,例如在deployment.xml等中,我们可以指向共享孤立库的名称并使用它。我已经通过SO和谷歌,但没有发现任何事情这样做。然而,我知道有商业应用程序在做,但不知道如何。
来自How can I specify a shared library reference at the web module level in Websphere 6.1 deployment descriptors?的这个问题与我所追求的非常相似,但我不想指定版本号或罐子名称作为答案状态

3 个答案:

答案 0 :(得分:9)

我只是按照WAS管理员控制台实际执行的操作找到了一种方法。

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

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

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

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

@dbreaux也表现出了一种方式。我自己的答案更适合我的需求,但也非常感谢dbreaux的建议。

答案 1 :(得分:4)

问题只是您不想单独配置每个应用程序,或者您根本不想使用管理控制台?你可以associate a shared library with an entire server,这可能比为每个应用程序更好。

创建这些应用程序关联的另一种方法是在特定于WebSphere的.xmi部署文件中。这些是在部署时创建的,但也可以包含在WAR / EAR文件中。我不知道这对你有帮助。如果可以的话,提前创建它们的官方方法是使用Deployment Tools之一,但由于它们只是XML,您可能会觉得手动创建它们很舒服。

答案 2 :(得分:2)

在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 \细胞\ defaultCell \应用\ defaultApp \部署\ 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>

(由于我没有声誉,我必须在文本中完成所有工作..)