[ https://issues.apache.org/jira/browse/SOLR-5363?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Petar Tahchiev updated SOLR-5363: --------------------------------- Attachment: SOLR-5363.patch Hi guys, so It seems that the CoreContainer checks if the slf4j implementation name contains log4j and if so instantiates the Log4j watcher. The problem is that using the Log4J2 the slf4j implementation is: {code} org.slf4j.helpers.Log4jLoggerFactory {code} so you see it does contain "Log4J", and thus SOLR will try to instantiate the Log4JWatcher, which was written for Log4J1. The Log4J1 slf4j implementation is called: {code} org.slf4j.impl.Log4jLoggerFactory {code} so what I have done is to change the if to include the full class name. If you apply this patch i guess the issue can be closed, but further on it might be a good idea to implement a Log4J2Watcher. > NoClassDefFoundError when using Apache Log4J2 > --------------------------------------------- > > Key: SOLR-5363 > URL: https://issues.apache.org/jira/browse/SOLR-5363 > Project: Solr > Issue Type: Bug > Affects Versions: 4.5 > Reporter: Petar Tahchiev > Labels: log4j2 > Attachments: SOLR-5363.patch > > > Hey guys, > I'm using Log4J2 + SLF4J in my project. Unfortunately my embedded solr server > throws this error when starting: > {code} > 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 > {code} > Seems like Solr relies on Log4J version 1.x. -- This message was sent by Atlassian JIRA (v6.1#6144) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org