When trying to execute a wsadmin command using ant you might get the error

Unable to parse setupCmdLine: null\bin\setupCmdLine.bat  (The system cannot find the path specified)

This error is caused when you don’t provide the user.install.root system property or no wsadmin task profileName property.

In order to fix you can either add a user.install.root property and point it to your websphere profile directory (in default installations e.g. AppSrv01)
or you can just add a profileName attribute to the wsadmin task. In this case the wsadmin task resolves the profile directory for you, because of the wasHome attribute that you must provide.

The analyse of the error

Reproduce the error

Before we dive into the analyse we need an example project to reproduce the error. For this we need a simple ant script.

<?xml version="1.0" encoding="iso-8859-1" ?>
<project name="errorAnalyse" default="listApps" basedir=".">
	<property name="hostName" value="localhost" />
	<property name="connType" value="SOAP" />
	<property name="connPort" value="8880" />
	<property name="wasHome.dir" value="C:/IBM/WebSphere/AppServer" /> <!-- SET THIS PROPERTY TO YOUR WAS INSTALL ROOT -->

	<taskdef name="wsListApps" classname="com.ibm.websphere.ant.tasks.ListApplications" classpath="${wasHome.dir}/plugins/com.ibm.ws.runtime.jar" />

	<target name="listApps">
		<wsListApps wasHome="${wasHome.dir}" />
	</target>
</project>

So if we run this script we get something like this

Buildfile: C:\errorAnalyse\test-ant.xml
listApps:
Unable to parse setupCmdLine: null\bin\setupCmdLine.bat (The system cannot find the path specified.)
  [wsadmin] WSVR0719E
  [wsadmin] C:\IBM\WebSphere\AppServer\%USER_INSTALL_ROOT%\configuration\1403763498222.log
  [wsadmin] ERROR: An exception occurred while starting Eclipse: See the log file C:\IBM\WebSphere\AppServer\%USER_INSTALL_ROOT%\configuration\1403763498222.log
BUILD SUCCESSFUL
Total time: 1 second

 Go into the depth

To understand the error one must understand how the wsadmin ant tasks work.

The wsadmin ant tasks do the follwoing:

  1. Validate ant-properties (e.g. conntype, host, etc.)
  2. Parse the setupCmdLine.bat or  setupCmdLine.sh  located in the profile’s bin directory to extract environment settings (e.g. JAVA_HOME, WAS_HOME, etc.)
  3. Create command line arguments for a new java process
  4. Create a new java process based on the main class com.ibm.wsspi.bootstrap.WSPreLauncher and pass it the arguments created before
  5. The WSPreLauncher application itself build a command line for a headleass eclipse application and runs it

The problem arises in step 2 when the wsadmin ant task tries to parse the setupCmdLine.bat or setupCmdLine.sh. The wsadmin ant task delegates the parsing to the com.ibm.ws.ant.utils.WasUtils class.

This class tries to resolve the user install root in the following way:

  1. If the WasUtils property profileHome is set then take it’s value
  2. If the ant project defines a property user.install.root than take it’s value
  3. If a system property named user.install.root exists than take it’s value

If none of these locations define a user install root than the error

Unable to parse setupCmdLine: null\bin\setupCmdLine.bat (The system cannot find the path specified.)

occurs.

Since the WasUtils gets all values from the WasAdmin task there is a mapping between the WasAdmin task’s property profileName and the profileHome property of the WasUtils.

Options to make it work

Use the wsadmin tasks profileName property.

<?xml version="1.0" encoding="iso-8859-1" ?>
<project name="errorAnalyse" default="listApps" basedir=".">
	<property name="hostName" value="localhost" />
	<property name="connType" value="SOAP" />
	<property name="connPort" value="8880" />
	<property name="wasHome.dir" value="C:/Dev/IBM/WebSphere/AppServer" />

	<taskdef name="wsListApps" classname="com.ibm.websphere.ant.tasks.ListApplications" classpath="${wasHome.dir}/plugins/com.ibm.ws.runtime.jar" />

	<target name="listApps">
		<wsListApps 
                    wasHome="${wasHome.dir}" 
                    profileName="AppServ01" <!-- Change the profileName to your profile's name if necessary -->
                /> 
	</target>
</project>

User the ant property user.install.root

<?xml version="1.0" encoding="iso-8859-1" ?>
<project name="errorAnalyse" default="listApps" basedir=".">
	<property name="hostName" value="localhost" />
	<property name="connType" value="SOAP" />
	<property name="connPort" value="8880" />
	<property name="wasHome.dir" value="C:/Dev/IBM/WebSphere/AppServer" />

	<property name="user.install.root" value="${wasHome.dir}/profiles/AppSrv01" /><!-- Change the profileName to your profile's name if necessary -->

	<taskdef name="wsListApps" classname="com.ibm.websphere.ant.tasks.ListApplications" classpath="${wasHome.dir}/plugins/com.ibm.ws.runtime.jar" />

	<target name="listApps">
		<wsListApps wasHome="${wasHome.dir}"  />
	</target>
</project>

Provide the user.install.root as  java system property

> ant -Duser.install.root=<path to your profile>