Search code examples
javamysqlweb-servicestomcatapache-axis

Why am I not able to see the services in this database through axis2 localhost?


I've been learning about web services and stuff and finally was able to build my first gimmick code, but whenever I try to create a web service of my DAO class on eclipse, I end up not being able to access it's sessions (Services, Validate, Administration) on localhost.

Additional info: I'm using axis2 with tomcat 6.0.41 (for tutorial's sake) and trying to access a recently created MySQL database "ExemploWS" through http://localhost:8080/ExemploWS/, which Works fine until I try to navigate through it.

Also using XAMPP Control Panel with Apache and MySQL started. So I'm leaving the connection class and then the error I'm getting when accesssing http://localhost:8080/ExemploWS/services/listServices.

package br.com.ExemploWS;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConectaMySQL { 
private static final String url = "jdcb:mysql://localhost/exemplows";
private static final String user = "root";
private static final String pass = "";

public static Connection obtemConexao() throws SQLException {
    try {
        Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return DriverManager.getConnection(url,user,pass);
}
}

HTTP Status 500 - Servlet.init() for servlet AxisServlet threw exception

type Exception report

message Servlet.init() for servlet AxisServlet threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet.init() for servlet AxisServlet threw exception org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) java.lang.Thread.run(Unknown Source) root cause

java.lang.NoClassDefFoundError: org/apache/ws/commons/schema/resolver/URIResolver org.apache.axis2.deployment.ModuleDeployer.deploy(ModuleDeployer.java:128) org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:144) org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:585) org.apache.axis2.deployment.RepositoryListener.init(RepositoryListener.java:264) org.apache.axis2.deployment.RepositoryListener.init2(RepositoryListener.java:66) org.apache.axis2.deployment.RepositoryListener.(RepositoryListener.java:61) org.apache.axis2.deployment.DeploymentEngine.loadRepository(DeploymentEngine.java:152) org.apache.axis2.deployment.WarBasedAxisConfigurator.getAxisConfiguration(WarBasedAxisConfigurator.java:233) org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64) org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:620) org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:471) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) java.lang.Thread.run(Unknown Source) root cause

java.lang.ClassNotFoundException: org.apache.ws.commons.schema.resolver.URIResolver org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) org.apache.axis2.deployment.ModuleDeployer.deploy(ModuleDeployer.java:128) org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:144) org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:585) org.apache.axis2.deployment.RepositoryListener.init(RepositoryListener.java:264) org.apache.axis2.deployment.RepositoryListener.init2(RepositoryListener.java:66) org.apache.axis2.deployment.RepositoryListener.(RepositoryListener.java:61) org.apache.axis2.deployment.DeploymentEngine.loadRepository(DeploymentEngine.java:152) org.apache.axis2.deployment.WarBasedAxisConfigurator.getAxisConfiguration(WarBasedAxisConfigurator.java:233) org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64) org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:620) org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:471) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) java.lang.Thread.run(Unknown Source) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.41 logs.

Apache Tomcat/6.0.41'


Solution

  • add this class to your application, it is missing:

    java.lang.NoClassDefFoundError: org/apache/ws/commons/schema/resolver/URIResolver 
    

    it is in commons-xmlschema, find it here: http://mvnrepository.com/artifact/org.apache.ws.commons.schema/XmlSchema