Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-5363

NoClassDefFoundError when using Apache Log4J2

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.5
    • Fix Version/s: 4.6, 6.0
    • Component/s: None
    • Labels:

      Description

      Hey guys,

      I'm using Log4J2 + SLF4J in my project. Unfortunately my embedded solr server throws this error when starting:

      Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.da
      ta.solr.core.SolrOperations com.xxxxx.platform.core.config.SolrsearchConfig.defaultSolrTemplate() throws javax.xml.par
      sers.ParserConfigurationException,java.io.IOException,org.xml.sax.SAXException] threw exception; nested exception is org
      .springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultSolrServer' defined in class
       path resource [com/xxxxx/platform/core/config/SolrsearchConfig.class]: Instantiation of bean failed; nested exception
       is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.apache.solr.client.solrj.
      SolrServer com.xxxxxx.platform.core.config.SolrsearchConfig.defaultSolrServer() throws javax.xml.parsers.ParserConfigur
      ationException,java.io.IOException,org.xml.sax.SAXException] threw exception; nested exception is java.lang.NoClassDefFo
      undError: org/apache/log4j/Priority
              at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy
      .java:181)
              at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolv
      er.java:570)
              ... 105 more
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultSolrServer' de
      fined in class path resource [com/xxxxxx/platform/core/config/SolrsearchConfig.class]: Instantiation of bean failed; ne
      sted exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.apache.solr
      .client.solrj.SolrServer com.xxxxxxx.platform.core.config.SolrsearchConfig.defaultSolrServer() throws javax.xml.parsers.
      ParserConfigurationException,java.io.IOException,org.xml.sax.SAXException] threw exception; nested exception is java.lan
      g.NoClassDefFoundError: org/apache/log4j/Priority
              at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolv
      er.java:581)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(Ab
      stractAutowireCapableBeanFactory.java:1025)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutow
      ireCapableBeanFactory.java:921)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCap
      ableBeanFactory.java:487)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapab
      leBeanFactory.java:458)
              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegis
      try.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.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(Configurati
      onClassEnhancer.java:298)
              at com.xxxxxx.platform.core.config.SolrsearchConfig$$EnhancerByCGLIB$$c571c5a6.defaultSolrServer(<generated>)
              at com.xxxxx.platform.core.config.SolrsearchConfig.defaultSolrTemplate(SolrsearchConfig.java:37)
              at com.xxxxxx.platform.core.config.SolrsearchConfig$$EnhancerByCGLIB$$c571c5a6.CGLIB$defaultSolrTemplate$2(<gen
      erated>)
              at com.xxxxx.platform.core.config.SolrsearchConfig$$EnhancerByCGLIB$$c571c5a6$$FastClassByCGLIB$$f67069c2.invo
      ke(<generated>)
              at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
              at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(Configurati
      onClassEnhancer.java:286)
              at com.xxxxxx.platform.core.config.SolrsearchConfig$$EnhancerByCGLIB$$c571c5a6.defaultSolrTemplate(<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:606)
              at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy
      .java:160)
              ... 106 more
      Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.apache.solr.client
      .solrj.SolrServer com.xxxxxxx.platform.core.config.SolrsearchConfig.defaultSolrServer() throws javax.xml.parsers.ParserC
      onfigurationException,java.io.IOException,org.xml.sax.SAXException] threw exception; nested exception is java.lang.NoCla
      ssDefFoundError: org/apache/log4j/Priority
              at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy
      .java:181)
              at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolv
      er.java:570)
              ... 127 more
      Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Priority
              at org.apache.solr.core.CoreContainer.load(CoreContainer.java:433)
              at org.apache.solr.core.CoreContainer.load(CoreContainer.java:358)
              at org.apache.solr.core.CoreContainer.<init>(CoreContainer.java:160)
              at org.springframework.data.solr.server.support.EmbeddedSolrServerFactory.createPathConfiguredSolrServer(Embedde
      dSolrServerFactory.java:101)
              at org.springframework.data.solr.server.support.EmbeddedSolrServerFactory.initSolrServer(EmbeddedSolrServerFacto
      ry.java:77)
              at org.springframework.data.solr.server.support.EmbeddedSolrServerFactory.getSolrServer(EmbeddedSolrServerFactor
      y.java:70)
              at com.xxxxxxx.platform.core.config.SolrsearchConfig.defaultSolrServer(SolrsearchConfig.java:32)
              at com.xxxxxx.platform.core.config.SolrsearchConfig$$EnhancerByCGLIB$$c571c5a6.CGLIB$defaultSolrServer$1(<gener
      ated>)
              at com.xxxxxx.platform.core.config.SolrsearchConfig$$EnhancerByCGLIB$$c571c5a6$$FastClassByCGLIB$$f67069c2.invo
      ke(<generated>)
              at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
              at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(Configurati
      onClassEnhancer.java:286)
              at com.xxxxxx.platform.core.config.SolrsearchConfig$$EnhancerByCGLIB$$c571c5a6.defaultSolrServer(<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:606)
              at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy
      .java:160)
              ... 128 more
      Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority
              at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
              at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
              at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
              at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:430)
              at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:383)
              ... 145 more
      

      Seems like Solr relies on Log4J version 1.x.

        Attachments

        1. SOLR-5363.patch
          0.9 kB
          Petar Tahchiev

          Activity

            People

            • Assignee:
              romseygeek Alan Woodward
              Reporter:
              paranoiabla Petar Tahchiev
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: