gpt4 book ai didi

java - Web 服务抛出 ClassNotFoundException

转载 作者:太空宇宙 更新时间:2023-11-04 14:14:33 25 4
gpt4 key购买 nike

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;
}
}

我已经将项目拍卖添加到Web服务项目的构建路径中。但是当我尝试运行它时。我收到以下 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

我是网络服务新手。希望得到任何帮助。

最佳答案

单击 Web 项目的属性,转到“部署程序集”选项卡并使用“添加”按钮将 DAO 项目/模块添加到 Web 项目的类路径中,如此处的图像所示 -

Web Deployment Assembly

关于java - Web 服务抛出 ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27907544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com