0

只是尝试在 IBM RAD\RSA 8 中运行 ANT 脚本以部署到 websphere 。使用 WS_ANT.bat 从命令提示符运行时它工作正常,但在 RAD 内部失败并出现以下错误

Unable to determine WAS Home directory. Please use the wasHome task attribute or set the was.root System property.

以下是从 SO 复制并再次修改的基本 ANT 脚本从 WS_ANT 但不能从 RAD 正常运行

<?xml version="1.0"?>
<projectname="project"default="wasListApps"basedir=".">
        <description>
        Script for listing installed apps.
        Example run from:
        /opt/IBM/SDP70/runtimes/base_v61/profiles/AppSrv01/bin
    </description>

        <propertyname="was_home"location="C:\Program Files\ibm\SDP80\runtimes\base_v7"/>       

        <pathid="was.runtime">
                <filesetdir="${was_home}/lib">
                        <includename="**/*.jar"/>
                </fileset>
                <filesetdir="${was_home}/plugins">
                        <includename="**/*.jar"/>
                </fileset>
        </path>
        <propertyname="was_cp"value="${toString:was.runtime}">
        </property>
        <propertyname="was_server"value="server1"/>
        <propertyenvironment="env">
        </property>

        <targetname="wsStopServer">
                <taskdefname="wsStopServer"classname="com.ibm.websphere.ant.tasks.StopServer"classpath="${was_cp}">
                </taskdef>
                <wsStopServerserver="${was_server}"failonerror="false"/>
        </target>

        <targetname="wsStartServer" depends="wsStopServer">
                        <taskdefname="wsStartServer"classname="com.ibm.websphere.ant.tasks.StartServer"classpath="${was_cp}">
                        </taskdef>
                        <wsStartServerserver="${was_server}"failonerror="true"/>
                </target>


        <targetname="wasListApps"depends="wsStartServer">
                <taskdefname="wsListApp"classname="com.ibm.websphere.ant.tasks.ListApplications"classpath="${was_cp}">
                </taskdef>
                <wsListAppwasHome="${was_home}"/>
        </target>

</project>
4

1 回答 1

0

如果您查看ws_ant.bat文件,您会发现它首先调用setupCmdLine.bat,您猜对了,设置命令行。该文件尝试通过将WAS_HOME环境变量设置为父目录来确定它。

SET CUR_DIR=%cd%
cd /d "%~dp0.."
SET WAS_HOME=%cd%
cd /d "%CUR_DIR%"

当您从命令行运行时,这很好。您通常位于 ~/SDP/runtimes/base_v7/bin(或其他服务器版本)目录中。父母是你想去的地方。

当您运行 ws_ant.bat 脚本时,我会考虑设置工作目录。这可能是最可能的原因。

于 2011-08-22T15:49:49.693 回答