博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
解决Only a type can be imported. * resolves to a package
阅读量:5050 次
发布时间:2019-06-12

本文共 4891 字,大约阅读时间需要 16 分钟。

HTTP Status 500 - Unable to compile class for JSP:

type Exception report
message 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 package
Stacktrace:
    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();   Map 
map = attributePrincipal.getAttributes(); String userId = String.valueOf(map.get("PERSONID")); String userName = String.valueOf(map.get("USER_NAME")); out.print(userName); %>~

 

转载于:https://www.cnblogs.com/littlehb/p/9122341.html

你可能感兴趣的文章
javaweb常识
查看>>
Java注解
查看>>
时间>金钱
查看>>
元数据元素
查看>>
Visual Studio Code 构建C/C++开发环境
查看>>
web自己主动保存表单
查看>>
一个小的日常实践——高速Fibonacci数算法
查看>>
创建与删除索引
查看>>
java的基本数据类型
查看>>
机器学些技法(9)--Decision Tree
查看>>
静态页面复习--用semantic UI写一个10min首页
查看>>
在Windows下安装64位压缩包版mysql 5.7.11版本的方法
查看>>
drf权限组件
查看>>
输入月份和日期,得出是今年第几天
查看>>
利用mysqldump备份mysql
查看>>
Qt中子窗口全屏显示与退出全屏
查看>>
使用brew安装软件
查看>>
[BZOJ1083] [SCOI2005] 繁忙的都市 (kruskal)
查看>>
吴裕雄 python 机器学习——数据预处理嵌入式特征选择
查看>>
Centos6.4安装JDK
查看>>