Troubleshooting
Problem
The wsadmin command line scripting tool does not return a non-zero return code when the specified profile name (using the -profileName parameter) does not refer to an existing profile.
Symptom
The console output of running such command:
C:\WebSphere7\AppServer>cd bin
C:\WebSphere7\AppServer\bin>wsadmin -profileName abc
WCMD0003E: The specified profile "abc" cannot be found. If a default profile exists and you wish to use it, the -profileName parameter is not required.
C:\WebSphere7\AppServer\bin>echo %ERRORLEVEL%
0
Note: It should return a error code "1" instead of "0" . This problem does not occur in UNIX platforms.
Cause
In the wsadmin.bat script, the RC variable is not initialized and the code exits before it is assigned any value.
Resolving The Problem
wsadmin.bat script is being used in many parts of WebSphere Application Server code and cannot be changed in the service stream, but setting the value of RC variable in the below code snippet then you will get the desired result :
Look for the section "REM subroutine for checking if invalid profile specified" under \WAS_HOME\bin\wsadmin.bat and add entry "SET RC=1":
REM subroutine for checking if invalid profile specified.
:CHECK_INVALID_PROFILE_SPECIFIED
if defined INV_PRF_SPECIFIED (
if "%INV_PRF_SPECIFIED%"=="true" (
%JAVA_EXE% -Djava.endorsed.dirs="%WAS_ENDORSED_DIRS%" -classpath
"%WAS_HOME%\lib\commandlineutils.jar"
com.ibm.ws.install.commandline.utils.CommandLineUtils
-specifiedProfileNotExists -profileName "%WAS_PROFILE_NAME:"=%"
SET PROFILE_ERROR=1
SET RC=1
) else ( call :CHECK_WAS_USER_SCRIPT_FILE_NOT_EXISTS
)
) else ( call :CHECK_WAS_USER_SCRIPT_FILE_NOT_EXISTS
)
goto :EOF
Command console output after correction :
C:\WebSphere7\AppServer\bin>wsadmin -profileName abc
WCMD0003E: The specified profile "abc" cannot be found. If a default profile exists and you wish to use it, the -profileName parameter is not required.
C:\WebSphere7\AppServer\bin>echo %ERRORLEVEL%
1
Was this topic helpful?
Document Information
Modified date:
15 June 2018
UID
swg21586783