osgi - ServiceMix / Blueprint / JPA Integration -


i have been spending week attempting integrate jpa / servicemix 4.5.1 / camel-jpa 2.10.4 / blueprint together. i'm using openjpa, not tied it. version of aries jpa used servicemix 0.3.0.

the stack trace cannot past is:

org.osgi.service.blueprint.container.componentdefinitionexception: error when instanciating bean workoutentity of class class [...].workoutentity @ org.apache.aries.blueprint.container.beanrecipe.getinstance(beanrecipe.java:271)[10:org.apache.aries.blueprint:0.3.2] @ org.apache.aries.blueprint.container.beanrecipe.internalcreate(beanrecipe.java:708)[10:org.apache.aries.blueprint:0.3.2] @ org.apache.aries.blueprint.di.abstractrecipe.create(abstractrecipe.java:64)[10:org.apache.aries.blueprint:0.3.2] @ org.apache.aries.blueprint.di.refrecipe.internalcreate(refrecipe.java:60)[10:org.apache.aries.blueprint:0.3.2] @ org.apache.aries.blueprint.di.abstractrecipe.create(abstractrecipe.java:64)[10:org.apache.aries.blueprint:0.3.2] @ org.apache.aries.blueprint.container.blueprintrepository.createinstances(blueprintrepository.java:219)[10:org.apache.aries.blueprint:0.3.2] [...] caused by: <openjpa-2.2.0-r422266:1244990 nonfatal general error> org.apache.openjpa.persistence.persistenceexception: [javax.sql.datasource] @ org.apache.openjpa.kernel.abstractbrokerfactory.newbroker(abstractbrokerfactory.java:218) @ org.apache.openjpa.kernel.delegatingbrokerfactory.newbroker(delegatingbrokerfactory.java:156) @ org.apache.openjpa.persistence.entitymanagerfactoryimpl.createentitymanager(entitymanagerfactoryimpl.java:227)  [...] caused by: java.lang.illegalargumentexception: [javax.sql.datasource] @ org.apache.aries.jndi.services.servicehelper.proxypriviledged(servicehelper.java:348) @ org.apache.aries.jndi.services.servicehelper.access$700(servicehelper.java:65) @ org.apache.aries.jndi.services.servicehelper$1.run(servicehelper.java:285) @ java.security.accesscontroller.doprivileged(native method)[:1.6.0_43] [...] 

i've attempted several variations. here current configuration:

persistence.xml:

<persistence-unit name="customer1" transaction-type="jta">      <provider>org.apache.openjpa.persistence.persistenceproviderimpl</provider>      <jta-data-source>osgi:service/javax.sql.datasource/(osgi.jndi.service.name=jdbc/prototypedb)</jta-data-source>      <class>...</class> </persistence-unit> 

camel-context.xml

<service id="prototypedb" interface="javax.sql.datasource">     <service-properties>         <entry key="osgi.jndi.service.name" value="jdbc/prototypedb"/>     </service-properties>     <bean class="org.apache.commons.dbcp.basicdatasource">         <property name="driverclassname"        value="com.mysql.jdbc.driver"/>         <property name="url"                    value="jdbc:mysql://localhost:3306/prototype"/>         <property name="username"               value="root"/>         <property name="password"               value="..."/>     </bean> </service>  <service ref="workoutentity" interface="..."/> <bean id="workoutentity" class="...">     <jpa:unit index="0"         unitname="customer1" />     <tx:transaction method="*"  value="required"/> </bean> 

entity bean (written in groovy)

@entity @table(name='customer1') @slf4j class workoutentity implements iworkoutentity{      private entitymanager entitymanager      workoutentity(final entitymanagerfactory entitymanagerfactory) {         this.entitymanager = entitymanagerfactory.createentitymanager()     }      @handler     void create( @body final string input) {          // ...     } } 

i've attempted multiple different implementations of datasource, including basicdatasource, org.springframework.jdbc.datasource.simpledriverdatasource, , com.mysql.jdbc.jdbc2.optional.mysqldatasource. cause illegalargumentexception.

i've attempted forego using jndi , instead define data source directly in persistence.xml. causes classnotfoundexception in openjpa bundle, not importing mysql driver. i'd prefer define in camel-context.xml , prefer not re-bundle openjpa jar.

you need aries jndi features installed. helps call osgi services via jndi lookups. should missing piece.


Comments