2014年4月20日日曜日

Solr を Tomcatで動かす

Solr を Tomcatで動かすときにぶつかった問題と解決。

SolrとTomcatの連携はすでにいろんなブログに書かれてるので省略します。

Solr Tomcatとかで探してみて。

参考
http://www.soum.co.jp/misc/toza/apache-solr/1.html
とか参考にして


でこのようにやったのに http://****:8080/solrで動かず
こんなエラーがでた

4 17, 2014 12:00:06 午前 org.apache.catalina.core.StandardContext filterStart
SEVERE: フィルタ SolrRequestFilter の起動中の例外です
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
        at org.apache.solr.client.solrj.impl.HttpClientUtil.<clinit>(HttpClientUtil.java:78)
        at org.apache.solr.servlet.SolrDispatchFilter.<init>(SolrDispatchFilter.java:120)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at java.lang.Class.newInstance0(Class.java:374)
        at java.lang.Class.newInstance(Class.java:327)
        at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:140)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        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: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

        ... 25 more

4 17, 2014 12:37:04 午前 org.apache.catalina.core.StandardContext filterStart
SEVERE: フィルタ SolrRequestFilter の起動中の例外です
java.lang.NoClassDefFoundError: org/apache/log4j/Level
        at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
        at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
        at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
        at org.apache.solr.client.solrj.impl.HttpClientUtil.<clinit>(HttpClientUtil.java:78)
        at org.apache.solr.servlet.SolrDispatchFilter.<init>(SolrDispatchFilter.java:120)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at java.lang.Class.newInstance0(Class.java:374)
        at java.lang.Class.newInstance(Class.java:327)
        at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:140)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        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: java.lang.ClassNotFoundException: org.apache.log4j.Level
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

        ... 30 more

4 18, 2014 11:55:54 午後 org.apache.catalina.core.StandardContext filterStart
SEVERE: フィルタ SolrRequestFilter の起動中の例外です
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
        at org.apache.http.impl.client.CloseableHttpClient.<init>(CloseableHttpClient.java:60)
        at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:271)
        at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:127)
        at org.apache.http.impl.client.SystemDefaultHttpClient.<init>(SystemDefaultHttpClient.java:116)
        at org.apache.solr.client.solrj.impl.HttpClientUtil.createClient(HttpClientUtil.java:112)
        at org.apache.solr.servlet.SolrDispatchFilter.<init>(SolrDispatchFilter.java:120)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at java.lang.Class.newInstance0(Class.java:374)
        at java.lang.Class.newInstance(Class.java:327)
        at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:140)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        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: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

        ... 29 more

とかこんな感じのログ

解決方法

solrのパッケージのlibにこんなの入ってる
$ ll solr-4.7.0/example/lib/ext/
合計 540
-rw-r--r-- 1 suganuma suganuma  17289  6月 11 16:43 2012 jcl-over-slf4j-1.6.6.jar
-rw-r--r-- 1 suganuma suganuma   4955  6月 11 16:43 2012 jul-to-slf4j-1.6.6.jar
-rw-r--r-- 1 suganuma suganuma 481535  3月 31 06:25 2010 log4j-1.2.16.jar
-rw-r--r-- 1 suganuma suganuma  26176  6月 11 16:41 2012 slf4j-api-1.6.6.jar
-rw-r--r-- 1 suganuma suganuma   9711  6月 11 16:42 2012 slf4j-log4j12-1.6.6.jar

これら5このjarファイルを
tomcatのwebappのlibにおきました。

こういうところ
/usr/local/tomcat/7.0.53/webapps/solr/WEB-INF/lib/

そんで解決!!!

0 件のコメント:

コメントを投稿