Postgresql jdbc driver

thumbnail
1937664, modified 17 Years ago. New Member Posts: 6 Join Date: 1/13/09 Recent Posts
Hi.

I have one question about postgresql jdbs driver wich comes with bundles.
What is the difference between postgresql.jar from Glassfish+Liferay bundle and drivers from http://jdbc.postgresql.org/ ?

I'm using:

Glassfish 2.1
Liferay 5.2.2 (not bundled)
Postgresql 8.3
Ubuntu 8.10

This is the problem.
When I try to enable Lucene stores indexes in a database via jdbc with
lucene.store.type=jdbc
and original postgresql jdbc drivers, I got a lot of error messages in Glassfish logs like:

[#|2009-03-12T16:19:44.806+0000|SEVERE|sun-appserver2.1|javax.enterprise.system.container.web|_ThreadID=23;_ThreadName=pool-1-thread-2;_RequestID=01801e6c-2041-45ce-b241-aa88dbb0452
d;|WebModule[]PWC1396: Servlet  threw load() exception
java.lang.RuntimeException: org.apache.lucene.store.jdbc.JdbcStoreException: Failed to execute sql [select tablename from pg_tables where schemaname = 'public' and lower(tablename)
= ?]; nested exception is org.postgresql.util.PSQLException: Method org.postgresql.jdbc3.Jdbc3PreparedStatement.setQueryTimeout(int) is not yet implemented.
        at com.liferay.portal.search.lucene.LuceneUtil._getLuceneDirJdbc(LuceneUtil.java:656)
        at com.liferay.portal.search.lucene.LuceneUtil._getLuceneDir(LuceneUtil.java:590)
        at com.liferay.portal.search.lucene.LuceneUtil.getLuceneDir(LuceneUtil.java:394)
        at com.liferay.portal.search.lucene.LuceneUtil.checkLuceneDir(LuceneUtil.java:324)
        at com.liferay.portal.events.StartupAction.run(StartupAction.java:84)
        at com.liferay.portal.servlet.MainServlet.init(MainServlet.java:154)
        at javax.servlet.GenericServlet.init(GenericServlet.java:270)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1194)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1023)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4917)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:5324)
        at com.sun.enterprise.web.WebModule.start(WebModule.java:353)
        at com.sun.enterprise.web.LifecycleStarter.doRun(LifecycleStarter.java:58)
        at com.sun.appserv.management.util.misc.RunnableBase.runSync(RunnableBase.java:304)
        at com.sun.appserv.management.util.misc.RunnableBase.run(RunnableBase.java:341)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.lucene.store.jdbc.JdbcStoreException: Failed to execute sql [select tablename from pg_tables where schemaname = 'public' and lower(tablename) = ?]; nested exce
ption is org.postgresql.util.PSQLException: Method org.postgresql.jdbc3.Jdbc3PreparedStatement.setQueryTimeout(int) is not yet implemented.
        at org.apache.lucene.store.jdbc.support.JdbcTemplate.executeSelect(JdbcTemplate.java:112)
        at org.apache.lucene.store.jdbc.JdbcDirectory.tableExists(JdbcDirectory.java:191)
        at com.liferay.portal.search.lucene.LuceneUtil._getLuceneDirJdbc(LuceneUtil.java:651)
        ... 20 more
Caused by: org.postgresql.util.PSQLException: Method org.postgresql.jdbc3.Jdbc3PreparedStatement.setQueryTimeout(int) is not yet implemented.
        at org.postgresql.Driver.notImplemented(Driver.java:738)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.setQueryTimeout(AbstractJdbc2Statement.java:597)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setQueryTimeout(NewProxyPreparedStatement.java:1304)
        at org.apache.lucene.store.jdbc.support.JdbcTemplate.executeSelect(JdbcTemplate.java:105)
        ... 22 more

[#|2009-03-12T16:19:44.807+0000|SEVERE|sun-appserver2.1|javax.enterprise.system.container.web|_ThreadID=14;_ThreadName=pool-1-thread-1;_RequestID=a4070111-9bef-4b23-adc3-c3b50aa42d9
7;|WEB0207: Error starting web context StandardEngine[com.sun.appserv].StandardHost[server].StandardContext[] on virtual server server
LifecycleException:  java.lang.RuntimeException: org.apache.lucene.store.jdbc.JdbcStoreException: Failed to execute sql [select tablename from pg_tables where schemaname = 'public'
and lower(tablename) = ?]; nested exception is org.postgresql.util.PSQLException: Method org.postgresql.jdbc3.Jdbc3PreparedStatement.setQueryTimeout(int) is not yet implemented.
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4927)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:5324)
        at com.sun.enterprise.web.WebModule.start(WebModule.java:353)
        at com.sun.enterprise.web.LifecycleStarter.doRun(LifecycleStarter.java:58)
        at com.sun.appserv.management.util.misc.RunnableBase.runSync(RunnableBase.java:304)
        at com.sun.appserv.management.util.misc.RunnableBase.run(RunnableBase.java:341)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)


But, when i put postgresql.jar from bundle to $GALSSFISH_INSTALL/domains/domain1/lib/ , instead of orriginal, I got errors too, but not like first one:


[#|2009-03-14T16:03:24.587+0000|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=liferay/search_writer;|16:03:24,587 ERROR [IndexWriterFactory:209]
Unable to create a new writer
java.io.FileNotFoundException: no segments* file found in org.apache.lucene.store.jdbc.JdbcDirectory@769601: files: write.lock
        at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:587)
        at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:251)
        at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:710)
        at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:503)
        at com.liferay.portal.search.lucene.IndexWriterFactory.getWriter(IndexWriterFactory.java:190)
        at com.liferay.portal.search.lucene.LuceneUtil.getWriter(LuceneUtil.java:414)
        at com.liferay.portal.search.lucene.LuceneUtil.getWriter(LuceneUtil.java:408)
        at com.liferay.portal.search.lucene.LuceneIndexWriterImpl.addDocument(LuceneIndexWriterImpl.java:56)
        at com.liferay.portal.search.lucene.LuceneSearchEngineUtil.addDocument(LuceneSearchEngineUtil.java:43)
        at com.liferay.portal.search.lucene.messaging.LuceneWriterMessageListener.doReceive(LuceneWriterMessageListener.java:72)
        at com.liferay.portal.search.lucene.messaging.LuceneWriterMessageListener.receive(LuceneWriterMessageListener.java:43)
        at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:70)
        at com.liferay.portal.kernel.messaging.SerialDestination$1.run(SerialDestination.java:53)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)

</init>


So, question is why this errors are different with different drivers and how to fix it ? :-)
Thanks.
thumbnail
1937664, modified 17 Years ago. New Member Posts: 6 Join Date: 1/13/09 Recent Posts
Guys, does anybody know what is the difference between postgresql.jar from liferay-bundles and jdbc driver from jdbc.postgresql.org ?
I tried to compare files size, it's not the same.
thumbnail
682861, modified 17 Years ago. Liferay Legend Posts: 1228 Join Date: 4/14/08 Recent Posts
Vlad, are you trying to find the difference between two jdbc drivers, or need to fix the lucene problem? Drivers from different vendors would usually produce different error output, jar file sizes will change with every build and are never the same.
It is very unlikely that jdbc driver is the cause of the problem. Use whatever drivers are defined in liferay, get back to lucene configuration manuals and related forum threads, wipe out you lucene databases and restart the system. If it does not work, rephrase your question.
thumbnail
1937664, modified 17 Years ago. New Member Posts: 6 Join Date: 1/13/09 Recent Posts
Well, actually I'm trying to figure out both problems. But sure, lucene problem is my main task :-) . And I just noticed a little bit different reaction with jdbc drivers, so that is why i deside it can be a reason.
Anyway, thanks for reply :-)
1108419, modified 17 Years ago. New Member Post: 1 Join Date: 7/24/08 Recent Posts
We are experiencing the same problem with Tomcat :
We installed Liferay bundle 5.2.1 with Tomcat 6.0.18 and MySQL 5.1.31.
Our portal.ext properties includes as followed :
jdbc.default.url=jdbc:mysql://localhost/lportal?emulateLocators=true&useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
##
## Lucene Search
##
index.read.only=false
index.on.startup=true
index.on.startup.delay=120
index.with.thread=true
lucene.store.type=jdbc
lucene.store.jdbc.auto.clean.up=true
lucene.store.jdbc.dialect.mysql=org.apache.lucene.store.jdbc.dialect.MySQLInnoDBDialect
lucene.dir=${liferay.home}/data/lucene/
lucene.file.extractor=com.liferay.portal.search.lucene.LuceneFileExtractor
lucene.file.extractor.regexp.strip=

lucene.analyzer=org.apache.lucene.analysis.standard.StandardAnalyzer
lucene.merge.factor=10
lucene.optimize.interval=1

When we launched Liferay for the 1st time there was no problem, then we added a few document in the document library (the search function was working properly, finding our documents).
Then we shutdown Liferay and re-started it, that’s when we got the following message. As we saw in one of the previous post we put in the portal.ext properties the ‘emulateLocators=true” but it didn’t make any difference.

We tried to delete the lucene_0 and lucene_1 tables from the database and then restart Liferay, then it worked again, but we don’t think that it is a good solution to have to delete the indexes each time we shutdown Liferay.


This is the error message that we get at startup :

Using CATALINA_BASE: C:\liferay-portal-5.2.1\tomcat-6.0.18
Using CATALINA_HOME: C:\liferay-portal-5.2.1\tomcat-6.0.18
Using CATALINA_TMPDIR: C:\liferay-portal-5.2.1\tomcat-6.0.18\temp
Using JRE_HOME: C:\liferay-portal-5.2.1\tomcat-6.0.18/jre1.5.0_17/win
Loading jar:file:/C:/liferay-portal-5.2.1/tomcat-6.0.18/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
Loading jar:file:/C:/liferay-portal-5.2.1/tomcat-6.0.18/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties
Loading file:/C:/liferay-portal-5.2.1/tomcat-6.0.18/webapps/ROOT/WEB-INF/classes/portal-ext.properties
15:43:13,203 INFO [DialectDetector:64] Determining dialect for MySQL 5
15:43:13,296 INFO [DialectDetector:97] Using dialect org.hibernate.dialect.MySQLDialect
Loading jar:file:/C:/liferay-portal-5.2.1/tomcat-6.0.18/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/captcha.properties
15:43:16,843 INFO [PortalImpl:240] Portal lib directory /C:/liferay-portal-5.2.1/tomcat-6.0.18/webapps/ROOT/WEB-INF/lib/
15:43:31,578 INFO [ServerDetector:103] Detected server tomcat
Starting Liferay Portal Standard Edition 5.2.1 (Augustine / Build 5201 / February 3, 2009)
15:43:37,625 ERROR [LuceneUtil:354] Check Lucene directory failed for 0
org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: PhantomReadLock[write.lock/LUCENE_0]
at org.apache.lucene.store.Lock.obtain(Lock.java:85)
at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:692)
at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:503)
at com.liferay.portal.search.lucene.LuceneUtil.checkLuceneDir(LuceneUtil.java:345)
at com.liferay.portal.events.StartupAction.run(StartupAction.java:84)
at com.liferay.portal.servlet.MainServlet.init(MainServlet.java:154)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
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:525)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
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:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
15:43:40,718 INFO [HotDeployUtil:64] Initializing hot deploy manager 24192786
15:43:41,140 INFO [AutoDeployDir:108] Auto deploy scanner started for C:\liferay-portal-5.2.1\deploy
15:43:41,578 INFO [LuceneServlet:66] Indexing Lucene on startup
Loading file:/C:/liferay-portal-5.2.1/tomcat-6.0.18/temp/0-chat-portlet/WEB-INF/classes/service.properties
15:43:42,359 INFO [DialectDetector:64] Determining dialect for MySQL 5
15:43:42,359 INFO [DialectDetector:97] Using dialect org.hibernate.dialect.MySQLDialect
Loading file:/C:/liferay-portal-5.2.1/tomcat-6.0.18/temp/0-chat-portlet/WEB-INF/classes/service.properties
15:43:44,296 INFO [PortletHotDeployListener:219] Registering portlets for chat-portlet
Loading file:/C:/liferay-portal-5.2.1/tomcat-6.0.18/temp/0-chat-portlet/WEB-INF/classes/portlet.properties
15:43:44,906 INFO [PortletHotDeployListener:298] 1 portlet for chat-portlet is available for use
15:43:45,281 ERROR [LuceneWriterMessageListener:46] Unable to process message {destination=liferay/search_writer, responseDestination=liferay/search_writer/response, responseId=null, payload={command=UPDATE, companyId=0, id=PluginPackageIndexer_PORTLET_liferay/chat-portlet/5.2.0.1/war, doc={title=[Ljava.lang.String;@b6efb2type=[Ljava.lang.String;@329bcbuid=[Ljava.lang.String;@9235c2pageURL=[Ljava.lang.String;@1077092content=[Ljava.lang.String;@16f84d8status=[Ljava.lang.String;@7abf31installedVersion=[Ljava.lang.String;@9e2e50version=[Ljava.lang.String;@f2a026modified=[Ljava.lang.String;@f036delicense=[Ljava.lang.String;@a2470crepositoryURL=[Ljava.lang.String;@1e69e99groupId=[Ljava.lang.String;@1b66659moduleId=[Ljava.lang.String;@1f99e90osi-approved-license=[Ljava.lang.String;@1191056tag=[Ljava.lang.String;@7f9d70portletId=[Ljava.lang.String;@39410aauthor=[Ljava.lang.String;@dd197dartifactId=[Ljava.lang.String;@1b47cc2}, query=null, sorts=null, start=0, end=0}, values=null}
com.liferay.portal.kernel.search.SearchException: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: PhantomReadLock[write.lock/LUCENE_0]
at com.liferay.portal.search.lucene.LuceneIndexWriterImpl.deleteDocument(LuceneIndexWriterImpl.java:85)
thumbnail
682861, modified 17 Years ago. Liferay Legend Posts: 1228 Join Date: 4/14/08 Recent Posts
Bogdan, if you do proper liferay shutdown this error would not be happenning (at least is not supposed to).

When lucene starts indexing it adds 'lock' record to the database, then when system is interrupted 'lock' record is still there and new indexing can not be started.
Find this record in DB in delete it manually.
In normal circumstances, you do not have to delete lucene databases if you restart the server.

This 'lock' problem would strike if you have file-based lucene storage as well. In this case just delete the lock file.

Also have a look at another thread: Since switch to lucene.store.type=jdbc I'm getting lucene errors