问题
Problem in running ant showing error Could not load definitions from resource axis-tasks.properties. It could not be found :
Here is the snapshot of build.xml on which the problem occurs
<target name="axis" depends="prepare">
<taskdef resource="axis-tasks.properties"/>
<axis-wsdl2java url="${webconsole.base}/src/myservice.wsdl"
output="${axis.output}">
<mapping
namespace="urn:myservice"
package="com.company.service" />
<mapping
namespace="http://webserviceurl.com"
package="com.company.service" />
</axis-wsdl2java>
</target>
When running ant shows following errors :
/build.xml:76: Problem: failed to create task or type axis-wsdl2java
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.
Environment properties :
export TMPDIR=$HOME/tmp
export RELEASE=$HOME/Release
export JAVA_HOME=/usr/java/current
export ANT_HOME=/usr/local/apache-ant-1.6.5
export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
Additional information
Actually, we have two build machines. First one has only root user and we have created /home/user folders manually e.g. /home/rajan etc. In this machine when we run ant as root from /home/rajan/R7_SP1_UTF8/vermaraj_R7_SP1/vobs/project/ip_src/AdminWebConsole ant works properly.
echo $PATH = /usr/java/current/bin:/usr/local/apache-ant-1.6.5/bin:/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
On the second machine, we have created individual user accounts and when we try and run ant either as root or rajan from /home/rajan/R7_SP1_UTF8/vermaraj_R7_SP1/vobs/project/ip_src/AdminWebConsole ant does not works properly.
echo $PATH : /usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Also, in both the build machines echo $CLASSPATH is empty
locate axis-ant.jar gives output as :
- /home/Rajan/R7_SP1_UTF8/vermaraj_R7_SP1/vobs/project/ip_src/AdminWebConsole/lib/axis-ant.jar
- /home/Rajan/R7_SP1_UTF8/vermaraj_R7_SP1/vobs/project/ip_src/AdminWebConsole/output/war/WEB-INF/lib/axis-ant.jar
- /usr/local/apache-ant-1.6.5/lib/axis-ant.jar
ivy is not an option as this is part of very big code base, it may create problems if we add additional libraries.
回答1:
The ANT task does appear to have a complex set of dependencies. I would recommend adding the ivy extension to manage these.
Example
├── build.xml
├── src
│ └── myservice.wsdl
└── target
└── output
└── com
└── examples
└── www
└── wsdl
└── HelloService_wsdl
├── Hello_BindingStub.java
├── Hello_PortType.java
├── Hello_Service.java
└── Hello_ServiceLocator.java
build.xml
<project name="demo" default="axis" xmlns:ivy="antlib:org.apache.ivy.ant">
<!--
================
Build properties
================
-->
<property name="build.dir" location="target"/>
<property name="axis.output" location="${build.dir}/output"/>
<available classname="org.apache.ivy.Main" property="ivy.installed"/>
<!--
===========
Targets
===========
-->
<target name="install-ivy" description="Install ivy" unless="ivy.installed">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar"/>
<fail message="Ivy has been installed. Run the build again"/>
</target>
<target name="resolve" depends="install-ivy" description="Use ivy to resolve classpaths">
<ivy:cachepath pathid="build.path">
<dependency org="org.apache.axis" name="axis-ant" rev="1.4" />
<dependency org="org.apache.axis" name="axis" rev="1.4" />
<dependency org="org.apache.axis" name="axis-jaxrpc" rev="1.4"/>
<dependency org="commons-logging" name="commons-logging" rev="1.1.1" />
<dependency org="commons-discovery" name="commons-discovery" rev="0.4" />
<dependency org="wsdl4j" name="wsdl4j" rev="1.6.2" />
</ivy:cachepath>
</target>
<target name="axis" depends="resolve" description="Run Axis task">
<taskdef resource="axis-tasks.properties" classpathref="build.path"/>
<mkdir dir="${axis.output}"/>
<axis-wsdl2java url="src/myservice.wsdl" output="${axis.output}">
<mapping namespace="urn:myservice" package="com.company.service" />
<mapping namespace="http://webserviceurl.com" package="com.company.service" />
</axis-wsdl2java>
</target>
<target name="clean" description="Clean workspace">
<delete dir="${build.dir}"/>
</target>
<target name="clean-all" depends="clean" description="Purge ivy cache">
<ivy:cleancache/>
</target>
</project>
回答2:
axis-task.properties is part of axis-ant.jar, but it is not available for ant :/build.xml:76: Problem: failed to create task or type axis-wsdl2java
it need's to be on ant classpath.
A simple way - but not recommended - is to put all axis jars in ANT_HOME/lib but that will pollute the ant core installation. Better put in it's own path as described here on axis.apache.org
Another way is to put all your ant addon libraries or third party jars in a special folder and make it available for ant via ANT_ARGS environment variable.
Either put this line in ANT_HOME/bin/ant.sh :
ANT_ARGS="-lib /usr/local/ant_xtralibs:/usr/local/ant_testlibs"
export ANT_ARGS
or create your own startscript as described here
来源:https://stackoverflow.com/questions/25058098/ant-command-showing-error-while-execution-resource-axis-tasks-properties-could