当我尝试显示JSP页面时如何解决错误?

时间:2015-03-03 07:01:20

标签: java jsp servlets

我尝试在JSP页面上显示一些数据库记录。在我的项目中,我需要像index.html和studentDeatils.jsp这样的页面。我将requestDispather设置为从index页面转到studentDetails页面。

当我尝试显示JSP时,我的浏览器页面出现以下错误。

错误:

HTTP Status 500 - Servlet execution threw an exception

type Exception report

message Servlet execution threw an exception

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

exception

javax.servlet.ServletException: Servlet execution threw an exception
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/catalina/loader/WebappClassLoader) previously initiated loading for a different type with name "javax/servlet/RequestDispatcher"
    java.lang.ClassLoader.defineClass1(Native Method)
    java.lang.ClassLoader.defineClass(Unknown Source)
    java.security.SecureClassLoader.defineClass(Unknown Source)
    java.net.URLClassLoader.defineClass(Unknown Source)
    java.net.URLClassLoader.access$100(Unknown Source)
    java.net.URLClassLoader$1.run(Unknown Source)
    java.net.URLClassLoader$1.run(Unknown Source)
    java.security.AccessController.doPrivileged(Native Method)
    java.net.URLClassLoader.findClass(Unknown Source)
    org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:894)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1298)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1175)
    com.mine.servlet.TestClass.doGet(TestClass.java:23)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.5 logs.

这是我的文件夹结构:                 网页内容                      - > index.html和stucentDetails.jsp

日志文件:tomcat8-stdout.2015-03-03

2015-03-03 12:17:10 Commons Daemon procrun stdout initialized
reqType = next
Inside if() reqType = next
ID :: 101 First Name :: Kavi Last Name :: Arasu
ID :: 102 First Name :: Sathis Last Name :: Kumar
ArrayList = [com.min.variableobject.StudentVO@45a690]

错误文件:tomcat8-stderr.2015-03-03

2015-03-03 12:17:10 Commons Daemon procrun stderr initialized
03-Mar-2015 12:17:14.535 INFO [main] org.apache.catalina.core.AprLifecycleListener.init The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\egurkha\bin;C:\egurkha\lib;C:\egurkha\JAVA\JDK\bin;C:\egurkha\lib\tt;C:\egurkha\bin\tt;C:\Program Files\Common Files\Microsoft Shared\Microsoft Online Services;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\apache-ant-1.9.4\bin;C:\Program Files\Java\jdk1.7.0_17\bin ;C:\egurkha\manager\tomcat\bin;.
03-Mar-2015 12:17:15.941 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
03-Mar-2015 12:17:16.113 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
03-Mar-2015 12:17:16.129 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
03-Mar-2015 12:17:16.145 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
03-Mar-2015 12:17:16.145 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 2763 ms
03-Mar-2015 12:17:16.270 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
03-Mar-2015 12:17:16.270 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.5
03-Mar-2015 12:17:16.316 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\egtomcat.war
03-Mar-2015 12:17:17.004 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
03-Mar-2015 12:17:17.238 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\Learning.war
03-Mar-2015 12:17:17.410 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
03-Mar-2015 12:17:17.410 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\docs
03-Mar-2015 12:17:17.457 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\manager
03-Mar-2015 12:17:17.551 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\ROOT
03-Mar-2015 12:17:17.598 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
03-Mar-2015 12:17:17.598 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
03-Mar-2015 12:17:17.613 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1468 ms

请分享您的想法。

1 个答案:

答案 0 :(得分:0)

WAR文件中的jar包含servlet-api.jarjavaee-api.jar。它捆绑在您的tomcat安装中。如果你用这些罐子添加任何lib,他们就会发生冲突