简体   繁体   English

java.lang.NoClassDefFoundError:在多次使用程序后发生

[英]java.lang.NoClassDefFoundError: occurs after multiple uses of a program

I have a service that runs from a docker container which runs just fine for about an hour or so, and then suddenly throws a java.lang.NoClassDefFoundError . 我有一个从docker容器运行的服务,运行时间大约一个小时左右,然后突然抛出一个java.lang.NoClassDefFoundError After reading up on these errors it seems it is often an issue in initialization. 在阅读了这些错误之后,它似乎常常是初始化中的一个问题。 However, my service runs just fine at first -- including using the class that suddenly can't be found! 但是,我的服务最初运行得很好 - 包括使用突然找不到的类!

In fact this particular class needs to be initialized in order for the service to start correctly. 实际上,需要初始化此特定类以使服务正确启动。 This is a multithreaded application running on Spring. 这是一个在Spring上运行的多线程应用程序。

What are some reasons for a class to go missing after being used? 一个班级在被使用后会失踪的原因是什么?

Figured it out! 弄清楚了!

This was a weird memory issue. 这是一个奇怪的记忆问题。 The garbage collector was picking and deleting the class that my program was looking for. 垃圾收集器正在挑选和删除我的程序正在寻找的类。 It would boot up and run fine, but once it sat idle for 30 minutes or so the GC would destroy the class it needed. 它会启动并运行正常,但一旦它闲置30分钟左右,GC就会破坏它所需的类。 Womp! Womp! Gave my program some more memory and it works like a dream now. 给我的程序更多的记忆,现在就像一个梦想。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM