为什么weblogic不使用我的部署计划?

时间:2012-05-15 10:54:35

标签: java java-ee weblogic

我在尝试调整weblogic中应用程序的部署设置时遇到了一些麻烦。我觉得我想要做的事情应该很简单,但它没有按预期工作。

我只是试图覆盖weblogic.xml中的context-root和数据源的JNDI名称,因此可以在部署时配置它们。

我已经从ear文件中删除了application.xml,因此不应该影响覆盖。

到目前为止我所拥有的:

weblogic.xml中:

<context-root>mosaic</context-root>

<resource-description>
  <res-ref-name>jdbc/LogicalDS</res-ref-name>
  <jndi-name>LogicalDS</jndi-name>
</resource-description>

的web.xml

<resource-ref>
  <description>A logical reference to the datasource - mapped in deployment plan</description>
  <res-ref-name>jdbc/LogicalDS</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>

plan.xml中

<?xml version="1.0" encoding="UTF-8"?>
 <wls:deployment-plan xmlns:wls="http://xmlns.oracle.com/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd" global-variables="true">
 <!--weblogic-version:10.3.5-->
 <wls:application-name>mosaic.ear</wls:application-name>
 <wls:variable-definition>
    <wls:variable>
        <wls:name>datasource_name</wls:name>
        <wls:value xsi:nil="true"></wls:value>
        <wls:description>The name of the datasource to map to the mosaic application</wls:description>
    </wls:variable>
    <wls:variable>
        <wls:name>new_context_root</wls:name>
        <wls:value xsi:nil="true"></wls:value>
        <wls:description>URL to deploy Mosaic at</wls:description>
    </wls:variable>
 </wls:variable-definition>
<wls:module-override>
    <wls:module-name>mosaic.war</wls:module-name>
    <wls:module-type>war</wls:module-type>
    <wls:module-descriptor>
        <wls:root-element>weblogic-web-app</wls:root-element>
        <wls:uri>WEB-INF/weblogic.xml</wls:uri>
        <wls:variable-assignment>
            <wls:name>new_context_root</wls:name>
            <wls:xpath>/weblogic-web-app/context-root</wls:xpath>
            <wls:operation>replace</wls:operation>
        </wls:variable-assignment>
        <wls:variable-assignment>
            <wls:description>Data source for mosaic application</wls:description>
            <wls:name>datasource_name</wls:name>
            <wls:xpath>/weblogic-web-app/resource-env-description/resource-env-ref-name</wls:xpath>
            <wls:operation>replace</wls:operation>
        </wls:variable-assignment>
        <wls:variable-assignment>
            <wls:name>datasource_name</wls:name>
            <wls:xpath>/weblogic-web-app/resource-description/[res-ref-name="jdbc/LogicalDS"]/jndi-name</wls:xpath>
            <wls:operation>replace</wls:operation>
        </wls:variable-assignment>
    </wls:module-descriptor>
  </wls:module-override>
</wls:deployment-plan>

使用部署计划时没有任何反应,管理控制台中的部署计划配置屏幕下不会显示任何变量。根据我的理解,我至少应该被要求提供这些变量,因为我已经指定它们在部署计划中为空。

当我使用WLST浏览树时,我发现运行时配置只是作为部署描述符中的值保留。

我已验证部署计划正在管理控制台的常规选项卡中使用。

任何人都可以帮助我找出我在这里做错了吗?

1 个答案:

答案 0 :(得分:3)

我看到你有两次“datasource_name”变量替换。这是有意的吗?您的xpath似乎不正确:

资源描述/ [RES-REF-名称= 等

应该是:

资源描述[RES-REF-名称= 等

我的建议是在时间上改变一件事,例如,首先改变Web应用程序上下文,然后进行测试。 Web应用程序上下文也可以在管理控制台中设置,因此您应该在那里看到值。

关于部署计划的文章很少:

https://blogs.oracle.com/jamesbayer/entry/11gr1_update_and_a_deployment

http://m-button.blogspot.com/2008/08/how-to-use-deployment-plan.html

良好的资源映射文档:

http://docs.oracle.com/cd/E15523_01/web.1111/e13737/packagedjdbc.htm  (查看底部附近的图表。)

您的变量是“替换”还是“定义”?

相关问题