Code I/O

A topnotch WordPress.com site


Leave a comment

5 Minutes on Java : Metro Web Services – solution for wsimport failure

There is a bug in wsimport (command line wrapper).  It throws an exception “Failed to load Main-Class manifest attribute …” because the wsimport script is faulty.

 

It is acknowledged as a bug, however, I didn’t see a fix in the latest build I downloaded.  Here are the modifications to the wrapper script (.bat) file to temporarily resolve this issue.

 

The key change is in line 1, JDK path and the METRO_LIB (classpath) changes in line 28.

 

set JAVA_HOME=<PATH_TO_JDK1.7>

rem
rem Infer METRO_HOME if not set
rem
if not "%METRO_HOME%" == "" goto CHECKJAVAHOME

rem Try to locate METRO_HOME
set METRO_HOME=%~dp0
set METRO_HOME=%METRO_HOME%..
if exist %METRO_HOME%libwebservices-tools.jar goto CHECKJAVAHOME

rem Unable to find it
echo METRO_HOME must be set before running this script
goto END

:CHECKJAVAHOME
if not "%JAVA_HOME%" == "" goto USE_JAVA_HOME

set JAVA=java
goto LAUNCH

:USE_JAVA_HOME
set JAVA="%JAVA_HOME%binjava"
goto LAUNCH

:LAUNCH
set METRO_LIB=%METRO_HOME%libstax-api.jar;%METRO_HOME%libwebservices-api.jar;%METRO_HOME%libwebservices-extra.jar;%METRO_HOME%libwebservices-extra-api.jar;%METRO_HOME%libwebservices-rt.jar;%METRO_HOME%libwebservices-tools.jar

REM %JAVA% -classpath %METRO_LIB% %WSIMPORT_OPTS% -jar "%METRO_HOME%libwebservices-tools.jar" %*
%JAVA% -classpath %METRO_LIB% %WSIMPORT_OPTS% com.sun.tools.ws.WsImport %*

:END
%COMSPEC% /C exit %ERRORLEVEL%
Advertisements