无法从命令行启动Liberty配置文件:无法创建任务或键入antlib:com.ibm.websphere.wlp.ant:server

时间:2014-11-20 23:24:53

标签: ant websphere-8 websphere-liberty

我正在尝试启动WebSphere Liberty配置文件服务器(名为WL_UAT_Server)

<project basedir="." default="help" name="myProject" xmlns:wlp="antlib:com.ibm.websphere.wlp.ant">
      <target name="liberty-start">
        <wlp:server id="test" installDir="/opt/IBM/WebSphere/Liberty" operation="start" serverName="WL_UAT_Server"/>
      </target>
</project>

来自以下命令:

ant -f /opt/myProject/build.xml "liberty-start"

但系统发出以下错误:

/opt/myProject/build.xml:144: Problem: failed to create task or type antlib:com.ibm.websphere.wlp.ant:server
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet

This appears to be an antlib declaration. 
Action: Check that the implementing library exists in one of:
        -/usr/share/ant/lib
        -/home/root/.ant/lib
        -a directory added on the command line with the -lib argument


Total time: 2 seconds

跟随ant -diagonstics命令的输出

------- Ant诊断报告-------     Apache Ant版本1.7.1于2010年4月26日编译

-------------------------------------------
 Implementation Version
-------------------------------------------
core tasks     : 1.7.1
optional tasks : not available

-------------------------------------------
 ANT PROPERTIES
-------------------------------------------
ant.version: Apache Ant version 1.7.1 compiled on April 26 2010
ant.java.version: 1.6
ant.core.lib: /usr/share/java/ant-1.7.1.jar
ant.home: /usr/share/ant

-------------------------------------------
 ANT_HOME/lib jar listing
-------------------------------------------
ant.home: /usr/share/ant
ant.jar (1339582 bytes)
ant-launcher.jar (12243 bytes)
ant-bootstrap.jar (19013 bytes)
wlp-anttasks.jar (43990 bytes)

-------------------------------------------
 USER_HOME/.ant/lib jar listing
-------------------------------------------
user.home: /root
No such directory.

感谢任何帮助。

2 个答案:

答案 0 :(得分:2)

我在ant 1.7.1上测试了以下构建文件,它运行正常。 如果我从wlp-anttasks.jar文件夹中删除ant\lib,则会收到您的错误消息。 所以仔细检查,如果文件在那里并且可读 - 正确的权限?也许你正在运行来自不同用户的构建?或者您可能无法访问Liberty或服务器文件夹?

检查同一用户是否可以使用以下命令从命令行启动服务器:

C:\IBM\WebSphere\wlp\bin>server start WLP_UAT_Server
Starting server WLP_UAT_Server.
Server WLP_UAT_Server started.

这是我的build.xml文件

<project name="libertyTest" default="start-server" xmlns:wlp="antlib:com.ibm.websphere.wlp.ant">
    <description>
            description
    </description>
    <!-- set global properties for this build -->
      <property name="wlp_install_dir" value="C:/IBM/WebSphere/wlp"/>
      <property name="serverName" value="WLP_UAT_Server"/>

    <target name="start-server" description="description">
        <wlp:server id="wlp.ant.test" installDir="${wlp_install_dir}" operation="start" serverName="${serverName}" />
        <wlp:server ref="wlp.ant.test" operation="status"/>
    </target>

    <target name="stop-server" description="description">
            <wlp:server id="wlp.ant.test" installDir="${wlp_install_dir}" operation="stop" serverName="${serverName}" />
    </target>
</project>

诊断中的Ant属性:

-------------------------------------------
 ANT PROPERTIES
-------------------------------------------
ant.version: Apache Ant version 1.7.1 compiled on June 27 2008
ant.java.version: 1.6
ant.core.lib: C:\install\apache-ant-1.7.1\lib\ant.jar
ant.home: C:\install\apache-ant-1.7.1\bin\..

答案 1 :(得分:0)

您似乎错过了将wlp-anttasks.jar复制到$ANT_HOME/lib目录中的步骤。或者,如果您不想更改您的ant安装,则可以使用 加载Liberty任务的typedef任务,例如:

<typedef resource="net/wasdev/wlp/ant/antlib.xml" 
       uri="antlib:net.wasdev.wlp.ant" 
       classpath="somewhere/wlp-anttasks.jar"/>