java.lang.NoClassDefFoundError: Could not initialize class XXX

后端 未结 10 1210
無奈伤痛
無奈伤痛 2020-11-27 10:59
public class PropHolder {
  public static Properties prop;

  static {
    //code for loading properties from file
  }
}

// Referencing the class somewhere else:
Pr         


        
10条回答
  •  自闭症患者
    2020-11-27 11:18

    You are getting a java.lang.NoClassDefFoundError which does NOT mean that your class is missing (in that case you'd get a java.lang.ClassNotFoundException). The ClassLoader ran into an error while reading the class definition when trying to read the class.

    Put a try/catch inside your static initializer and look at the exception. If you read some files there and it differs from your local environment it's very likely the cause of the problem (maybe file can't be found, no permissions etc.).

提交回复
热议问题