Issue
I am just trying to get a sample web service to work using Apache Tomcat 9, Axis2 and Ant. I am following https://axis.apache.org/axis2/java/core/docs/quickstartguide.html#introduction and I am getting this error
and on clicking the url
Below is how my environment look like and what I have done so far.
C:\Users\adars\Downloads\dev\git\webservices>echo %JAVA_HOME% C:\Program Files\Java\jdk-18.0.1.1 C:\Users\adars\Downloads\dev\git\webservices>where java C:\Program Files\Java\jre1.8.0_333\bin\java.exe C:\Program Files\Java\jdk-18.0.1.1\bin\java.exe C:\Users\adars\Downloads\dev\git\webservices>echo %AXIS2_HOME% C:\javalibs\axis2-1.8.1 C:\Users\adars\Downloads\dev\git\webservices>echo %CATALINA_HOME% C:\Program Files\Apache Software Foundation\Tomcat 9.0
C:\Users\adars\Downloads\dev\git\webservices>ant generate.wsdl Buildfile: C:\Users\adars\Downloads\dev\git\webservices\build.xml
compile.service: [mkdir] Created dir: C:\Users\adars\Downloads\dev\git\webservices\build\classes [javac] C:\Users\adars\Downloads\dev\git\webservices\build.xml:42: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 1 source file to C:\Users\adars\Downloads\dev\git\webservices\build\classes
generate.wsdl:
BUILD SUCCESSFUL Total time: 4 seconds
C:\Users\adars\Downloads\dev\git\webservices>ant generate.service Buildfile: C:\Users\adars\Downloads\dev\git\webservices\build.xml
compile.service: [javac] C:\Users\adars\Downloads\dev\git\webservices\build.xml:42: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
generate.service: [copy] Copying 1 file to C:\Users\adars\Downloads\dev\git\webservices\build\classes [jar] Building jar: C:\Users\adars\Downloads\dev\git\webservices\build\Calculator.aar [copy] Copying 1 file to C:\Users\adars\Downloads\dev\repository\services
BUILD SUCCESSFUL Total time: 0 seconds
C:\Users\adars\Downloads\dev\git\webservices>tree /F Folder PATH listing for volume Windows8_OS Volume serial number is AEA2-7F54 C:. │ build.xml │ ├───build │ │ Calculator.aar │ │ Calculator.wsdl │ │ │ └───classes │ ├───META-INF │ │ services.xml │ │ │ └───Start │ Calculator.class │ ├───resources │ └───META-INF │ services.xml │ └───src └───Start Calculator.java
C:\Users\adars\Downloads\dev\git\webservices>ls C:\Users\adars\Downloads\dev\repository\services Calculator.aar
C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\axis2\WEB-INF\services>jar -tvf Calculator.aar 0 Sat Jun 18 18:50:46 AST 2022 META-INF/ 105 Sat Jun 18 18:50:44 AST 2022 META-INF/MANIFEST.MF 0 Sat Jun 18 18:48:18 AST 2022 Start/ 525 Sat Jun 18 18:50:46 AST 2022 META-INF/services.xml 462 Sat Jun 18 18:48:18 AST 2022 Start/Calculator.class
<?xml version="1.0"?>
-<service scope="application" name="Calculator">
<description>A simple calulator to study web services</description>
<parameter name="ServiceClass" locked="false">Start.Calculator</parameter>
-<messageReceivers>
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" mep="http://www.w3.org/ns/wsdl/in-only"/>
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" mep="http://www.w3.org/ns/wsdl/in-out"/>
</messageReceivers>
<operation name="getSum"/>
</service>
I copy the Calculator.aar under C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\axis2\WEB-INF\services and restart Tomcat. But I get the error No services found in this location.
Solution
Finally I found the issue and resolved it, and I could get the service functional.
I increased the Tomcat debug level to ALL, and it showed error
20-Jun-2022 20:13:11.479 FINE [main] org.apache.catalina.core.StandardContext.listenerStart Sending application start events
20-Jun-2022 20:13:11.839 FINE [main] org.apache.catalina.session.StandardSession.doReadObject readObject() loading session 0CC9F9423F1AB41ADEAE13CCCB7FCCB8
20-Jun-2022 20:13:11.839 FINE [main] org.apache.catalina.session.StandardSession.doReadObject loading attribute 'errprservicemap' with value '{C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\axis2\WEB-INF\services\Calculator.aar=Error:
java.lang.UnsupportedClassVersionError: Start/Calculator has been **compiled by a more recent version of the Java Runtime (class file version 62.0), this version of the Java Runtime only recognizes class file versions up to 52.0**
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
I was compiling on a more recent version of java and Tomcat 9 could not recognize the error. I changed to Java 1.8 But I am surprised why this is not logged at an ERROR level and instead put at a fine level. Should this be logged as a bug ?
Answered By - Adarsh Nanu
Answer Checked By - Clifford M. (JavaFixing Volunteer)