Announcement Announcement Module
Collapse
No announcement yet.
java.lang.NoClassDefFoundError: org/apache/http/impl/client/HttpClients Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.NoClassDefFoundError: org/apache/http/impl/client/HttpClients

    Just checked out the latest version of the Spring Social Movies example. Everything seems to compile fine, but at runtime the application fails to load because of the following exception (see below). Is anyone else able to start up the app without a problem?

    -Joe

    Code:
     Apr 15, 2014 12:37:31 PM org.apache.catalina.core.StandardContext listenerStart
      SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.connectionFactoryLocator' defined in class path resource [org/springframework/social/movies/config/SocialConfig.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.social.connect.ConnectionFactoryLocator org.springframework.social.movies.config.SocialConfig.connectionFactoryLocator()] threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/http/impl/client/HttpClients
          at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1025)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:921)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
          at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
          at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
          at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4961)
          at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5455)
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
          at java.util.concurrent.FutureTask.run(FutureTask.java:166)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at java.lang.Thread.run(Thread.java:722)
      Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.social.connect.ConnectionFactoryLocator org.springframework.social.movies.config.SocialConfig.connectionFactoryLocator()] threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/http/impl/client/HttpClients
          at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:181)
          at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570)
          ... 24 more
      Caused by: java.lang.NoClassDefFoundError: org/apache/http/impl/client/HttpClients
          at org.springframework.social.support.ClientHttpRequestFactorySelector$HttpComponentsClientRequestFactoryCreator.createRequestFactory(ClientHttpRequestFactorySelector.java:89)
          at org.springframework.social.support.ClientHttpRequestFactorySelector.getRequestFactory(ClientHttpRequestFactorySelector.java:52)
          at org.springframework.social.oauth1.OAuth1Template.createRestTemplate(OAuth1Template.java:167)
          at org.springframework.social.oauth1.OAuth1Template.<init>(OAuth1Template.java:91)
          at org.springframework.social.oauth1.OAuth1Template.<init>(OAuth1Template.java:71)
          at org.springframework.social.movies.netflix.connect.NetFlixOAuth1Template.<init>(NetFlixOAuth1Template.java:25)
          at org.springframework.social.movies.netflix.connect.NetFlixServiceProvider.<init>(NetFlixServiceProvider.java:26)
          at org.springframework.social.movies.netflix.connect.NetFlixConnectionFactory.<init>(NetFlixConnectionFactory.java:24)
          at org.springframework.social.movies.config.SocialConfig.connectionFactoryLocator(SocialConfig.java:57)
          at org.springframework.social.movies.config.SocialConfig$$EnhancerByCGLIB$$35acaa36.CGLIB$connectionFactoryLocator$0(<generated>)
          at org.springframework.social.movies.config.SocialConfig$$EnhancerByCGLIB$$35acaa36$$FastClassByCGLIB$$27ca8263.invoke(<generated>)
          at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
          at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:286)
          at org.springframework.social.movies.config.SocialConfig$$EnhancerByCGLIB$$35acaa36.connectionFactoryLocator(<generated>)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:601)
          at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:160)
          ... 25 more
      Caused by: java.lang.ClassNotFoundException: org.apache.http.impl.client.HttpClients
          at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
          at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
          ... 44 more

  • #2
    Changing the httpclient dependency version from 4.2.5 to 4.3.3 fixes this problem as this class doesn't exist until version 4.3.

    Comment

    Working...
    X