HTTP Status 500 - Unable to compile class for JSP:
type Exception reportmessage Unable to compile class for JSP:description The server encountered an internal error that prevented it from fulfilling this request.<html><head><title>Apache Tomcat/7.0.75 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - Unable to compile class for JSP: </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>Unable to compile class for JSP: </u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: [16] in the generated java file: [/usr/local/tomcat7/work/Catalina/localhost/dsideal_yy/org/apache/jsp/html/ypt/getLoginInfo_jsp.java]Only a type can be imported. com.alibaba.fastjson.JSONObject resolves to a packageStacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:490) org.apache.jasper.compiler.Compiler.compile(Compiler.java:379) org.apache.jasper.compiler.Compiler.compile(Compiler.java:354) org.apache.jasper.compiler.Compiler.compile(Compiler.java:341) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:82) dsidealsso.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:130) org.jasig.cas.client.util.AssertionThreadLocalFilter.doFilter(AssertionThreadLocalFilter.java:54) dsidealsso.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:133) org.jasig.cas.client.util.HttpServletRequestWrapperFilter.doFilter(HttpServletRequestWrapperFilter.java:75) dsidealsso.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:133) org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:199) dsidealsso.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:133) org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:124) dsidealsso.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:133) org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:76) dsidealsso.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:133) dsidealsso.FilterChainProxy.doFilter(FilterChainProxy.java:92)</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.75 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.75</h3></body></html>
网上有人说:
开发中国银行支付网关时碰到了这个问题。我想在index.jsp中导入PKCS7Tool,代码如下:
<%@ page import=”com.bocnet.common.security.PKCS7Tool” %>
运行时报错:
An error occurred at line: 9 in the generated java file Only a type can be imported. com.bocnet.common.security.PKCS7Tool resolves to a package意思是说只有一个类能被导入,com.bocnet.common.security.PKCS7Tool是一个包。
实际上是因为PKCS7Tool这个包没有导入java运行环境。于是我把pkcs7.jar、pkcs7-src.jar这两个包加到/usr/local/tomcat/lib/目录下,并重启tomcat,一定要确保tomcat已重启。再测试看看,程序正常运行了。
黄海的方式:fastjson-1.2.47.jar 拷贝到 /usr/local/tomcat7/lib下,然后 ./restart.sh tomcat!
<%@ page language="java" import="org.jasig.cas.client.authentication.AttributePrincipal" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ page language="java" import="java.util.*"%><%@ page language="java" import="com.alibaba.fastjson.JSONObject"%><% AttributePrincipal attributePrincipal = (AttributePrincipal)request.getUserPrincipal(); Mapmap = attributePrincipal.getAttributes(); String userId = String.valueOf(map.get("PERSONID")); String userName = String.valueOf(map.get("USER_NAME")); out.print(userName); %>~