掲示板

[SOLVED] Installing SOLR with Liferay 6

thumbnail
12年前 に alex wom によって更新されました。

[SOLVED] Installing SOLR with Liferay 6

Regular Member 投稿: 218 参加年月日: 09/05/04 最新の投稿
I'm using Liferay 6.0.6 in tomcat bundle and I'm trying to install SOLR on my MAC/OS

SOLR installation
-----------------------
I unzipped apache-solr-3.1.0.
I put apache-solr-3.1.0.war in example.
I prepared solr.xml as specified in http://www.liferay.com/en/community/wiki/-/wiki/Main/Integrate%20Solr%20with%20Liferay%20portal;jsessionid=8DA52AA57C6D9058D229741DF4C76B69.node-1
and I used absolute path as in the following.
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="$SOLR_HOME/example/apache-solr-3.1.0.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="$SOLR_HOME/example/solr" override="true"/>
</Context>
Moreover solr/home has been set to $SOLR_HOME/example/solr because if I do as suggested in the post, using $SOLR_HOME/example I cannot raise SOLR admin page with the URL http://localhost:8080/solr/admin.
I updated tomcat/bin/setenv.sh as in the following:
JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF8 -Duser.timezone=GMT -Xmx1024m -XX:MaxPermSize=256m -Dsolr.solr.home=$SOLR_HOME/example/solr/data"
I put SOLR plugin schema.xml in $SOLR_HOME/example/solr/conf

SOLR plugin installation
--------------------------------
I open the war (importing with eclipse)
I deleted from lib solr-common.jar and solr-solrj.jar and I put in place of them apache-solr-solrj-3.1.0.jar
I exported the war in liferay-portal-6.0.6/deploy
I started liferay and I receive an exception:
-----------------------------------------------------------------------------------------------
INFO: Deploying web application directory solr-web
log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [WebappClassLoader
context: /solr-web
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@10849bc
] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [WebappClassLoader
context:
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@10849bc
].
log4j:ERROR Could not instantiate appender named "CONSOLE".
07:02:44,449 ERROR [ContextLoader:220] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageListener.solr_reader' defined in ServletContext resource [/WEB-INF/classes/META-INF/messaging-spring.xml]: Cannot resolve reference to bean 'com.liferay.portal.kernel.search.SearchEngine' while setting bean property 'searchEngine'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.search.SearchEngine' defined in ServletContext resource [/WEB-INF/classes/META-INF/solr-spring.xml]: Cannot resolve reference to bean 'com.liferay.portal.kernel.search.IndexSearcher' while setting bean property 'searcher'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.search.IndexSearcher' defined in ServletContext resource [/WEB-INF/classes/META-INF/solr-spring.xml]: Cannot resolve reference to bean 'com.liferay.portal.search.solr.server.BasicAuthSolrServer' while setting bean property 'solrServer'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.search.solr.server.BasicAuthSolrServer' defined in ServletContext resource [/WEB-INF/classes/META-INF/solr-spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.liferay.portal.search.solr.server.BasicAuthSolrServer]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at com.liferay.portal.spring.context.PortletContextLoaderListener.contextInitialized(PortletContextLoaderListener.java:71)
at com.liferay.portal.kernel.servlet.PortalClassLoaderServletContextListener.doPortalInit(PortalClassLoaderServletContextListener.java:91)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:52)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:50)
at com.liferay.portal.kernel.servlet.PortalClassLoaderServletContextListener.contextInitialized(PortalClassLoaderServletContextListener.java:52)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.search.SearchEngine' defined in ServletContext resource [/WEB-INF/classes/META-INF/solr-spring.xml]: Cannot resolve reference to bean 'com.liferay.portal.kernel.search.IndexSearcher' while setting bean property 'searcher'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.search.IndexSearcher' defined in ServletContext resource [/WEB-INF/classes/META-INF/solr-spring.xml]: Cannot resolve reference to bean 'com.liferay.portal.search.solr.server.BasicAuthSolrServer' while setting bean property 'solrServer'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.search.solr.server.BasicAuthSolrServer' defined in ServletContext resource [/WEB-INF/classes/META-INF/solr-spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.liferay.portal.search.solr.server.BasicAuthSolrServer]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 45 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.search.IndexSearcher' defined in ServletContext resource [/WEB-INF/classes/META-INF/solr-spring.xml]: Cannot resolve reference to bean 'com.liferay.portal.search.solr.server.BasicAuthSolrServer' while setting bean property 'solrServer'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.search.solr.server.BasicAuthSolrServer' defined in ServletContext resource [/WEB-INF/classes/META-INF/solr-spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.liferay.portal.search.solr.server.BasicAuthSolrServer]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 55 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.search.solr.server.BasicAuthSolrServer' defined in ServletContext resource [/WEB-INF/classes/META-INF/solr-spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.liferay.portal.search.solr.server.BasicAuthSolrServer]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 65 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.liferay.portal.search.solr.server.BasicAuthSolrServer]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:108)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
... 74 more

After this anyway I try to index contents by publishing them, or by indexing all together using the Reindex all search indexes in the admin panel: it seems to index but not using SOLR. If I go in the SOLR admin page I see 0 indexed documents: in the admin page the solr home seems ok (SolrHome=/Users/ale/Documents/CINI/Liferay6/apache-solr-3.1.0/example/solr/./ ).
I would like understand if SOLR doesn't work because I did something wrong in configuration, or if the problem is the exception, and SOLR is not correctly plugged in and Lucene is the search engine I'm using. In both cases how can I correct the problem?
Help me thanks.
Alex
thumbnail
12年前 に alex wom によって更新されました。

RE: Installing SOLR with Liferay 6

Regular Member 投稿: 218 参加年月日: 09/05/04 最新の投稿
Anyone is available to help me?
thumbnail
12年前 に jelmer kuperus によって更新されました。

RE: Installing SOLR with Liferay 6

Liferay Legend 投稿: 1191 参加年月日: 10/03/10 最新の投稿
The problem you are seeing is caused by this exception

Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

The latest version of solrj depends on slf4j so you need to include that as a dependency by changing the portal-dependency-jars property in liferay-plugin-package.properties to this

portal-dependency-jars=\
    commons-codec.jar,\
    commons-httpclient.jar,\
    slf4j-api.jar,\
    slf4j-log4j12.jar


Unfortunately the 6.0.6 plugin has some issues it wont work properly unless you make some changes to SolrIndexSearcherImpl

Here's a patch for that :

--- a/liferay-plugins-sdk/webs/solr-web/docroot/WEB-INF/src/com/liferay/portal/search/solr/SolrIndexSearcherImpl.java
+++ b/liferay-plugins-sdk/webs/solr-web/docroot/WEB-INF/src/com/liferay/portal/search/solr/SolrIndexSearcherImpl.java
@@ -26,11 +26,7 @@ import com.liferay.portal.kernel.search.IndexSearcher;
 import com.liferay.portal.kernel.search.Query;
 import com.liferay.portal.kernel.search.SearchException;
 import com.liferay.portal.kernel.search.Sort;
-import com.liferay.portal.kernel.util.StringBundler;
-import com.liferay.portal.kernel.util.StringPool;
-import com.liferay.portal.kernel.util.StringUtil;
-import com.liferay.portal.kernel.util.Time;
-import com.liferay.portal.kernel.util.Validator;
+import com.liferay.portal.kernel.util.*;
 
 import java.util.Collection;
 import java.util.HashSet;
@@ -156,12 +152,15 @@ public class SolrIndexSearcherImpl implements IndexSearcher {
 
 			Collection<string> names = solrDocument.getFieldNames();
 
-			for (String name : names) {
-				Field field = new Field(
-					name, solrDocument.getFieldValue(name).toString(), false);
+            for (String name : names) {
+                Field field = new Field(
+                    name,
+                    ArrayUtil.toStringArray(
+                            solrDocument.getFieldValues(name).toArray()), false);
+
+                document.add(field);
+            }
 
-				document.add(field);
-			}
 
 			float score = Float.valueOf(
 				solrDocument.getFieldValue("score").toString());</string>
thumbnail
12年前 に jelmer kuperus によって更新されました。

RE: Installing SOLR with Liferay 6

Liferay Legend 投稿: 1191 参加年月日: 10/03/10 最新の投稿
Also the schema.xml included in the plugin did not work out for me , right now i am using the attached schema
but i havent't used it long enough to know if this will finally solve all issues i had with the solr plugin

添付ファイル:

thumbnail
12年前 に Hitoshi Ozawa によって更新されました。

RE: Installing SOLR with Liferay 6

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
Do you know if there's an issue on this in the jira? I remember modifying the code myself too but wondered because the question came up here.
thumbnail
12年前 に jelmer kuperus によって更新されました。

RE: Installing SOLR with Liferay 6

Liferay Legend 投稿: 1191 参加年月日: 10/03/10 最新の投稿
As usual the code change i made they already implemented on the trunk so i didn't raise an issue. for the schema issue i created LPS-17569

The solr plugin kind of feels flawed by design though. since you have to know in advance which fields will be indexed and which of those fields should be multivalued. so if you install a new plugin it might now work correctly unless you update your schema. and worse you might not get it to work at all

suppose you have two plugins that both write to the myid field , plugin 1 writes a single value to it and uses the field to sort, and plugin 2 writes multiple values to this field.

You'd now have an issue
thumbnail
12年前 に alex wom によって更新されました。

RE: Installing SOLR with Liferay 6

Regular Member 投稿: 218 参加年月日: 09/05/04 最新の投稿
Sorry but, even if SOLR seems to work (I updated all as you suggested, also schema.xml to avoid exception on delete documents), when I start the system I receive this without exception...

log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [WebappClassLoader
context: /solr-web
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@27bc82e7
] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [WebappClassLoader
context:
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@27bc82e7
].
log4j:ERROR Could not instantiate appender named "CONSOLE".
thumbnail
12年前 に Raja Nagendra Kumar によって更新されました。

RE: Installing SOLR with Liferay 6

Expert 投稿: 484 参加年月日: 06/03/02 最新の投稿
Check if you have multiple log4j jar files in different webcontexts..

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
-Services 3.0 - Work Focused Costing as Opposed to Bodies or CV selling.
thumbnail
12年前 に Rex Petersen によって更新されました。

RE: Installing SOLR with Liferay 6

New Member 投稿: 11 参加年月日: 11/03/10 最新の投稿
I had to use Apache SOLR version 1.4.x to avoid compatibility errors between solr and solr-web.
12年前 に Farrel Chen によって更新されました。

RE: [SOLVED] Installing SOLR with Liferay 6

New Member 投稿: 18 参加年月日: 11/04/20 最新の投稿
How did you solve this problem? I have exactly the same problem integrating solr 3.4 with liferay 6.0.6.

I tried updating liferay-plugin-package.properties(the one under webapps/solr-web) and patching SolrIndexSearcherImpl as suggested by Jelmer, but that didn't solve my problem. Please help. Thanks a bunch!
thumbnail
11年前 に Wole Adetiba によって更新されました。

RE: [SOLVED] Installing SOLR with Liferay 6

New Member 投稿: 12 参加年月日: 07/11/09 最新の投稿
Hi,

This might not be useful anymore but just wanted to add what I did when I had similar problem. Like it was pointed out here, http://issues.liferay.com/browse/LPS-9376?focusedCommentId=137451&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-137451, I started having same problem after I started using log4j logging in the service layer. I removed all my references to log4j at service layer, changed them to use Liferay logging, redeployed the portlet plugins. This solved the problem for me.

Wole