You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Tim McCaskill <tm...@cisco.com> on 2017/06/29 18:03:22 UTC

OpenJPA connection issue with Karaf 4.0.x

I'm trying to get an application running on ServiceMix 7.0.1 which has Karaf
4.0.9 but I cannot get the entity manager to populate. I keep bashing my
head against it, but getting nowhere. 
And web searches for this error are very slim and haven't helped me much.

I have a simple case built that has a karaf command to write to an sql
database. But I seem to get an error whenever it tries to create an entity
manager for the db, so it is never set in my bundle, and I can't access the
db.


On my bundle startup I keep getting an error like this:

2017-06-27 15:28:40,048 | INFO  | mix-7.0.1/deploy | fileinstall                     
| 4 - org.apache.felix.fileinstall - 3.5.8 | Started bundle:
file:/C:/local/apache-servicemix-7.0.1/deploy/Audit_Tester-0.0.1-SNAPSHOT.jar
2017-06-27 15:28:40,052 | WARN  | udit-test-unit]) | EMFTracker                      
| 257 - org.apache.aries.jpa.support - 2.6.0 | Error while determining the
transaction type. Falling back to JTA.
<openjpa-2.4.1-r422266:1730418 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: Resource does not
exist: bundle://278.0:1/
	at
org.apache.openjpa.meta.AbstractCFMetaDataFactory.getPersistentTypeNames(AbstractCFMetaDataFactory.java:635)
	at
org.apache.openjpa.meta.MetaDataRepository.getPersistentTypeNamesInternal(MetaDataRepository.java:1478)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.meta.MetaDataRepository.getPersistentTypeNames(MetaDataRepository.java:1470)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypesInternal(MetaDataRepository.java:1522)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypes(MetaDataRepository.java:1513)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:279)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:235)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:211)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:154)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:226)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:153)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.getProperties(EntityManagerFactoryImpl.java:108)[249:org.apache.openjpa:2.4.1]
	at
org.apache.aries.jpa.support.osgi.impl.EMFTracker.getTransactionType(EMFTracker.java:96)[257:org.apache.aries.jpa.support:2.6.0]
	at
org.apache.aries.jpa.support.osgi.impl.EMFTracker.addingService(EMFTracker.java:78)[257:org.apache.aries.jpa.support:2.6.0]
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)[org.osgi.core-6.0.0.jar:]
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)[org.osgi.core-6.0.0.jar:]
	at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[org.osgi.core-6.0.0.jar:]
	at
org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)[org.osgi.core-6.0.0.jar:]
	at
org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901)[org.osgi.core-6.0.0.jar:]
	at
org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990)[org.apache.felix.framework-5.6.2.jar:]
	at
org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838)[org.apache.felix.framework-5.6.2.jar:]
	at
org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545)[org.apache.felix.framework-5.6.2.jar:]
	at
org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4578)[org.apache.felix.framework-5.6.2.jar:]
	at
org.apache.felix.framework.Felix.registerService(Felix.java:3570)[org.apache.felix.framework-5.6.2.jar:]
	at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348)[org.apache.felix.framework-5.6.2.jar:]
	at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:355)[org.apache.felix.framework-5.6.2.jar:]
	at
org.apache.aries.jpa.container.impl.ManagedEMF.createAndPublishEMF(ManagedEMF.java:132)[256:org.apache.aries.jpa.container:2.6.0]
	at
org.apache.aries.jpa.container.impl.ManagedEMF.updated(ManagedEMF.java:125)[256:org.apache.aries.jpa.container:2.6.0]
	at
org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)[3:org.apache.felix.configadmin:1.8.14]
	at
org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)[3:org.apache.felix.configadmin:1.8.14]
	at
org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)[3:org.apache.felix.configadmin:1.8.14]
	at
org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1463)[3:org.apache.felix.configadmin:1.8.14]
	at
org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1419)[3:org.apache.felix.configadmin:1.8.14]
	at
org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)[3:org.apache.felix.configadmin:1.8.14]
	at
org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)[3:org.apache.felix.configadmin:1.8.14]
	at java.lang.Thread.run(Unknown Source)[:1.8.0_121]
Caused by: java.io.IOException: Resource does not exist: bundle://278.0:1/
	at
org.apache.felix.framework.URLHandlersBundleURLConnection.<init>(URLHandlersBundleURLConnection.java:60)
	at
org.apache.felix.framework.URLHandlersBundleStreamHandler.openConnection(URLHandlersBundleStreamHandler.java:64)
	at java.net.URL.openConnection(Unknown Source)[:1.8.0_121]
	at java.net.URL.openStream(Unknown Source)[:1.8.0_121]
	at
org.apache.openjpa.lib.util.J2DoPrivHelper$43.run(J2DoPrivHelper.java:946)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.lib.util.J2DoPrivHelper$43.run(J2DoPrivHelper.java:944)[249:org.apache.openjpa:2.4.1]
	at java.security.AccessController.doPrivileged(Native Method)[:1.8.0_121]
	at
org.apache.openjpa.meta.AbstractCFMetaDataFactory.parsePersistentTypeNames(AbstractCFMetaDataFactory.java:769)[249:org.apache.openjpa:2.4.1]
	at
org.apache.openjpa.meta.AbstractCFMetaDataFactory.getPersistentTypeNames(AbstractCFMetaDataFactory.java:623)[249:org.apache.openjpa:2.4.1]
	... 35 more

I have a datasource defined as oracleds_xa, and I can query it in Karaf so I
know it is connecting.


my persistence xml looks like this:

<persistence version="2.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_2_0.xsd">
	
	<persistence-unit name="audit-test-unit" transaction-type="JTA">
	
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
	
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=oracleds_xa)</jta-data-source>
	</persistence-unit>
	
</persistence>


And then my implemented connector references that like this:

@OsgiServiceProvider(classes = {AuditConnector.class})
@Transactional(TxType.REQUIRED)
public class AuditConnectorImpl implements AuditConnector{
	
	@PersistenceContext(unitName="audit-test-unit")
	EntityManager entityManager;

    public void setEntityManager(EntityManager entityManager) {
    	Log.info("Setting Audit Connector Entity Manager.");
        this.entityManager = entityManager;
    }
	
	public void addAudit(String userId, String type, Long sourceProjectId,
String sourceId, String messageId, String correlationId, String data) {
		if (userId == null || type == null) {
			throw new NullPointerException("An audit is required to have the user id
and the audit type.");
		}
		if (entityManager == null) {
			throw new NullPointerException("Entity Manager has not been set. Cannot
save audit.");
		}
		AuditBean audit = new AuditBean(userId, type, sourceProjectId, sourceId,
messageId, correlationId, data);
		entityManager.persist(audit);
	}
}


I have a blueprint:

<!DOCTYPE blueprint>
<blueprint default-activation="eager"
	xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"
	xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
	<jpa:enable />
	<tx:enable-annotations />
</blueprint>

And I am registering the connector in the activator:

public class Activator extends BaseActivator {
	
	private static final Logger log = LoggerFactory.getLogger(Activator.class);

	protected void doStart() throws Exception {
        log.info("Starting Audit Tester Bundle");
        DBServiceFactory.getInstance().setBundleContext(bundleContext);
        
        AuditConnector auditConnector = new AuditConnectorImpl();
        register(AuditConnector.class, auditConnector);
	}

	protected void doStop() {
        log.info("Stopping Audit Tester Bundle");
		super.doStop();
	}

}




--
View this message in context: http://karaf.922171.n3.nabble.com/OpenJPA-connection-issue-with-Karaf-4-0-x-tp4050887.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: OpenJPA connection issue with Karaf 4.0.x

Posted by Tim McCaskill <tm...@cisco.com>.
For a better look at my code to my sample bundle, I have uploaded it to
bitbucket
https://bitbucket.org/tmccask/audit_tester



--
View this message in context: http://karaf.922171.n3.nabble.com/OpenJPA-connection-issue-with-Karaf-4-0-x-tp4050887p4050888.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: OpenJPA connection issue with Karaf 4.0.x

Posted by Tim McCaskill <tm...@cisco.com>.
Here is all my installed features

karaf@root>feature:list -i
Name                     | Version          | Required | State   |
Repository                | Description
------------------------------------------------------------------------------------------------------------------------------------------------
xml-specs-api            | 2.5.0            |          | Started |
camel-2.16.5              |
camel                    | 2.16.5           | x        | Started |
camel-2.16.5              |
camel-core               | 2.16.5           |          | Started |
camel-2.16.5              |
camel-spring             | 2.16.5           |          | Started |
camel-2.16.5              |
camel-blueprint          | 2.16.5           | x        | Started |
camel-2.16.5              |
camel-cxf                | 2.16.5           | x        | Started |
camel-2.16.5              |
camel-jms                | 2.16.5           | x        | Started |
camel-2.16.5              |
camel-xstream            | 2.16.5           | x        | Started |
camel-2.16.5              |
pax-jdbc-spec            | 1.1.0            |          | Started |
org.ops4j.pax.jdbc-1.1.0  | Provides OSGi JDBC Service spec
pax-jdbc                 | 1.1.0            |          | Started |
org.ops4j.pax.jdbc-1.1.0  | Provides JDBC Service support
pax-jdbc-config          | 1.1.0            | x        | Started |
org.ops4j.pax.jdbc-1.1.0  | Provides JDBC Config support
pax-jdbc-oracle          | 1.1.0            | x        | Started |
org.ops4j.pax.jdbc-1.1.0  | Provides JDBC Oracle DataSourceFactory
pax-jdbc-pool-dbcp2      | 1.1.0            | x        | Started |
org.ops4j.pax.jdbc-1.1.0  | Provides JDBC Pooling DataSourceFactory
activemq-client          | 5.14.5           |          | Started |
activemq-core-5.14.5      | ActiveMQ client libraries
activemq                 | 5.14.5           |          | Started |
activemq-core-5.14.5      | ActiveMQ broker libraries
pax-jetty                | 9.2.19.v20160908 |          | Started |
org.ops4j.pax.web-4.3.0   | Provide Jetty engine support
pax-http-jetty           | 4.3.0            |          | Started |
org.ops4j.pax.web-4.3.0   |
pax-http                 | 4.3.0            |          | Started |
org.ops4j.pax.web-4.3.0   | Implementation of the OSGI HTTP Service
pax-http-whiteboard      | 4.3.0            |          | Started |
org.ops4j.pax.web-4.3.0   | Provide HTTP Whiteboard pattern support
pax-war                  | 4.3.0            |          | Started |
org.ops4j.pax.web-4.3.0   | Provide support of a full WebContainer
cxf-specs                | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-jaxb                 | 3.1.9            |          | Started | cxf-3.1.9                
|
wss4j                    | 2.1.8            |          | Started | cxf-3.1.9                
|
cxf-core                 | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-wsdl                 | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-ws-policy            | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-ws-addr              | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-ws-rm                | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-ws-mex               | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-ws-security          | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-rt-security          | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-rt-security-saml     | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-http                 | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-http-jetty           | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-bindings-soap        | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-jaxws                | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-jaxrs                | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-databinding-aegis    | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-databinding-jaxb     | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-databinding-xmlbeans | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-features-clustering  | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-features-logging     | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-features-throttling  | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-features-metrics     | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-bindings-corba       | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-bindings-coloc       | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-bindings-object      | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-transports-local     | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-transports-jms       | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-transports-udp       | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-javascript           | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-frontend-javascript  | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf-xjc-runtime          | 3.1.9            |          | Started | cxf-3.1.9                
|
cxf                      | 3.1.9            | x        | Started | cxf-3.1.9                
|
transaction-api          | 1.2.0            |          | Started |
enterprise-4.0.9          |
transaction              | 1.3.1            | x        | Started |
enterprise-4.0.9          | OSGi Transaction Manager
jpa                      | 2.6.0            | x        | Started |
enterprise-4.0.9          | OSGi Persistence Container
openjpa                  | 2.4.1            | x        | Started |
enterprise-4.0.9          | Apache OpenJPA 2.4.x persistence engine support
jndi                     | 4.0.9            | x        | Started |
enterprise-4.0.9          | OSGi Service Registry JNDI access
jdbc                     | 4.0.9            | x        | Started |
enterprise-4.0.9          | JDBC service and commands
aries-proxy              | 4.0.9            |          | Started |
standard-4.0.9            | Aries Proxy
aries-blueprint          | 4.0.9            | x        | Started |
standard-4.0.9            | Aries Blueprint
feature                  | 4.0.9            | x        | Started |
standard-4.0.9            | Features Support
shell                    | 4.0.9            | x        | Started |
standard-4.0.9            | Karaf Shell
shell-compat             | 4.0.9            | x        | Started |
standard-4.0.9            | Karaf Shell Compatibility
deployer                 | 4.0.9            | x        | Started |
standard-4.0.9            | Karaf Deployer
bundle                   | 4.0.9            | x        | Started |
standard-4.0.9            | Provide Bundle support
config                   | 4.0.9            | x        | Started |
standard-4.0.9            | Provide OSGi ConfigAdmin support
diagnostic               | 4.0.9            | x        | Started |
standard-4.0.9            | Provide Diagnostic support
instance                 | 4.0.9            | x        | Started |
standard-4.0.9            | Provide Instance support
jaas                     | 4.0.9            | x        | Started |
standard-4.0.9            | Provide JAAS support
log                      | 4.0.9            | x        | Started |
standard-4.0.9            | Provide Log support
package                  | 4.0.9            | x        | Started |
standard-4.0.9            | Package commands and mbeans
service                  | 4.0.9            | x        | Started |
standard-4.0.9            | Provide Service support
system                   | 4.0.9            | x        | Started |
standard-4.0.9            | Provide System support
http                     | 4.0.9            |          | Started |
standard-4.0.9            | Implementation of the OSGI HTTP Service
war                      | 4.0.9            | x        | Started |
standard-4.0.9            | Turn Karaf as a full WebContainer
jetty                    | 9.2.15.v20160210 |          | Started |
standard-4.0.9            |
kar                      | 4.0.9            | x        | Started |
standard-4.0.9            | Provide KAR (KARaf archive) support
ssh                      | 4.0.9            | x        | Started |
standard-4.0.9            | Provide a SSHd server on Karaf
management               | 4.0.9            | x        | Started |
standard-4.0.9            | Provide a JMX MBeanServer and a set of MBeans in
wrap                     | 0.0.0            | x        | Started |
standard-4.0.9            | Wrap URL handler
servicemix-messaging     | 7.0.1            | x        | Started |
servicemix-features-7.0.1 |
activemq-broker-noweb    | 5.14.5           | x        | Started |
activemq-5.14.5           | Full ActiveMQ broker with default configuration
activemq-camel           | 5.14.5           | x        | Started |
activemq-5.14.5           |
activemq-blueprint       | 5.14.5           | x        | Started |
activemq-5.14.5           |
spring-dm                | 1.2.1            |          | Started |
spring-4.0.9              | Spring DM support
spring                   | 3.2.18.RELEASE_1 |          | Started |
spring-4.0.9              | Spring 3.2.x support
spring-jms               | 3.2.18.RELEASE_1 |          | Started |
spring-4.0.9              | Spring 3.2.x JMS support
spring-tx                | 3.2.18.RELEASE_1 |          | Started |
spring-4.0.9              | Spring 3.2.x Transaction (TX) support



--
View this message in context: http://karaf.922171.n3.nabble.com/OpenJPA-connection-issue-with-Karaf-4-0-x-tp4050887p4050890.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: OpenJPA connection issue with Karaf 4.0.x

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Tim,

which features are installed ? (especially jpa & transaction features)

Thanks,
Regards
JB

On 06/29/2017 08:03 PM, Tim McCaskill wrote:
> I'm trying to get an application running on ServiceMix 7.0.1 which has Karaf
> 4.0.9 but I cannot get the entity manager to populate. I keep bashing my
> head against it, but getting nowhere.
> And web searches for this error are very slim and haven't helped me much.
> 
> I have a simple case built that has a karaf command to write to an sql
> database. But I seem to get an error whenever it tries to create an entity
> manager for the db, so it is never set in my bundle, and I can't access the
> db.
> 
> 
> On my bundle startup I keep getting an error like this:
> 
> 2017-06-27 15:28:40,048 | INFO  | mix-7.0.1/deploy | fileinstall
> | 4 - org.apache.felix.fileinstall - 3.5.8 | Started bundle:
> file:/C:/local/apache-servicemix-7.0.1/deploy/Audit_Tester-0.0.1-SNAPSHOT.jar
> 2017-06-27 15:28:40,052 | WARN  | udit-test-unit]) | EMFTracker
> | 257 - org.apache.aries.jpa.support - 2.6.0 | Error while determining the
> transaction type. Falling back to JTA.
> <openjpa-2.4.1-r422266:1730418 nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: Resource does not
> exist: bundle://278.0:1/
> 	at
> org.apache.openjpa.meta.AbstractCFMetaDataFactory.getPersistentTypeNames(AbstractCFMetaDataFactory.java:635)
> 	at
> org.apache.openjpa.meta.MetaDataRepository.getPersistentTypeNamesInternal(MetaDataRepository.java:1478)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.meta.MetaDataRepository.getPersistentTypeNames(MetaDataRepository.java:1470)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypesInternal(MetaDataRepository.java:1522)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypes(MetaDataRepository.java:1513)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:279)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:235)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:211)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:154)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:226)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:153)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.getProperties(EntityManagerFactoryImpl.java:108)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.aries.jpa.support.osgi.impl.EMFTracker.getTransactionType(EMFTracker.java:96)[257:org.apache.aries.jpa.support:2.6.0]
> 	at
> org.apache.aries.jpa.support.osgi.impl.EMFTracker.addingService(EMFTracker.java:78)[257:org.apache.aries.jpa.support:2.6.0]
> 	at
> org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)[org.osgi.core-6.0.0.jar:]
> 	at
> org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)[org.osgi.core-6.0.0.jar:]
> 	at
> org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[org.osgi.core-6.0.0.jar:]
> 	at
> org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)[org.osgi.core-6.0.0.jar:]
> 	at
> org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901)[org.osgi.core-6.0.0.jar:]
> 	at
> org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990)[org.apache.felix.framework-5.6.2.jar:]
> 	at
> org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838)[org.apache.felix.framework-5.6.2.jar:]
> 	at
> org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545)[org.apache.felix.framework-5.6.2.jar:]
> 	at
> org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4578)[org.apache.felix.framework-5.6.2.jar:]
> 	at
> org.apache.felix.framework.Felix.registerService(Felix.java:3570)[org.apache.felix.framework-5.6.2.jar:]
> 	at
> org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348)[org.apache.felix.framework-5.6.2.jar:]
> 	at
> org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:355)[org.apache.felix.framework-5.6.2.jar:]
> 	at
> org.apache.aries.jpa.container.impl.ManagedEMF.createAndPublishEMF(ManagedEMF.java:132)[256:org.apache.aries.jpa.container:2.6.0]
> 	at
> org.apache.aries.jpa.container.impl.ManagedEMF.updated(ManagedEMF.java:125)[256:org.apache.aries.jpa.container:2.6.0]
> 	at
> org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)[3:org.apache.felix.configadmin:1.8.14]
> 	at
> org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)[3:org.apache.felix.configadmin:1.8.14]
> 	at
> org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)[3:org.apache.felix.configadmin:1.8.14]
> 	at
> org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1463)[3:org.apache.felix.configadmin:1.8.14]
> 	at
> org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1419)[3:org.apache.felix.configadmin:1.8.14]
> 	at
> org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)[3:org.apache.felix.configadmin:1.8.14]
> 	at
> org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)[3:org.apache.felix.configadmin:1.8.14]
> 	at java.lang.Thread.run(Unknown Source)[:1.8.0_121]
> Caused by: java.io.IOException: Resource does not exist: bundle://278.0:1/
> 	at
> org.apache.felix.framework.URLHandlersBundleURLConnection.<init>(URLHandlersBundleURLConnection.java:60)
> 	at
> org.apache.felix.framework.URLHandlersBundleStreamHandler.openConnection(URLHandlersBundleStreamHandler.java:64)
> 	at java.net.URL.openConnection(Unknown Source)[:1.8.0_121]
> 	at java.net.URL.openStream(Unknown Source)[:1.8.0_121]
> 	at
> org.apache.openjpa.lib.util.J2DoPrivHelper$43.run(J2DoPrivHelper.java:946)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.lib.util.J2DoPrivHelper$43.run(J2DoPrivHelper.java:944)[249:org.apache.openjpa:2.4.1]
> 	at java.security.AccessController.doPrivileged(Native Method)[:1.8.0_121]
> 	at
> org.apache.openjpa.meta.AbstractCFMetaDataFactory.parsePersistentTypeNames(AbstractCFMetaDataFactory.java:769)[249:org.apache.openjpa:2.4.1]
> 	at
> org.apache.openjpa.meta.AbstractCFMetaDataFactory.getPersistentTypeNames(AbstractCFMetaDataFactory.java:623)[249:org.apache.openjpa:2.4.1]
> 	... 35 more
> 
> I have a datasource defined as oracleds_xa, and I can query it in Karaf so I
> know it is connecting.
> 
> 
> my persistence xml looks like this:
> 
> <persistence version="2.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_2_0.xsd">
> 	
> 	<persistence-unit name="audit-test-unit" transaction-type="JTA">
> 	
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> 	
> <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=oracleds_xa)</jta-data-source>
> 	</persistence-unit>
> 	
> </persistence>
> 
> 
> And then my implemented connector references that like this:
> 
> @OsgiServiceProvider(classes = {AuditConnector.class})
> @Transactional(TxType.REQUIRED)
> public class AuditConnectorImpl implements AuditConnector{
> 	
> 	@PersistenceContext(unitName="audit-test-unit")
> 	EntityManager entityManager;
> 
>      public void setEntityManager(EntityManager entityManager) {
>      	Log.info("Setting Audit Connector Entity Manager.");
>          this.entityManager = entityManager;
>      }
> 	
> 	public void addAudit(String userId, String type, Long sourceProjectId,
> String sourceId, String messageId, String correlationId, String data) {
> 		if (userId == null || type == null) {
> 			throw new NullPointerException("An audit is required to have the user id
> and the audit type.");
> 		}
> 		if (entityManager == null) {
> 			throw new NullPointerException("Entity Manager has not been set. Cannot
> save audit.");
> 		}
> 		AuditBean audit = new AuditBean(userId, type, sourceProjectId, sourceId,
> messageId, correlationId, data);
> 		entityManager.persist(audit);
> 	}
> }
> 
> 
> I have a blueprint:
> 
> <!DOCTYPE blueprint>
> <blueprint default-activation="eager"
> 	xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0"
> xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"
> 	xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
> https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
> 	<jpa:enable />
> 	<tx:enable-annotations />
> </blueprint>
> 
> And I am registering the connector in the activator:
> 
> public class Activator extends BaseActivator {
> 	
> 	private static final Logger log = LoggerFactory.getLogger(Activator.class);
> 
> 	protected void doStart() throws Exception {
>          log.info("Starting Audit Tester Bundle");
>          DBServiceFactory.getInstance().setBundleContext(bundleContext);
>          
>          AuditConnector auditConnector = new AuditConnectorImpl();
>          register(AuditConnector.class, auditConnector);
> 	}
> 
> 	protected void doStop() {
>          log.info("Stopping Audit Tester Bundle");
> 		super.doStop();
> 	}
> 
> }
> 
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/OpenJPA-connection-issue-with-Karaf-4-0-x-tp4050887.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com