This is a rehash of the job. I don’t know how many times THIS has happened. Recording a wave of… Bring up the previous document. HMMMM

background

At 1:30 p.m., the service feedback container failed to be loaded. The LIB JAR package was not loaded, causing services to fail.

To deal with

Since this is a serious business, I first SSH into the container to check the loading status of the processFrom the screenshot, both processes load jar packages. That doesn’t seem quite right. Then business feedback asked me to use itjad xxx.xxx.xxxLook at some of the classes. They don’tBut the use ofclassloader -c --load xx.xx.xxxIt’s ok.

Then came the main characterjava.lang.NoClassDefFoundError: Could not initialize class com.xxx.xxx.services.youzan.basis.YouzanClientHelperNew  It’s kind of obvious at this point. It’s just initializationYouzanClientHelperNewWhen a static block of code or a static field has an error, the JVM will mark the class as failing and the error will occur later in use. If you have no experience, you will look for this class and find that there are misunderstandings in this class, leading to the failure to find the problem.Exception class screenshot.How to fix

  • Static code fast addtry catch, error throws or is the log obviously printed. This type of error must see the original error or it will be swamped by the NoClassDefFoundError.
  • If there is no static code block, then there must be a static field initialization error. Static fields can be instantiated in the code block, andtry catch .

The question that finally popped up

conclusion

There is basically nothing to say about this problem, experienced people can FIX it in about 5 minutes, and if they don’t know they will get caught in a huge wave of class loading. HMMMM? HMMMM? HMMMM

Will see links blog.csdn.net/hengyunabc/…

In fact, I came across it once,nested exception is java.lang.NoClassDefFoundError: Cloud not initialize class sun.security.provider.certpath.AlgorithmChecker.The solution was to initialize the Thread class ahead of time. I don’t know why.