When I try to start Apache Axis2 standalone server on Windows, the console stops printing at "Using AXIS2_HOME path\to\axis2" and the server does not start:
C:\Users\me>%AXIS2_HOME%\bin\axis2server.bat
Using JAVA_HOME C:\Users\me\Software\Oracle\Java\jdk-24.0.1
Using AXIS2_HOME C:\Users\me\Software\Apache\Axis2\axis2-2.0.0
C:\Users\me>
Version information:
- Windows 11
- Java JDK 24.0.1
- Apache Axis2 2.0.0
I've set up Axis2 according to the "Installing Axis2 as a Standalone Server using the Standard Binary Distribution" section in https://axis.apache.org/axis2/java/core/docs/installationguide.html.
I started Axis2 standalone server by running the following command in Command Prompt:
%AXIS2_HOME%\bin\axis2server.bat
I have checked to ensure that both %AXIS2_HOME% and %JAVA_HOME% point to the correct location.
In https://instantkhichri.blogspot.com/2016/02/how-to-start-apache-axis2-standalone.html?m=1, the possible reason mentioned for Axis2 server failing to start was incompatibility between Axis2 and Java versions. Hence, I have tried using all the LTS JDK versions down to JDK 8, but the same problem still occurred.
This problem occurs when Axis2 is installed in a directory with a longer path than what Axis2 expects. This results in one of the commands in axis2server.bat
(in %AXIS2_HOME%\bin\
) exceeding the length limit at runtime.
The problem command (at line 108):
"%_JAVACMD%" %JAVA_OPTS% -cp "!AXIS2_CLASS_PATH!" org.apache.axis2.kernel.SimpleAxis2Server %AXIS2_CMD_LINE_ARGS%
The AXIS2_CLASS_PATH
environment variable contains the paths to all the .jar
files in the %AXIS2_HOME%\lib\
directory. If the %AXIS2_HOME%
path is too long, then AXIS2_CLASS_PATH
will be too long, causing the above command to exceed the length limit. This causes the command to be evaluated as a blank command and not be executed.
I would like to suggest three possible solutions.
This solution is a quick and easy fix that should work for most users. However, for users who would like to keep their software files organized into designated directories, consider Solution 2
instead.
Move your Axis2 installation directory to a shorter path. For example, C:\axis2
.
Update %AXIS2_HOME%
accordingly.
In Command Prompt, start the Axis2 standalone server using the command:
%AXIS2_HOME%\bin\axis2server.bat
In your browser, visit http://localhost:8080/axis2/services/ to verify that the server is running.
axis2server.bat
to Replace AXIS2_CLASS_PATH
Concatenation With %AXIS2_HOME%\lib\*
WildcardThis solution involves editing the axis2server.bat
file (in %AXIS2_HOME%\bin\
) to replace the "for" loop concatenation logic (for storing the paths to all the .jar
files in the AXIS2_CLASS_PATH
environment variable) with the wildcard %AXIS2_HOME%\lib\*
to represent all the .jar
files in the %AXIS2_HOME%\lib\
directory.
Consider creating a backup file axis2server.bat.backup
before proceeding.
In axis2server.bat
, replace the following lines (originally at lines 101-102):
set AXIS2_CLASS_PATH=%AXIS2_HOME%;%AXIS2_HOME%\conf;%JAVA_HOME%\lib\tools.jar;
FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c
With the following line:
set AXIS2_CLASS_PATH=%AXIS2_HOME%;%AXIS2_HOME%\conf;%JAVA_HOME%\lib\tools.jar;%AXIS2_HOME%\lib\*
In Command Prompt, start the Axis2 standalone server using the command:
%AXIS2_HOME%\bin\axis2server.bat
In your browser, visit http://localhost:8080/axis2/services/ to verify that the server is running.
axis2server.bat
to Replace AXIS2_CLASS_PATH
Environment Variable With a .txt
FileSince this solution is more complicated, Solution 2
is preferred.
This solution involves editing the axis2server.bat
file (in %AXIS2_HOME%\bin\
) to use a .txt
file instead of the AXIS2_CLASS_PATH
environment variable to store the paths to all the .jar
files in the %AXIS2_HOME%\lib\
directory.
Consider creating a backup file axis2server.bat.backup
before proceeding.
In axis2server.bat
, replace the following lines (originally at lines 100-102):
setlocal EnableDelayedExpansion
set AXIS2_CLASS_PATH=%AXIS2_HOME%;%AXIS2_HOME%\conf;%JAVA_HOME%\lib\tools.jar;
FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c
With the following two lines:
<nul set /p=%AXIS2_HOME%;%AXIS2_HOME%\conf;%JAVA_HOME%\lib\tools.jar>%AXIS2_HOME%\lib\_axis2classpath.txt
FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO <nul set /p=;%%c>>%AXIS2_HOME%\lib\_axis2classpath.txt
The first line is a command that initializes _axis2classpath.txt
(in %AXIS2_HOME%\lib\
) with the following content (without a newline):
%AXIS2_HOME%;%AXIS2_HOME%\conf;%JAVA_HOME%\lib\tools.jar
The second line is a command that appends the paths to all the .jar
files in the %AXIS2_HOME%\lib\
directory to _axis2classpath.txt
(without newlines).
In axis2server.bat
, replace the following line (originally at line 108):
"%_JAVACMD%" %JAVA_OPTS% -cp "!AXIS2_CLASS_PATH!" org.apache.axis2.kernel.SimpleAxis2Server %AXIS2_CMD_LINE_ARGS%
With the following line:
"%_JAVACMD%" %JAVA_OPTS% -cp "@%AXIS2_HOME%\lib\_axis2classpath.txt" org.apache.axis2.kernel.SimpleAxis2Server %AXIS2_CMD_LINE_ARGS%
!AXIS2_CLASS_PATH!
has been replaced with @%AXIS2_HOME%\lib_axis2classpath.txt
, so that instead of using the environment variable AXIS2_CLASS_PATH
, the value read from _axis2classpath.txt
is used. This prevents the command from reaching the length limit.
In Command Prompt, start the Axis2 standalone server using the command:
%AXIS2_HOME%\bin\axis2server.bat
In your browser, visit http://localhost:8080/axis2/services/ to verify that the server is running.