JDBC 代码给出 MySql 的 IllegalAccessError
JDBC code is giving IllegalAccessError for MySql
我在检索数据库表的主键、外键和列信息时遇到以下错误。基本上我知道 IllegalAccess 与访问私有方法等有关。可能是由于不兼容的更改。
我正在使用mysql以下版本。我在类路径中只有一个 mysql jar。
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>
这是堆栈跟踪。
IllegalAccessError: com/mysql/jdbc/DatabaseMetaData
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.IllegalAccessError: com/mysql/jdbc/DatabaseMetaData
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.mycompany.filters.ErrorInterceptorFilter.doFilter(ErrorInterceptorFilter.java:50)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.mycompany.security.filters.EFWFilter.doFilter(SourceFile:164)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at com.mycompany.service.impl.RequestParameterAuthenticationFilter.doFilter(RequestParameterAuthenticationFilter.java:120)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:208)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:274)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalAccessError: com/mysql/jdbc/DatabaseMetaData
at com.mysql.jdbc.DatabaseMetaData.getPrimaryKeys(DatabaseMetaData.java:3747)
at com.mycompany.components.metadata.genericdbmetadata.PrimaryKeyDetails.getPrimaryKeys(PrimaryKeyDetails.java:32)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.getPrimaryKeys(MetadataProducer.java:345)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.setPrimaryKey(MetadataProducer.java:275)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.getListOfTables(MetadataProducer.java:241)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.getTables(MetadataProducer.java:210)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.getDatabase(MetadataProducer.java:88)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.getMetadata(MetadataProducer.java:61)
at com.mycompany.components.metadata.genericdbmetadata.GenericDatabaseMetadataProvider.getMetadata(GenericDatabaseMetadataProvider.java:120)
at com.mycompany.components.DatabaseMetadataProvider.executeComponent(DatabaseMetadataProvider.java:34)
at com.mycompany.services.GenericService.executeService(GenericService.java:92)
at com.mycompany.services.GenericService.executeService(GenericService.java:39)
at com.mycompany.services.MetadataProvider.doService(MetadataProvider.java:43)
at com.mycompany.controller.EfwServicesController.service(EfwServicesController.java:112)
at sun.reflect.GeneratedMethodAccessor415.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
... 61 more
但我经常遇到这个问题。在我的开发机器中,代码运行良好,但是当我部署到登台服务器时,我经常遇到这个问题——但并非总是如此(仅在某些部署期间)。如何解决这个问题?
附加信息:正在使用的 Servlet 容器是 Tomcat 6.0.26。该应用程序是 Spring 应用程序。
服务器的共享目录jars:
正如您所推断的,原因很可能是编译时 class 和运行时 class 之间的冲突,其中 class 具有(来自 JavaDoc)...不可撤销地更改.
查看您的共享文件夹,我想说 mariadb-java-client-1.1.2.jar
可能是罪魁祸首。
我在检索数据库表的主键、外键和列信息时遇到以下错误。基本上我知道 IllegalAccess 与访问私有方法等有关。可能是由于不兼容的更改。
我正在使用mysql以下版本。我在类路径中只有一个 mysql jar。
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>
这是堆栈跟踪。
IllegalAccessError: com/mysql/jdbc/DatabaseMetaData
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.IllegalAccessError: com/mysql/jdbc/DatabaseMetaData
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.mycompany.filters.ErrorInterceptorFilter.doFilter(ErrorInterceptorFilter.java:50)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.mycompany.security.filters.EFWFilter.doFilter(SourceFile:164)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at com.mycompany.service.impl.RequestParameterAuthenticationFilter.doFilter(RequestParameterAuthenticationFilter.java:120)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:208)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:274)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalAccessError: com/mysql/jdbc/DatabaseMetaData
at com.mysql.jdbc.DatabaseMetaData.getPrimaryKeys(DatabaseMetaData.java:3747)
at com.mycompany.components.metadata.genericdbmetadata.PrimaryKeyDetails.getPrimaryKeys(PrimaryKeyDetails.java:32)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.getPrimaryKeys(MetadataProducer.java:345)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.setPrimaryKey(MetadataProducer.java:275)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.getListOfTables(MetadataProducer.java:241)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.getTables(MetadataProducer.java:210)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.getDatabase(MetadataProducer.java:88)
at com.mycompany.components.metadata.genericdbmetadata.MetadataProducer.getMetadata(MetadataProducer.java:61)
at com.mycompany.components.metadata.genericdbmetadata.GenericDatabaseMetadataProvider.getMetadata(GenericDatabaseMetadataProvider.java:120)
at com.mycompany.components.DatabaseMetadataProvider.executeComponent(DatabaseMetadataProvider.java:34)
at com.mycompany.services.GenericService.executeService(GenericService.java:92)
at com.mycompany.services.GenericService.executeService(GenericService.java:39)
at com.mycompany.services.MetadataProvider.doService(MetadataProvider.java:43)
at com.mycompany.controller.EfwServicesController.service(EfwServicesController.java:112)
at sun.reflect.GeneratedMethodAccessor415.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
... 61 more
但我经常遇到这个问题。在我的开发机器中,代码运行良好,但是当我部署到登台服务器时,我经常遇到这个问题——但并非总是如此(仅在某些部署期间)。如何解决这个问题?
附加信息:正在使用的 Servlet 容器是 Tomcat 6.0.26。该应用程序是 Spring 应用程序。
服务器的共享目录jars:
正如您所推断的,原因很可能是编译时 class 和运行时 class 之间的冲突,其中 class 具有(来自 JavaDoc)...不可撤销地更改.
查看您的共享文件夹,我想说 mariadb-java-client-1.1.2.jar
可能是罪魁祸首。