Failed to load a class specified by the class name as a string

Thrown when an application tries to load in a class through its string name using:
  • The forName method in class Class.
  • The findSystemClass method in class ClassLoader .
  • The loadClass method in class ClassLoader.

but no definition for the class with the specified name could be found.

As of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The "optional exception that was raised while loading the class" that may be provided at construction time and accessed via the {@link #getException()} method is now known as the cause, and may be accessed via the {@link Throwable#getCause()} method, as well as the aforementioned "legacy method." @author unascribed @see java.lang.Class#forName(java.lang.String) @see java.lang.ClassLoader#findSystemClass(java.lang.String) @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) @since JDK1.0

at java.lang.ClassLoader.loadClass
at sun.misc.Launcher$AppClassLoader.loadClass
at java.lang.ClassLoader.loadClass
at java.lang.Class.forName0
at java.lang.Class.forName
9 frames hidden

Typical Exception Messages

  1. com.mysql.jdbc.Driver
  2. org.postgresql.Driver
  4. sun.jdbc.odbc.JdbcOdbcDriver
  5. org.apache.mahout.math.Vector
  6. org.sqlite.JDBC
  7. oracle.jdbc.driver.OracleDriver
  9. org.apache.nutch.indexer.solr.SolrDeleteDuplicates$SolrInputFormat
  10. oracle.jdbc.OracleDriver


Specific cases


  1. poroszd, 2 months ago

    Check the exception message to find out what is the name of the class that could not be found. It might be misspelled and you have to fix it in a config file. If the name is correct, you have to fix your classpath.

We have seen this error pattern in the following webpages (827)

  2. Bjarnivia Stack Overflow1 month ago
  3. Failed to create Ignite component (consider adding ignite-spring module to classpath) [comp onent=SPRING, cls=org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl]
  4. sho-suzukivia GitHub1 month ago
  5. Markvia Stack Overflow1 month ago
    Error creating bean with name 'appUserRestController': Unsatisfied dependency expressed through field 'appUserRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appUserRepository': Cannot create inner bean '(inner bean)#69ec93c2' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#69ec93c2': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Unable to load class: com.mysql.jdbc.Driver from ClassLoader:sun.misc.Launcher$AppClassLoader@119d7047;ClassLoader:sun.misc.Launcher$AppClassLoader@119d7047
  6. MajiDvia Stack Overflow1 month ago