Skip to content

Commit

Permalink
fix: OSGi require-capability manifest entry
Browse files Browse the repository at this point in the history
closes #497
  • Loading branch information
vlsi committed Feb 8, 2016
1 parent ee6118e commit a3e2045
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions pgjdbc/src/main/java/org/postgresql/osgi/PGBundleActivator.java
Expand Up @@ -29,8 +29,20 @@ public void start(BundleContext context) throws Exception {
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, Driver.class.getName());
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_NAME, "PostgreSQL JDBC Driver");
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_VERSION, Driver.getVersion());
_registration = context.registerService(DataSourceFactory.class.getName(),
new PGDataSourceFactory(), properties);
try {
_registration = context.registerService(DataSourceFactory.class.getName(),
new PGDataSourceFactory(), properties);
} catch (NoClassDefFoundError e) {
String msg = e.getMessage();
if (msg != null && msg.contains("org/osgi/service/jdbc/DataSourceFactory")) {
new IllegalArgumentException("Unable to load DataSourceFactory. "
+ "Will ignore DataSourceFactory registration. If you need one, "
+ "ensure org.osgi.enterprise is on the classpath", e).printStackTrace();
// just ignore. Assume OSGi-enterprise is not loaded
return;
}
throw e;
}
}

public void stop(BundleContext context) throws Exception {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.postgresql</groupId>
<artifactId>pgjdbc-versions</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
</parent>

<artifactId>pgjdbc-aggregate</artifactId>
Expand Down

0 comments on commit a3e2045

Please sign in to comment.