Tuesday, December 11, 2007

ClassNotFoundException Solution

Here is a list of possible problems which would may case ClassNotFoundException and the solution for this problems

  1. The class doesn't exists in the classpath, You can add it to your classpath by either click on properties of the project and add it to the java build path or you can choose run->classpath->and add the jar.
  2. The class exists in the classpath, but it has a static section in the beginning of the class which throws an exception in this case the class doesn't create by the classloader, the solution is to fix the exception thrown in the static section or add try catch.
  3. The class exists but it is loaded by a different classloader, for example you have two EAR files in which one need to access another one, The solution is to add reference between this two EAR files, or making one of the class loaders be the parent of the other class loader

No comments:

Links

 
RSS Feeds Submission Directory