Prerak Tiwari
Prerak Tiwari

Reputation: 3466

Unable to start Liberty Profile from Command Line : failed to create task or type antlib:com.ibm.websphere.wlp.ant:server

I am trying to start WebSphere Liberty profile server (named 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>

from following command:

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

but system is giving following error:

/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

following the the output of ant -diagonstics command

------- Ant diagnostics report ------- Apache Ant version 1.7.1 compiled on April 26 2010

-------------------------------------------
 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.

Any help is appreciated.

Upvotes: 0

Views: 1217

Answers (2)

Gas
Gas

Reputation: 18020

I've tested the following build file on ant 1.7.1 and it works fine. I'm getting your error, if I remove wlp-anttasks.jar from ant\lib folder. So double check, if the file is there and is readable - correct permissions? Maybe you are running build from different user? Or maybe you don't have access to Liberty or server folder?

Check, if the same user can start server from command line using:

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

Here is my build.xml file

<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 properties from diagnostics:

-------------------------------------------
 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\..

Upvotes: 2

Holly Cummins
Holly Cummins

Reputation: 11482

It looks like you've missed the step of copying the wlp-anttasks.jar into your $ANT_HOME/lib directory. Alternatively, if you don't want to alter your ant installation, you can use the typedef task to load the Liberty tasks, for example:

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

Upvotes: 0

Related Questions