Search code examples
eclipseanteclipse-pluginwebspherewebsphere-liberty

Failed to create task or type antlib:com.ibm.websphere.wlp.ant:server


Following is the server configuration for WebSphere Liberty Profile:

product = WebSphere Application Server 8.5.5.1
wlp.install.dir = /opt/IBM/WebSphere/Liberty/
java.home = /root/Downloads/jre1.6.0_45
java.version = 1.6.0_45
java.runtime = Java(TM) SE Runtime Environment (1.6.0_45-b06)
os = Linux (2.6.32-431.23.3.el6.x86_64; amd64) (en_US)

I have copied "wlp-anttasks.jar" to "/opt/worklight/eclipse/plugins/org.apache.ant_1.8.4.v201303080030/lib" location and running following ant task to start the Liberty server:

<project basedir="." xmlns:wlp="antlib:com.ibm.websphere.wlp.ant">
    <property name="wl.server.home" value="/opt/IBM/WebSphere/Liberty"/>
    <property name="wl.server.name" value="WL_UAT_Server"/>

    <target name="test">
      <wlp:server id="test" installDir="${wl.server.home}" operation="start" serverName="${wl.server.name}"/>
    </target>
</project>

After Execution its giving me following error:

BUILD FAILED
/opt/UIWS/UI/Liberty.xml:6: 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:
        -/opt/worklight/eclipse/plugins/org.apache.ant_1.8.4.v201303080030/lib
        -/root/.ant/lib
        -a directory added on the command line with the -lib argument


Total time: 445 milliseconds

Let me know if ant more information is needed. I am following this link.


Solution

  • If you start your build directly from Eclipse, I believe it is not automatically adding all jars from the eclipse/plugins/org.apache.ant_1.8.4.v201303080030/lib folder. It's better to provide it manually.

    • If you want to enable that tasks for all build files in the workspace, then modify workspace properties via Window > Preferences > Ant > Runtime and add wlp-anttasks.jar as external jar to the Ant Home Entries
    • If you want to enable it just for single build file, then select build.xml, right-click Run As > Ant build ... , then switch to the Classpath tab and add wlp-anttasks.jar as external jar to the User entries

    Your build will be successful in either case.