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.

So if we run this script we get something like this

 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

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.

User the ant property user.install.root

Provide the user.install.root as  java system property