-
Notifications
You must be signed in to change notification settings - Fork 820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OSGI dynamically loading issue with postgresql-9.4.1207 #497
Comments
Can you provide a test case? |
@lewie, can some tests from openhab be used as integration tests for pgjdbc? I mean add a Travis check, so we always know if a particular change in pgjdbc impacts openhab. |
Puhh, This we try to do:
We do this with other Drivers too: |
public static void main(String[] args) throws ClassNotFoundException {
Class<?> klass = Class.forName("org.postgresql.Driver");
System.out.println("klass = " + klass);
System.out.println("klass.getConstructors() = " + Arrays.toString(klass.getConstructors()));
}
What's the problem with that? |
This can happen if the jar is not correct for the JVM. Which jar are you using and which JVM ? Dave Cramer On 21 January 2016 at 10:14, Vladimir Sitnikov notifications@github.com
|
Helmut, Did you figure this out ? Dave Cramer On 21 January 2016 at 10:34, Dave Cramer davecramer@gmail.com wrote:
|
I tested all Versions, We had similar problem with one version of SQLite drivers two Month ago. Superficial I have seen that the meta-data structure in the bundle has changed a lot, compared to the older versions. |
Do you have a test case we can try ? We aren't OSGI experts by any means Dave Cramer On 26 January 2016 at 16:28, Helmut Lehmeyer notifications@github.com
|
@vlsi, the cause seems to be to find already on OSGI level. |
@lewie , I am not following you. |
as test case, you need a OSGI environment like Apache karaf or equinox, to see whats going on at boot time. My test case is OpenHAB, running live in karaf or for development in Eclipse. My time is a little tight but I will examine the bundle detail and to report to you. |
I understand that. I have never ran a single karaf instance though.
That is fine. I just thought some basic command like |
OK, I thought you mean a small peace of code to test it. I will configure you a openHAB with most simple configuration for testing. |
Just to be clear: I do not insist on openHAB. On the other hand, having some "live" project for a integration & regression testing is always a plus. One day I might read&understand how integration tests for Karaf are to be written. |
@vlsi, It should run with JVM >= 1.6, better use 1.8.x /addons folder is observed for changes, subfolders will be ignored. In openHAB root folder use start.sh or start.bat to start openHAB. In console output and /logs/openhab.log you can see logging data. If bundle is loaded you see:
If not:
I hope it helps. |
@lewie, I find no In the mean time, I've prepared a test suite via
|
have tested the file once again:
Then there is a file distribution-1.8.0_pgjdbc.zip?raw=true. Delete ?raw=true from Filename.
Tried to run https://github.com/vlsi/pgjdbc/tree/7942a254717e35a200d8ac4798191a075f815bdc with mvn clean install i had no luck. Manny errors and missing local postgresql instance... OK, comparing postgresql-9.4.1207.jre7.jar and postgresql-9.4-1206-jdbc41.jar in 1207 i found a folder META-INF/maven/ other jdbc drivers does or does not not have this META-INF/maven/ folder. Just for fun, I replaced hole 1207 META-INF/* by 1206 META-INF/* ... and behold the bundle starts. Don't know whats going on. I only know, anything has changed fundamentally since 1206 version. |
Thanks I'll check new zip.
This is "just for information".
You can build with 1206 was ant-based, 1207 is maven-based. |
@lewie
Even for JRE6 & JRE7 jars.
Is it expected? |
Re "java.lang.NoClassDefFoundError: org/osgi/service/jdbc/DataSourceFactory", I've added |
JFYI: here's a snapshot version: https://oss.sonatype.org/content/repositories/snapshots/org/postgresql/postgresql/9.4.1208.jre7-SNAPSHOT/ postgresql-9.4.1208.jre7-20160208.210048-45.jar or newer.
|
@vlsi,
Well done!
We could connect the database:
Tested postgresql-9.4.1208.jre7-20160208.210048-45.jar, works like a charme. Thanks |
Hi, just wanted to let you know that I had no luck with openHab 2.0, I tried the integrated persistence configurator as well as manually placing several postgresql driver jars (1201-1208) into the addons directory, the NoClassDefFoundError remains. I assume there is probably a class duplicate somewhere deep in the openHab installation, but this is only a poor guess. I decided not to use postgresql for the time being. |
@thhart , can you list full error message that you run into with 1208 driver? |
2016-07-06 07:29:28.652 [WARN ] [org.apache.felix.fileinstall ] - Error while starting bundle: file:/opt/openHAB/addons/postgresql-9.4 org.osgi.framework.BundleException: Exception in org.postgresql.osgi.PGBundleActivator.start() of bundle org.postgresql.jdbc42. at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:792)[org.eclipse.osgi-3.10.2.v20150203 at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:721)[org.eclipse.osgi-3.10.2.v20150203-1939.jar at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:936)[org.eclipse.osgi-3.10.2.v20150203-1939.jar: at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:319)[org.eclipse.osgi-3.10.2.v20150 at org.eclipse.osgi.container.Module.doStart(Module.java:571)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:] at org.eclipse.osgi.container.Module.start(Module.java:439)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:] at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:393)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:] at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245)[8:org.apache.felix.fileinstall:3.5. at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217)[8:org.apache.felix.fileinstall:3.5 at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:509)[8:org.apache.felix.fileinstall:3.5.0] at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[8:org.apache.felix.fileinstall:3.5.0] at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[8:org.apache.felix.fileinstall:3.5.0] *Caused by: java.lang.NoClassDefFoundError: org/osgi/service/jdbc/DataSourceFactory at org.postgresql.osgi.PGBundleActivator.start(PGBundleActivator.java:32) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:771)[org.eclipse.osgi-3.10.2.v20150203-1939.jar at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:] at java.security.AccessController.doPrivileged(Native Method)[:1.8.0_91] at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:764)[org.eclipse.osgi-3.10.2.v20150203 ... 11 more Caused by: java.lang.ClassNotFoundException: org.osgi.service.jdbc.DataSourceFactory cannot be found by org.postgresql.jdbc42_9.4.1207 at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)[org.eclipse.osgi-3.10.2.v20150203-1939.jar: at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:] at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:] at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)[org.eclipse.osgi-3.10.2.v20150203-1939.ja at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_91] ... 16 more |
This is jdbc42_9.4.1207 that is known to be openhab-incompatible.
|
This is with 1208 (jre7 or 42) put into addons: java.lang.IllegalArgumentException: Unable to load DataSourceFactory. Will ignore DataSourceFactory registration. If you need one, ensure org.osgi.enterprise is on the classpath at org.postgresql.osgi.PGBundleActivator.start(PGBundleActivator.java:38) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:771) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:764) at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:721) at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:936) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:319) at org.eclipse.osgi.container.Module.doStart(Module.java:571) at org.eclipse.osgi.container.Module.start(Module.java:439) at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:393) at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245) at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217) at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:509) at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358) at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310) Caused by: java.lang.NoClassDefFoundError: org/osgi/service/jdbc/DataSourceFactory at org.postgresql.osgi.PGBundleActivator.start(PGBundleActivator.java:33) ... 15 more Caused by: java.lang.ClassNotFoundException: org.osgi.service.jdbc.DataSourceFactory cannot be found by org.postgresql.jdbc42_9.4.1208 at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 16 more 13:34:15.370 [ERROR] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: could NOT load JDBC-driverClassName or JDBC-dataSourceClassName ClassNotFoundException: 'org.postgresql.Driver cannot be found by org.openhab.persistence.jdbc_1.9.0.201607040111' 13:34:15.381 [WARN ] [ence.jdbc.internal.JdbcConfiguration] - !!! To avoid this error, place a appropriate JDBC driver file for serviceName 'postgresql' in addons directory. Copy missing JDBC-Driver-jar to your OpenHab/addons Folder. !!! DOWNLOAD: PostgreSQL:version >= 9.4-1201-jdbc41 from http://mvnrepository.com/artifact/org.postgresql/postgresql |
@thhart , can you share your openhab installation and/or steps to reproduce the problem? By the way, the stacktrace from 1208 is not an error. We might need to reduce verbosity, however it should not fail the startup. |
Thank you all for such a good discussion. |
Versions before can be loaded dynamically as OSGI bundle since Version 1207 this does not work any longer.
These jars from maven-repo are not working:
postgresql-9.4.1207.jar
postgresql-9.4.1207.jre6.jar
postgresql-9.4.1207.jre7.jar
We use these drivers with our Database Services with openHAB:
openhab/openhab1-addons#3862 (comment)
Rgds
Helmut
The text was updated successfully, but these errors were encountered: