java.lang.NoClassDefFoundError: Could not initialize class异常

oClassDefFoundError occurs at compile time the corresponding class is available, and the Java runtime classpath path, the corresponding class is not caused by the error.
By looking for information on the cause of such abnormalities is likely to occur:

  - class or class dependent jar absent

  - the class file, but there is a different domain
1 corresponding to the java classpath in Class unavailable;

2. You might run your program with a jar command, but class does not classpath property in the manifest file of jar files defined;

3. The script may start a program covering the original classpath environment variable;

4. As a subclass java.lang.LinkageError NoClassDefFoundError is, it may be due to program-dependent native library unavailable result;

Is there such a mistake java.lang.ExceptionInInitializerError 5. Check the log file, NoClassDefFoundError may be due to a failure caused by static initialization;

6. If you are working in a J2EE environment, there are a number of different class loaders, it may also lead to NoClassDefFoundError;

7.NoClassDefFoundError` also possible due to the kind of static initialization module errors, when you perform some kind of static initialization module operation, if the initialization module throws an exception, which will depend on other classes of this class throw NoClassDefFoundError errors. If you view the log, you will find some of java.lang.ExceptionInInitializerError the error log, ExceptionInInitializerError of error causes java.lang.NoClassDefFoundError: Could not initialize class.

ava application deployment in tomcat container, which function is to render html page into pdf file, an error in the process of converting html pdf in: java.lang.NoClassDefFoundError: Could not initialize class java.awt.Rectangle:

java.lang.NoClassDefFoundError: Could not initialize class java.awt.Rectangle at org.xhtmlrenderer.pdf.ITextRenderer.getInitialExtents(ITextRenderer.java:217) at org.xhtmlrenderer.pdf.ITextRenderer.layout(ITextRenderer.java:206)

Solution In another article, " BufferedImage Captcha error Could not initialize class sun.awt.X11GraphicsEnvironment solutions " have encountered a similar situation, the solution here is analogous thereto:

Added catalina.sh startup script JAVA_OPTS in "-Djava.awt.headless = true", also can access the graphics code, modifications as follows:

JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Djava.awt.headless=true" 

The investigation, this situation is generally inaccessible to the user tomcat start Xserver, including Xserver does not start or do not have permission to access. Adding the above mentioned option to normal.

The above article excerpt

Guess you like

Origin www.cnblogs.com/lazyli/p/11347612.html