title: How can I install postgresqljdbc to work in Karaf OSGi?
body: <p>I want to install org.postgresql/postgresql/9.4-1201-jdbc41 in Karaf but I get errors. How can I resolve these errors? Strangely on Windows my Karaf doesn't have errors with this Postgres jdbc but on Ubuntu it has these errors. Any clues appreciated.</p>
  
  <pre><code>Install Kar feature social_importer.kar/1.0-SNAPSHOT
  java.lang.Exception: Could not start bundle    
  mvn:org.postgresql/postgresql/9.4-1201-jdbc41 in feature(s) 
  
  T: Unresolved constraint in bundle org.postgresql.jdbc41 
  [127]: Unable to resolve 127.0: missing requirement [127.0]
  osgi.wiring.package; (osgi.wiring.package=javax.transaction.xa)
  
  
  Caused by: org.osgi.framework.BundleException: 
  Unresolved constraint in bundle org.postgresql.jdbc41 [127]: Unable 
  to resolve 127.0: missing requirement [127.0] osgi.wiring.package;
  (osgi.wiring.package=javax.transaction.xa)
  </code></pre>
  
  <p>This might be related <a href="https://stackoverflow.com/questions/17675483/apache-felix-not-able-to-access-postgres-jdbc">Apache Felix not able to access Postgres JDBC</a></p>
  
  <hr>
  
  <pre><code>karaf@root()&gt; install -s wrap:mvn:postgresql/postgresql/9.4-1201-jdbc41
  Bundle IDs:
  Error executing command: Error installing bundles:
      Unable to install bundle wrap:mvn:postgresql/postgresql/9.4-1201-jdbc41
  karaf@root()&gt; install -s mvn:postgresql/postgresql/9.4-1201-jdbc41
  Bundle IDs:
  Error executing command: Error installing bundles:
      Unable to install bundle mvn:postgresql/postgresql/9.4-1201-jdbc41
  karaf@root()&gt;
  </code></pre>
  
  <hr>
  
  <p>I looked in the Karaf logs with log level of INFO.</p>
  
  <pre><code>Caused by: java.lang.NoClassDefFoundError: org/osgi/service/jdbc/DataSourceFactory
      at org.postgresql.osgi.PGBundleActivator.start(PGBundleActivator.java:32)
      at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
      at org.apache.felix.framework.Felix.activateBundle(Felix.java:2154)
      ... 11 more
  Caused by: java.lang.ClassNotFoundException: org.osgi.service.jdbc.DataSourceFactory not found by org.postgresql.jdbc41 [5328]
      at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1556)[org.apache.felix.framework-4.4.1.jar:]
      at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)[org.apache.felix.framework-4.4.1.jar:]
      at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993)[org.apache.felix.framework-4.4.1.jar:]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_25]
  </code></pre>