java.lang.ClassNotFoundException:com.ebank.rajeev.controllers.Alogin

时间:2015-09-26 07:27:09

标签: eclipse jsp tomcat servlets

我在eclipse控制台上收到此错误,

java.lang.ClassNotFoundException: com.ebank.rajeev.controllers.Alogin
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:520)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:501)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:120)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:817)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1526)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1482)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

在运行jsp页面时,tomcat说 HTTP状态404 - 类型状态报告 信息 description请求的资源不可用。

我的代码是正确的。我仍然无法找到办法。

的web.xml

<servlet-mapping>
<servlet-name>Alogin</servlet-name>
<url-pattern>/Alogin</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>Alogin</display-name>
<servlet-name>Alogin</servlet-name>
<servlet-class>com.ebank.rajeev.controllers.Alogin</servlet-class>
</servlet>

admin.jsp

<form method="post" action="Alogin">
<div>
<input type="password" name="uname" placeholder="username" />
<input type="password" name="pwd" placeholder="password" />
<input type="submit" id="search-submit" value="Login" /><br />
</div>
</form>

Alogin servlet

String uname=request.getParameter("uname");
    String pwd=request.getParameter("pwd");
    if(uname.equals("admin") && pwd.equals("admin"))
    {
         HttpSession session=request.getSession();
         session.setAttribute("UNAME",uname);
         response.sendRedirect("AdminHome.jsp");
    }
    else
    {
         response.sendRedirect("admin.jsp?msg=invalid");
    }

Java构建路径需要jar文件,即servlet-api.jarjsp-api.jarmysql-connector.jar。我在这个页面上使用任何sql代码仍然会给出错误。

2 个答案:

答案 0 :(得分:0)

我认为com.ebank.rajeev.controllers.Alogin课程不会出现在你提到的罐子里。您必须查看项目中需要的第三个库。

如果您有一堆库,并且您不知道com.ebank.rajeev.controllers.Alogin提供的位置,那么您可以使用jarscan找到合适的jar。

您可以从这里http://www.oracle.com/splash/java.net/maintenance/index.html

下载jarscan

以这种方式使用它:

java -jar jarscan.jar -d /path/to/find/libraries -j com.ebank.rajeev.controllers.Alogin

答案 1 :(得分:0)

转到项目属性,然后在Deployment Descriptor上添加Java Build path entries以及对源文件夹的引用,通常是/src/main/resourcesWEB-INF/classes。执行Project&gt; Clean并重新启动服务器。