Webservice抛出ClassNotFound异常

时间:2015-01-12 17:27:50

标签: java eclipse web-services axis2

AddService是使用ApacheTomcat,Eclipse和Axis2

创建的Web服务
import auctiondao.UsersDAO;

public class AddService {
    public String checkUser(String username,String password) {
        UsersDAO usersDAO=new UsersDAO();
        String user=usersDAO.checkUserExists(username, password);
        System.out.println("User....."+user);
        return user;
    }
}

我已经将项目拍卖添加到webservice项目的构建路径中。但是当我尝试运行它时。 我得到以下ClassPath异常

[ERROR] auctiondao/UsersDAO
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
atorg.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageRecei    ver.java:117)
atorg.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractI    nOutMessageReceiver.java:40)
at  org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)


Caused by: java.lang.NoClassDefFoundError: auctiondao/UsersDAO
at AddService.checkUser(AddService.java:5)
... 25 more
Caused by: java.lang.ClassNotFoundException: auctiondao.UsersDAO
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
... 26 more

我是webservices的新手。感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

单击您的Web项目属性,转到Deployment Assembly选项卡,然后使用'Add'按钮将DAO项目/模块添加到Web项目的类路径中,如下图所示 -

Web Deployment Assembly