java.lang.ClassNotFoundException

tip

If you're using Hibernate, this indicates you're missing FasterXML Classmate dependency, which you can add to your dependencies. To add it, the groupId is com.fasterxml and artifactId is Classmate.

tip

NoClassDefFoundError means java has failed to find a class you're trying to instantiate, look if you've added the class you're trying to instantiate to the dependencies.

tip

A few things cause this exception: 1) Check if you have all jars and if they're in the correct path when running. 2) Your classpath might be broken, you can define it in the command line with "java -cp yourClassPath" or at your IDE if you're using one.

tip

Check if you didn't forget to instantiate your topic in the kafka broker.

tip

You need to add httpcore to your dependencies. Try adding version 4.3 or further.

tip

You might've forgot to add a dependency or it's written wrong. Also, you might be using incompatible versions of Java and Hibernate. More on this here: https://goo.gl/SjSlRA

tip

This error means there's a class missing in your classpath during runtime. You need to create a jar with all your dependencies and have it in your classpath. Check Maven Assembly Plugin and how to add your dependencies to a jar: https://goo.gl/U2zr8k

tip

jsp-api and servlet-api jars must NOT be deployed by your web app. They should be marked as provided but not deployed by your app.

tip

The server rejects all jars that already belong to the server runtime (such as tomcat-**.jar, servlet**.jar). Consider substituting the CORS filter you're using for this one: https://goo.gl/ctQ7Fs

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • I was trying to set up a JMX client proxy. one of the interface method signatures contains byte[], and when setting up the client proxy, I get the exception below. seems like byte[].class.getName() returns '[B', and ClassUtils tries to use that as the name of the class when calling loadClass, a call which, evidently, fails. btw, I tried changing the signature to Byte[], but then I got the same error for '[Ljava.lang.Byte;'. java.lang.ClassNotFoundException: [B at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at org.springframework.util.ClassUtils.forName(ClassUtils.java:201) at org.springframework.util.ClassUtils.forName(ClassUtils.java:171) at org.springframework.jmx.support.JmxUtils.parameterInfoToTypes(JmxUtils.java:141) at org.springframework.jmx.access.MBeanClientInterceptor.retrieveMBeanInfo(MBeanClientInterceptor.java:239) at org.springframework.jmx.access.MBeanClientInterceptor.afterPropertiesSet(MBeanClientInterceptor.java:169) at org.springframework.jmx.access.MBeanProxyFactoryBean.afterPropertiesSet(MBeanProxyFactoryBean.java:81) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
    via by Zvika Markfeld,
  • I was trying to set up a JMX client proxy. one of the interface method signatures contains byte[], and when setting up the client proxy, I get the exception below. seems like byte[].class.getName() returns '[B', and ClassUtils tries to use that as the name of the class when calling loadClass, a call which, evidently, fails. btw, I tried changing the signature to Byte[], but then I got the same error for '[Ljava.lang.Byte;'. java.lang.ClassNotFoundException: [B at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at org.springframework.util.ClassUtils.forName(ClassUtils.java:201) at org.springframework.util.ClassUtils.forName(ClassUtils.java:171) at org.springframework.jmx.support.JmxUtils.parameterInfoToTypes(JmxUtils.java:141) at org.springframework.jmx.access.MBeanClientInterceptor.retrieveMBeanInfo(MBeanClientInterceptor.java:239) at org.springframework.jmx.access.MBeanClientInterceptor.afterPropertiesSet(MBeanClientInterceptor.java:169) at org.springframework.jmx.access.MBeanProxyFactoryBean.afterPropertiesSet(MBeanProxyFactoryBean.java:81) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
    via by Zvika Markfeld,
  • Bean Creation Exception with JBoss 5.1.2
    via Stack Overflow by ajit kumar
    ,
  • Classes not visible to OSGified Spring
    via Stack Overflow by baba
    ,
  • Spring data neo4j aspectJ setup error
    via Stack Overflow by maxsap
    ,
    • java.lang.ClassNotFoundException: [B at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at org.springframework.util.ClassUtils.forName(ClassUtils.java:201) at org.springframework.util.ClassUtils.forName(ClassUtils.java:171) at org.springframework.jmx.support.JmxUtils.parameterInfoToTypes(JmxUtils.java:141) at org.springframework.jmx.access.MBeanClientInterceptor.retrieveMBeanInfo(MBeanClientInterceptor.java:239) at org.springframework.jmx.access.MBeanClientInterceptor.afterPropertiesSet(MBeanClientInterceptor.java:169) at org.springframework.jmx.access.MBeanProxyFactoryBean.afterPropertiesSet(MBeanProxyFactoryBean.java:81) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)

    Users with the same issue

    Andreas Häber
    12 times, last one,
    stigkj
    1 times, last one,
    Axelo
    8 times, last one,
    marcbouvierdav
    26 times, last one,
    Unknown visitor1 times, last one,
    2285 more bugmates