Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Salesforce ant迁移工具时使用ant-contrib-1.0b3.jar时出现问题_Ant_Salesforce - Fatal编程技术网

使用Salesforce ant迁移工具时使用ant-contrib-1.0b3.jar时出现问题

使用Salesforce ant迁移工具时使用ant-contrib-1.0b3.jar时出现问题,ant,salesforce,Ant,Salesforce,我相信我已正确设置了所有内容,但在运行调用ANT迁移可执行文件的Powershell脚本时,出现以下错误: At C:\Users\user\Desktop\backup_script.ps1:13 char:1 + &ant "retrieveObjects" + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:String) [], RemoteException + FullyQual

我相信我已正确设置了所有内容,但在运行调用ANT迁移可执行文件的Powershell脚本时,出现以下错误:

At C:\Users\user\Desktop\backup_script.ps1:13 char:1
+ &ant "retrieveObjects"
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError   BUILD FAILED C:\Users\user\Desktop\AntCode\ant-salesforce-prgm\build.xml:63: Problem: failed to create task or type antlib:com.salesforce:retrieve 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:
        -C:\apache-ant-1.10.2\lib
        -C:\Users\user\.ant\lib
        -a directory added on the command line with the -lib argument Total time: 0 seconds
位于C:\Users\user\Desktop\backup\u script.ps1:13 char:1
+&ant“retrieveObjects”
+ ~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:NotSpecified:(:String)[],RemoteException
+FullyQualifiedErrorId:NativeCommandError生成失败C:\Users\user\Desktop\AntCode\ant salesforce prgm\BUILD.xml:63:问题:无法创建任务或类型antlib:com。salesforce:检索原因:名称未定义。措施:检查拼写。操作:检查是否已声明任何自定义任务/类型。措施:检查是否发生了任何/声明。尚未在此命名空间中定义任何类型或任务,但这似乎是一个antlib声明。操作:检查实现库是否存在于以下之一中:
-C:\apache-ant-1.10.2\lib
-C:\Users\user\.ant\lib
-在命令行中添加的带有-lib参数的目录总时间:0秒
以下是我的build.xml文件:

<project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce">
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    <property file="build.properties"/>
    <property environment="env"/>

    <!-- Setting default value for username, password and session id properties to empty string 
         so unset values are treated as empty. Without this, ant expressions such as ${sf.username}
         will be treated literally.
    -->
    <macrodef name="export">
        <attribute name="file"/>
        <attribute name="object"/>
        <attribute name="soql"/>
        <attribute name="userName"/>
        <attribute name="password"/>
        <attribute name="serverURL"/>
        <attribute name="batchSize"/>
        <attribute name="limit"/> 

        <sequential>
            <echo message="Exporting @{object}"/>
            <mkdir dir="exports/DATE"/>
            <mkdir dir="logs/DATE"/>
            <copy file="config/template-process-conf.xml" tofile="config/process-conf.xml" overwrite="true" failonerror="true"/>
            <replace file="config/process-conf.xml">
                <replacefilter token="_object_" value="@{object}"/>
                <replacefilter token="_soql_" value="@{soql}"/>
                <replacefilter token="_file_" value="exports/${todayDate_only}/@{file}.csv"/>
                <replacefilter token="_serverURL_" value="@{serverURL}"/>
                <replacefilter token="_userName_" value="@{username}"/>
                <replacefilter token="_password_" value="@{password}"/>
                <replacefilter token="_batchSize_" value="@{batchSize}"/>
                <replacefilter token="_logFile_" value="logs/DATE/@{file}_log.csv"/>
            </replace>
            <java classname="com.salesforce.dataloader.process.ProcessRunner" classpath="C:\YOUR_PATH\dataloader-39.0.0-uber.jar" failonerror="true">
                <sysproperty key="salesforce.config.dir" value="config"/>
                <arg line="process.name=@{object}"/>
            </java>
        </sequential>
    </macrodef>

    <!--
    <condition property="sf.username" value=""> <not> <isset property="sf.username"/> </not> </condition>
    <condition property="sf.password" value=""> <not> <isset property="sf.password"/> </not> </condition>
    <condition property="sf.sessionId" value=""> <not> <isset property="sf.sessionId"/> </not> </condition>

    <taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
        <classpath>
            <pathelement location="ant-salesforce.jar" />           
        </classpath>
    </taskdef>
    -->

    <!-- See what happens here -->
    <target name="retrieveObjects">
      <mkdir dir="retrieveObjects"/>
      <sf:retrieve 
          username="${sf.prod.profileName.username}" 
          password="${sf.prod.profileName.password}" 
          sessionId="${sfProd.sessionId}"
          serverurl="${sfProd.serverurl}" 
          retrieveTarget="retrieveObjects" 
          unpackaged="retrieveSource/package.xml"/>
    </target>

        <target name="foo">
        <foreach target="backup" param="file">  
            <path>
                <fileset dir="YOUR_PATH_objects" includes="**/*.object"/>
            </path>
        </foreach>
    </target>

    <target name="backup">
        <xmlproperty file="retrieveObjects/objects/Account.object" collapseAttributes="true"/> <!--this parses the xml file-->

        <export
            file="Account_backup-DATE"
            object="Account"
            soql="select ${CustomObject.fields.fullName} from Account"
            userName="${sf.prod.profileName.username}"
            password="${sf.prod.profileName.password}"
            serverURL="${sfProd.serverurl}"
            batchSize="200"
            limit = "1000" />
    </target>

</project>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>


我不确定问题发生在哪里。我将ant-contrib-1.0b3.jar文件放入以下目录:C:\apache-ant-1.10.2\lib,但这似乎无法解决问题。

这取决于您的ant版本。 您的ant contrib文件可能与正在运行的ant版本不兼容

我有一个类似的错误,它是通过使用ant-contrib-1.0b1.jar解决的。下载并解压缩它以找到其中的.jar文件

我运行的ant版本是1.10.3

此外,您还可以尝试将其添加到build.xml文件中:

<project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce">
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    <property file="build.properties"/>
    <property environment="env"/>

    <!-- Setting default value for username, password and session id properties to empty string 
         so unset values are treated as empty. Without this, ant expressions such as ${sf.username}
         will be treated literally.
    -->
    <macrodef name="export">
        <attribute name="file"/>
        <attribute name="object"/>
        <attribute name="soql"/>
        <attribute name="userName"/>
        <attribute name="password"/>
        <attribute name="serverURL"/>
        <attribute name="batchSize"/>
        <attribute name="limit"/> 

        <sequential>
            <echo message="Exporting @{object}"/>
            <mkdir dir="exports/DATE"/>
            <mkdir dir="logs/DATE"/>
            <copy file="config/template-process-conf.xml" tofile="config/process-conf.xml" overwrite="true" failonerror="true"/>
            <replace file="config/process-conf.xml">
                <replacefilter token="_object_" value="@{object}"/>
                <replacefilter token="_soql_" value="@{soql}"/>
                <replacefilter token="_file_" value="exports/${todayDate_only}/@{file}.csv"/>
                <replacefilter token="_serverURL_" value="@{serverURL}"/>
                <replacefilter token="_userName_" value="@{username}"/>
                <replacefilter token="_password_" value="@{password}"/>
                <replacefilter token="_batchSize_" value="@{batchSize}"/>
                <replacefilter token="_logFile_" value="logs/DATE/@{file}_log.csv"/>
            </replace>
            <java classname="com.salesforce.dataloader.process.ProcessRunner" classpath="C:\YOUR_PATH\dataloader-39.0.0-uber.jar" failonerror="true">
                <sysproperty key="salesforce.config.dir" value="config"/>
                <arg line="process.name=@{object}"/>
            </java>
        </sequential>
    </macrodef>

    <!--
    <condition property="sf.username" value=""> <not> <isset property="sf.username"/> </not> </condition>
    <condition property="sf.password" value=""> <not> <isset property="sf.password"/> </not> </condition>
    <condition property="sf.sessionId" value=""> <not> <isset property="sf.sessionId"/> </not> </condition>

    <taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
        <classpath>
            <pathelement location="ant-salesforce.jar" />           
        </classpath>
    </taskdef>
    -->

    <!-- See what happens here -->
    <target name="retrieveObjects">
      <mkdir dir="retrieveObjects"/>
      <sf:retrieve 
          username="${sf.prod.profileName.username}" 
          password="${sf.prod.profileName.password}" 
          sessionId="${sfProd.sessionId}"
          serverurl="${sfProd.serverurl}" 
          retrieveTarget="retrieveObjects" 
          unpackaged="retrieveSource/package.xml"/>
    </target>

        <target name="foo">
        <foreach target="backup" param="file">  
            <path>
                <fileset dir="YOUR_PATH_objects" includes="**/*.object"/>
            </path>
        </foreach>
    </target>

    <target name="backup">
        <xmlproperty file="retrieveObjects/objects/Account.object" collapseAttributes="true"/> <!--this parses the xml file-->

        <export
            file="Account_backup-DATE"
            object="Account"
            soql="select ${CustomObject.fields.fullName} from Account"
            userName="${sf.prod.profileName.username}"
            password="${sf.prod.profileName.password}"
            serverURL="${sfProd.serverurl}"
            batchSize="200"
            limit = "1000" />
    </target>

</project>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>


希望这有帮助

对钱德拉尼没有影响。还是一样的问题。我正在运行v1.10.2。有人擦掉了他的ANT安装,然后重新安装,让它正常工作。那会有帮助吗?