Apache ServiceMix 5.4.0

persistence.xml in Bundle x

<persistence 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_2_0.xsd";
             version="2.0">

    <persistence-unit name="x_cassandra_pu" transaction-type="RESOURCE_LOCAL">
        <provider>com.impetus.kundera.KunderaPersistence</provider>
        <class>stats.Stats</class>
         <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
            <property name="kundera.nodes" value="localhost"/>
            <property name="kundera.port" value="9042"/>
            <property name="kundera.keyspace" value="x"/>
            <property name="kundera.dialect" value="cassandra"/>
            <property name="kundera.client.lookup.class"
                      
value="com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory"/>
            <!--<property name="kundera.port" value="9160"/>-->
            <!--<property name="kundera.ddl.auto.prepare" value="create"/>-->
            <!--<property name="kundera.client.lookup.class" 
value="com.impetus.client.cassandra.thrift.ThriftClientFactory"/>-->
        </properties>
    </persistence-unit>

</persistence>


the logs after start Bundle x:

2017-12-14 14:57:24,701 | INFO  | l Console Thread | 
BlueprintContainerImpl           | 18 - org.apache.aries.blueprint.core - 
1.4.2 | Bundle x is waiting for dependencies 
[(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=x_cassandra_pu))(objectClass=javax.persistence.EntityManagerFactory))]
2017-12-14 14:57:24,701 | WARN  | l Console Thread | container              
          | 191 - org.apache.aries.jpa.container - 1.0.2 | There are no 
providers available.
2017-12-14 15:02:24,707 | ERROR | rint Extender: 2 | 
BlueprintContainerImpl           | 18 - org.apache.aries.blueprint.core - 
1.4.2 | Unable to start blueprint container for bundle x due to unresolved 
dependencies 
[(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=x_cassandra_pu))(objectClass=javax.persistence.EntityManagerFactory))]


karaf@root> list -t 0|grep -i jpa
[ 190] [Active     ] [            ] [       ] [   20] hibernate-jpa-2.1-api 
(1.0.0.Final)
[ 191] [Active     ] [            ] [       ] [   30] Aries JPA Container 
(1.0.2)
[ 192] [Active     ] [            ] [       ] [   30] Aries JPA Container 
API (1.0.2)
[ 193] [Active     ] [            ] [       ] [   30] Aries JPA Container 
Managed Contexts (1.0.4)
[ 194] [Active     ] [Created     ] [       ] [   30] Aries JPA Container 
blueprint integration for Aries blueprint (1.0.4)

karaf@root> ls
Kundera (291) provides:
------------------------------------------
[javax.persistence.spi.PersistenceProvider]

Bundle Kundera code:

package persistence.osgi;

import java.util.Hashtable;

import com.impetus.kundera.KunderaPersistence;
import org.osgi.framework.*;

import javax.persistence.spi.PersistenceProvider;


public class PersistenceActivator implements BundleActivator, BundleListener {
    public static final String PERSISTENCE_PROVIDER_ARIES = 
"javax.persistence.provider";
    public static final String PERSISTENCE_PROVIDER = 
PersistenceProvider.class.getName();
    public static final String OSGI_PERSISTENCE_PROVIDER = 
KunderaPersistence.class.getName();

    private static BundleContext ctx = null;
    private static ServiceRegistration svcReg = null;

    public void start(BundleContext ctx) throws Exception {
        this.ctx = ctx;
        final Hashtable<String, String> props = new Hashtable();
        props.put(PERSISTENCE_PROVIDER_ARIES, OSGI_PERSISTENCE_PROVIDER);
        props.put(PERSISTENCE_PROVIDER, OSGI_PERSISTENCE_PROVIDER);
        //props.put("javax.persistence.PersistenceProvider", 
OSGI_PERSISTENCE_PROVIDER);

        PersistenceProvider provider = new KunderaPersistence();
        svcReg = ctx.registerService(PERSISTENCE_PROVIDER, provider, props);
        ctx.addBundleListener(this);
    }

    public void stop(BundleContext ctx) throws Exception {
        if (svcReg != null) {
            svcReg.unregister();
            svcReg = null;
        }
        ctx.removeBundleListener(this);
    }

    public void bundleChanged(BundleEvent event) {
        String symbolicName = event.getBundle().getSymbolicName();
        String type = typeAsString(event);
        System.out.println("BundleChanged: " + symbolicName + ", event.type: " 
+ type);
    }

    private static String typeAsString(BundleEvent event) {
        if (event == null) {
            return "null";
        }
        int type = event.getType();
        switch (type) {
            case BundleEvent.INSTALLED:
                return "INSTALLED";
            case BundleEvent.LAZY_ACTIVATION:
                return "LAZY_ACTIVATION";
            case BundleEvent.RESOLVED:
                return "RESOLVED";
            case BundleEvent.STARTED:
                return "STARTED";
            case BundleEvent.STARTING:
                return "Starting";
            case BundleEvent.STOPPED:
                return "STOPPED";
            case BundleEvent.UNINSTALLED:
                return "UNINSTALLED";
            case BundleEvent.UNRESOLVED:
                return "UNRESOLVED";
            case BundleEvent.UPDATED:
                return "UPDATED";
            default:
                return "unknown event type: " + type;
        }
    }
}

-- 
-- 
------------------
OPS4J - http://www.ops4j.org - [email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to