2

I am using EclipseLink as my JPA implementation(in KARAF).And following jars are used:-

install -s mvn:org.eclipse.persistence/org.eclipse.persistence.antlr/2.5.0
install -s mvn:org.eclipse.persistence/org.eclipse.persistence.asm/2.5.0
install -s mvn:org.eclipse.persistence/org.eclipse.persistence.core/2.5.0
install -s mvn:org.apache.geronimo.specs/geronimo-jpa_2.0_spec/1.1
install -s mvn:org.osgi/org.osgi.compendium/4.2.0
install -s mvn:org.osgi/org.osgi.enterprise/4.2.0
org.eclipse.gemini.dbaccess.derby_1.0.0.M1-incubation.jar
org.eclipse.gemini.jpa.weaving_1.0.0.RC1.jar
org.eclipse.gemini.jpa_1.0.0.RC1.jar

My persistence.xml is :-

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
    xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

    <persistence-unit name="resource" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>myPkg.entity.Resource</class>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" 
                /> <property name="javax.persistence.jdbc.url" value="jdbc:derby:DB;create=true" 
                />

            <!-- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/D:\DB;create=true" /> -->


            <property name="javax.persistence.jdbc.user" value="test" />
            <property name="javax.persistence.jdbc.password" value="test" />
            <property name="eclipselink.logging.level" value="OFF" />

            <!-- EclipseLink should create the database schema automatically -->
            <property name="eclipselink.ddl-generation" value="create-tables" />
            <property name="eclipselink.ddl-generation.output-mode"
                value="database" />
            <property name="connection.autocommit" value="false" />
            <property name="eclipselink.persistence-context.flush-mode" value="commit" /> 
            <!-- <property name="eclipselink.allow-zero-id" value="true"/> -->
        </properties>
    </persistence-unit>
</persistence>

But the gemini.dbaccess.derby_1.0.0.M1-incubation jar remians in Installed state as well as the gemini.jpa.weaving jar remains in resolved state.

Restarting the gemini.dbaccess.derby_1.0.0.M1-incubation gives the following error:-

Reason: Missing Constraint: Import-Package: org.apache.derby.client.am; version="0.0.0"

And my application gives the following error:-

Could not find data source factory in registry: org.apache.derby.jdbc.ClientDriver

I am new to using eclipseLink in OSGI ,what am i missing here ?

Manas Pratim Chamuah
  • 1,527
  • 2
  • 15
  • 33

3 Answers3

1

Apache karaf 4.0.0 has been released,this version of karaf provides eclipseLink support.

feature:install eclipselink

Therefore there is no need to use external adapters for using eclipseLink

Danubian Sailor
  • 1
  • 38
  • 145
  • 223
Manas Pratim Chamuah
  • 1,527
  • 2
  • 15
  • 33
0

Here is the content of the manifest of org.eclipse.gemini.dbaccess.derby_1.0.0.M1-incubation.jar:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Gemini DBAccess (Incubation)
Bundle-SymbolicName: org.eclipse.gemini.dbaccess.derby
Bundle-Version: 1.0.0.M1-incubation
Bundle-Activator: org.eclipse.gemini.dbaccess.derby.Activator
Bundle-Vendor: Oracle Corporation
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: javax.sql,
org.apache.derby.client.am,
org.apache.derby.jdbc,
org.osgi.framework;version="[1.3,2)",
org.osgi.service.jdbc;version="[1.0,2.0)"

There are still two unresolved dependencies on Derby binaries:

  • org.apache.derby.client.am
  • org.apache.derby.jdbc

Both lack a version number, this is why the message states 0.0.0.

The two packages are part of the derbyclient.jar file available as an OSGi bundle in the Derby binaries. The problem is that the Export-Package clause of this bundle only exposes the org.apache.derby.jdbc package.

A simple solution is the SpringSource-packaged bundle: it exposes the two required packages. Beware, it has an additional dependency on the Java transaction API.

bdulac
  • 1,686
  • 17
  • 26
  • 1
    So what sholud i do..? my Application is not running – Manas Pratim Chamuah Apr 29 '15 at 06:45
  • Download the derby archive and deploy the *derbyclient.jar* file in your container. It will provide the JDBC component as an exported package (*Export-Package* clause in the JAR MANIFEST.MF). This should solve your error. You could then face a dependency problem on the *org.apache.derby.client.am* package as it is available in the classpath but not exposed in the *Export-Package* clause. In such a case, you could have to re-package the bundle, but this is [another story](http://stackoverflow.com/a/9821072/1207019). – bdulac Apr 29 '15 at 07:17
  • The [*SpringSource*-packaged bundle](http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.derby.client&version=10.5.1000001.764942) is ready to use: it exposes the two required packages. – bdulac Apr 29 '15 at 07:26
0

First of all, make sure you have the regions feature installed with Karaf, cause if you're using a version < 4 (isn't released yet), the Apache Aries Blueprint implementation is installed by default. So if you want to stick to Gemini, this will interfere. Therefore make sure you have Regions installed. Second I think there is a feature around for installing the eclipse-link bundles. Might want to take a look at it to get the right bundles aligned.

If you would stick to the Aries Blueprint impl, then it's even simpler. Just install the following features:

feature:install jpa jta jndi 

and if you want to use the Derby, might also want to install the jdbc feature. This will give you a bunch of commands to use to connect to a db and/or create a datasource. If you use the datasource commands, you're able to create a datasource for derby database which will install the correct working derby client jars if needed.

Achim Nierbeck
  • 5,265
  • 2
  • 14
  • 22