运行jsp文件时发生类强制转换异常 [英] Class cast exception while running the jsp file
问题描述
我正在尝试运行我的.jsp文件之一,并且遇到类强制转换异常.
I'm trying to run one of my .jsp file and i'm getting class cast exception.
('org.apache.catalina.core.DefaultInstanceManager无法转换为org.apache.tomcat.InstanceManager')
('org.apache.catalina.core.DefaultInstanceManager cannot be cast to org.apache.tomcat.InstanceManager')
我已将所有jar放在WEB-INF/lib文件夹中,并且已包含所有必需的jar.
I have placed all my jars in WEB-INF/lib folder and I have included all the required jars.
是否由于.jar版本不匹配而发生此错误?
Is this error occurs because of .jar versions mismatch?
请让我知道是否有人知道此错误.
Kindly let me know if anyone knows about this error.
推荐答案
不得将tomcat的jar文件放入WEB-INF/lib. Tomcat已经具有这些类,并且它们必须由根tomcat类加载器加载,而不是由Webapp的类加载器加载.除非此jar列表中有一个特定的库不属于Tomcat,否则所有这些jar都不应该存在.
You must not put tomcat's jar files into WEB-INF/lib. Tomcat already has thoses classes, and they must be loaded by the root tomcat classloader, not by the webapp's classloader. Unless there is a specific library in this list of jars that is not part of Tomcat, all those jars shouldn't be there.
您在WEB-INF/lib中放置的是您的代码使用的库,例如Guava或OpenCSV或您可能自己创建的jar.不是Tomcat自己的库.
What you put in WEB-INF/lib are libraries that your code uses, like Guava or OpenCSV or whatever jar you could have created yourself. Not Tomcat's own libraries.
这篇关于运行jsp文件时发生类强制转换异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!