我爲PAX以下數據源配置文件:NPE在春分
osgi.jdbc.driver.class=org.postgresql.Driver
url=jdbc:postgresql://localhost:5432/demo
dataSourceName=demo-pg
user=demo
password=demo
它創建數據源在Karaf,然而,在Eclipse中使用Equinox的OSGi的啓動,我得到NPE:
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:459)
at java.util.Properties.setProperty(Properties.java:166)
at org.postgresql.ds.common.BaseDataSource.setProperty(BaseDataSource.java:1030)
at org.postgresql.ds.common.BaseDataSource.setUrl(BaseDataSource.java:964)
at org.postgresql.osgi.PGDataSourceFactory.configureBaseDataSource(PGDataSourceFactory.java:65)
at org.postgresql.osgi.PGDataSourceFactory.createSimpleDataSource(PGDataSourceFactory.java:127)
at org.postgresql.osgi.PGDataSourceFactory.createDataSource(PGDataSourceFactory.java:149)
at org.ops4j.pax.jdbc.config.impl.DataSourceRegistration.createDs(DataSourceRegistration.java:108)
at org.ops4j.pax.jdbc.config.impl.DataSourceRegistration.<init>(DataSourceRegistration.java:63)
at org.ops4j.pax.jdbc.config.impl.DataSourceFactoryTracker.addingService(DataSourceFactoryTracker.java:42)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)
at org.ops4j.pax.jdbc.config.impl.DataSourceConfigManager.updated(DataSourceConfigManager.java:80)
at org.apache.felix.cm.impl.helper.ManagedServiceFactoryTracker.updated(ManagedServiceFactoryTracker.java:159)
at org.apache.felix.cm.impl.helper.ManagedServiceFactoryTracker.provideConfiguration(ManagedServiceFactoryTracker.java:93)
at org.apache.felix.cm.impl.ConfigurationManager$UpdateConfiguration.run(ConfigurationManager.java:1772)
at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)
at java.lang.Thread.run(Thread.java:745)
在調試器中檢查後,我發現錯誤是由於屬性PROTOCOL_VERSION
爲空而引發的。我試圖在配置文件中設置變量:
protocolVersion=3
但我仍然得到相同的錯誤。
如何在Equinox/Eclipse運行時配置PostgreSQL數據源?
我使用PostgreSQL驅動程序版本9.4-1200:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1200-jdbc41</version>
</dependency>
它看起來更像https://ops4j1.jira.com/browse/PAXJDBC-84 –
好吧..然後它可能只與PostgreSQL的版本問題。 –
它看起來像。我不確定是否應該將此作爲答案編寫......但是,是否應該從Maven存儲庫中刪除錯誤版本? –