5

Wondering if someone can help me with this. I'm trying to delete some components with the migration tool (Ant).

However when I try to deploy, I'm getting the following error:

    *********** DEPLOYMENT FAILED ***********
Request ID: 0Af2400000stDKJCA2

All Component Failures:
1.  package.xml -- Error: Bad file:Unexpected element {http://soap.sforce.com/2006/04/metadata}members during simple type deserialization

*********** DEPLOYMENT FAILED ***********


Total time: 2 seconds

Here is package.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>codepkg</fullName>
    <version>35.0</version>
</Package>

This is the sample package.xml for undeploying code that comes bundled with the Migration Tool.

Here is destructiveChanges.xml:

    <?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>MyClass</members>
        <name>ApexClass</name>
    </types>
    <version>33.0</version>
</Package>

Both files are in the same directory.

I also get the same error message when deploying the same files with the Dev. Workbench:

workbench error

Now if I remove this line from package.xml:

<fullName>codepkg</fullName>

I still get the same error.

Can anyone shed some light on what I'm doing wrong here?

9
  • do you have both files in same directory. because error system no package.xml found
    – Himanshu
    Commented Nov 4, 2015 at 18:18
  • update this question with your destructiveChanges.xml +package.xml
    – Himanshu
    Commented Nov 4, 2015 at 18:23
  • I've added destructiveChanges.xml to my post, package.xml was already there. Both files are indeed in the same directory. Commented Nov 4, 2015 at 18:40
  • I feel its some version conflict ..Can you change your ANT version and also keep package.xml and destructive with same version. Commented Nov 4, 2015 at 20:26
  • Ant & Migration tool are the latest versions, all XML files are on API V35. Tried with V33, same result. Commented Nov 4, 2015 at 21:33

4 Answers 4

1

Sorry if you find this overKill (This will retrieve all items from your org and remove them)

The way i have gotten mine to work (This is for a full dev operation and will be overkill if you know all the information needed, However if you do not know all of the data by name this will work. It will just take some time to run) is with a several stage deploy undeploy check, First i generate a package.xml for all items within a org. using the wildcard *

Here is what mine looks like (CUT DOWN VERSION) (Package.xml)

<echo file="purge/package.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
            <Package xmlns="http://soap.sforce.com/2006/04/metadata">
            <types><members>*</members><name>ApexClass</name></types>
            <types><members>*</members><name>ApexPage</name></types>
            <types><members>Opportunity.BatchProcess__c</members><name>CustomField</name></types>
            <types><members>*</members><name>CustomField</name></types>
            <types><members>*</members><name>CustomLabel</name></types>
            <types><members>*</members><name>CustomLabels</name></types>
            <types><members>*</members><name>CustomObject</name></types>
            <version>34.0</version>
            </Package>
        ]]></echo>

then you will want to replace the package definition like so

 <replace file="purge/package.xml">
        <replacetoken><![CDATA[</version>]]></replacetoken>
        <replacevalue><![CDATA[</version><fullName>Purge</fullName>]]></replacevalue>
    </replace>

Now you will want to re-deploy the wildcard package definition

<sf:deploy
        username="${sf.username}"
        password="${sf.password}"
        serverurl="https://login.salesforce.com"
        deployRoot="purge"
        purgeOnDelete="true"
        pollWaitMillis="1000" />

Next you will want to retrieve by name (This will give you your explicit package definition, You can skip all the above if you have this information already)

    <sf:retrieve
    username="${sf.username}"
    password="${sf.password}"
    serverurl="https://login.salesforce.com"
    retrieveTarget="purge"
    packageNames="Purge"
    pollWaitMillis="1000" />

You can trash all local components retrieved from this.

<delete includeEmptyDirs="true" dir="purge" includes="**/*" excludes="*.xml" />
        <copy file="purge/package.xml" tofile="purge/destructiveChanges.xml" />
        <echo file="purge/package.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
            <Package xmlns="http://soap.sforce.com/2006/04/metadata">
            <version>29.0</version>
            </Package>
        ]]></echo>

Now you can deploy your explicate deploy over the top of the org. This will delete everything.

    <sf:deploy
    username="${sf.username}"
    password="${sf.password}"
    serverurl="https://login.salesforce.com"
    deployRoot="purge"
    purgeOnDelete="true"
    pollWaitMillis="10000" />

The above will get you removing all items from the org, You can write in ignore rules if you wish.

To me you above error of members is referencing your Package.XML where you have not told it about any Members Or Types. I would add

<types><members>*</members><name>ApexClass</name></types>

just to rule that out. But this will get you running.

0

Have you tried removing the codepkg line from package.xml?

According to the Migration Tool Guide:

To deploy the destructive changes, you must also have a package.xml file that lists no components to deploy, includes the API version, and is in the same directory as destructiveChanges.xml:

<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <version>34.0</version> </Package>

1
  • Yes, even when removing this line I still get the same error. Commented Nov 5, 2015 at 8:59
0

I'm getting the same error even though destructivechanges+package.xml and build.xml are in different directories. ll Component Failures: 1. package.xml -- Error: Bad file:Unexpected element {http://soap.sforce.com/2006/04/metadata}members during simple type deserialization

*********** DEPLOYMENT FAILED ***********

    at com.salesforce.ant.DeployTask.logFailedDeploy(DeployTask.java:178)
    at com.salesforce.ant.DeployTask.handleResponse(DeployTask.java:150)
    at com.salesforce.ant.SFDCMDAPIAntTaskRunner.runTask(SFDCMDAPIAntTaskRunner.java:92)
    at com.salesforce.ant.DeployTask.execute(DeployTask.java:63)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
    at org.apache.tools.ant.Main.runBuild(Main.java:857)
    at org.apache.tools.ant.Main.startAnt(Main.java:236)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)

Can someone please help.

Best Regards Anand

-3

Thanks for all your input guys, much appreciated.

It turns out that the problem was that package.xml & destructiveChanges.xml were located in the same directory as build.xml.

Quite a bizarre one, but as soon as I moved package.xml & destructiveChanges.xml to their own directory and pointed the undeploy target to this directory the deployment successfully deleted the components listed in destructiveChanges.xml.

Marking this post as the answer in order to close off the question, thanks again for all the help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .