【问题标题】:How can i solve java.lang.IllegalStateException: Illegal access:?我该如何解决 java.lang.IllegalStateException:非法访问:?
【发布时间】:2020-02-02 01:14:33
【问题描述】:

我正在使用 Eclipse 开发一个 webapp。一切正常,但有时当我尝试 publist->start 我的服务器时,我收到以下错误:

Oct 03, 2019 6:52:55 PM org.apache.catalina.loader.WebappClassLoaderBase checkStateForResourceLoading
INFO: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
    at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1383)
    at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1036)
    at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkThreadContextClassLoader(AbandonedConnectionCleanupThread.java:117)
    at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:84)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)

前几次,我只是重新启动服务器,它工作正常,但现在即使重新启动也不能解决问题。我在网上读到了它,一些消息来源提到这可能是线程管理问题,但我没有比这更进一步的了。有人可以提供一些信息吗?谢谢。

【问题讨论】:

  • 控制台显示的内容是这样的吗?

标签: eclipse tomcat web-applications tomcat9


【解决方案1】:

mysql 驱动程序正在尝试在 web 应用程序关闭时进行清理,这很好。不幸的是,它正在尝试加载其他类来执行此清理,并且 - 由于 Web 应用程序正在关闭 - 类加载不再可用。理想情况下,驱动程序会在首次加载时加载它需要清理的所有类——这样可以避免这个问题。

如果您可以确定它正在尝试加载哪些类 - 检查驱动程序源代码应该会显示哪些类 - 那么您应该能够在应用程序启动时自行加载它们,例如 ServletContextListener

【讨论】:

  • 谢谢,我查看了错误消息,它确实给了我加载有问题的类。
【解决方案2】:

如果您创建了任何实体类并忘记为任何特定列提供 ID,那么也会出现此问题。因此,将@ID 分配给任何列并再次运行。您的问题将得到解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-14
    • 2019-05-10
    • 1970-01-01
    • 1970-01-01
    • 2021-12-27
    • 1970-01-01
    • 1970-01-01
    • 2020-03-25
    相关资源
    最近更新 更多