have different Class objects for the type org/apache/tomcat/InstanceManager used in the signa

遇到的 HTTP Status 500 - java.lang.LinkageError: loader constraint violation: when resolving method 和org.apache.jasper.JasperException: Unable to compile class for JSP这两个错

 

HTTP Status 500 - java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(Ljavax/servlet/ServletConfig;)Lorg/apache/tomcat/InstanceManager;"

 the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/index_jsp, and the class loader (instance of java/net/URLClassLoader) for the method's defining class, org/apache/jasper/runtime/InstanceManagerFactory,

 have different Class objects for the type org/apache/tomcat/InstanceManager used in the signaturetype

 Exception reportmessage

 java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(Ljavax/servlet/ServletConfig;)Lorg/apache/tomcat/InstanceManager;" the class loader (instance of org/apache/jasper/servlet/JasperLoader)

 of the current class, org/apache/jsp/index_jsp, and the class loader (instance of java/net/URLClassLoader) for the method's defining class, org/apache/jasper/runtime/InstanceManagerFactory, have different Class objects for the type org/apache/tomcat/InstanceManager

 used in the signaturedescription

 The server encountered an internal error that prevented it from fulfilling this request.exceptionjavax.servlet.ServletException:

 java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(Ljavax/servlet/ServletConfig;)Lorg/apache/tomcat/InstanceManager;" the class loader (instance of org/apache/jasper/servlet/JasperLoader)

 of the current class, org/apache/jsp/index_jsp, and the class loader (instance of java/net/URLClassLoader) for the method's defining class, org/apache/jasper/runtime/InstanceManagerFactory, have different Class objects for the type org/apache/tomcat/InstanceManager

 used in the signature

 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:349)

 javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

 org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)

 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)root

 causejava.lang.LinkageError:

 loader constraint violation: when resolving method "org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(Ljavax/servlet/ServletConfig;)Lorg/apache/tomcat/InstanceManager;" the class loader (instance of org/apache/jasper/servlet/JasperLoader)

 of the current class, org/apache/jsp/index_jsp, and the class loader (instance of java/net/URLClassLoader) for the method's defining class, org/apache/jasper/runtime/InstanceManagerFactory, have different Class objects for the type org/apache/tomcat/InstanceManager

 used in the signature

 org.apache.jsp.index_jsp._jspInit(index_jsp.java:53)

 org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:49)

 org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:179)

 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)

 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)

 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)

 javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

 org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)

 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)note

 The full stack trace of the root cause is available in the Apache Tomcat/8.0.23 logs.Apache

 Tomcat/8.0.23这是因为maven里面jar和tomcat里面自带的jar冲突了,

-----

这个错实际上就是你的tomcat的版本号和项目代码的版本号不同的原因!!!!

网上各种说把server-api和jsp-api有关,需要设置你pom中的这两个jar 为provided

我也这样做了,但是还是报错呢,只是换了一种形式,如下:

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.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

 

An error occurred at line: [65] in the generated java file: [C:\Users\sllata\.IntelliJIdea2019.1\system\tomcat\Unnamed_vmportal_3\work\Catalina\localhost\vmportal_war\org\apache\jsp\index_jsp.java]

The method getDispatcherType() is undefined for the type HttpServletRequest

 

Stacktrace:

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)

org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198)

org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)

org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:580)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)

javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)

org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)

org.jasig.cas.client.util.AssertionThreadLocalFilter.doFilter(AssertionThreadLocalFilter.java:54)

org.jasig.cas.client.util.HttpServletRequestWrapperFilter.doFilter(HttpServletRequestWrapperFilter.java:75)

org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:201)

org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:107)

org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:76)

com.wocloud.comserver.util.CorsFilter.doFilterInternal(CorsFilter.java:24)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)

note The full stack trace of the root cause is available in the Apache Tomcat/8.0.21 logs.


Apache Tomcat/8.0.21

发现还是错了,网上搜索还是jar包冲突,idea带的那个真心的不好看没有eclipse的好看,于是知道了,还可以这样:

在idea终端:

mvn dependency:tree>tree.txt  //列举出所有引用的包
mvn dependency:tree>tree.txt -Dverbose  //列出所有冲突的包(duplicate)

但是看完,我还是没找到,于是突然想到,我以前运行过,当时的pom文件还保留着,就对比和现在的版本有什么区别,【发现自己貌似遇见过这个问题】,于是把tomcat,【带有 tomcat 字样的】相关的包都provided,但是server-api 那两个没有设置,发现就运行起来了。就这样的我的一天就过去了,那种明知道错在哪就是不会改也是很无奈。

这种情况实在不行估计还是需要降低版本号。

 

 

你可能感兴趣的:(java错误)