Hi, yes, in the latest version of my application I've used JNDI to let the JPA to pick up the DataSource but there is still a problem with the configuration parameters of the JPA implementation which does not seem really easy to change outside the persistence.xml
On Fri, Feb 3, 2012 at 10:49, Timothy Ward <[email protected]> wrote: > Right, > > looking through the code, the JPA namespace handler does not (and can't > easily) participate with property placeholder support. On the other hand, > your datasource can be pulled from the service registry. If you use a > Datasource JNDI name of osgi:service/javax.sql.DataSource/(myProp=myValue) > then you can pick the datasource service using service properties. If you > make the DataSource service a Managed Service then you can use config admin > to change the backing service at runtime. This should be transparently > picked up by the JPA container. > > > Regards, > > Tim Ward > ------------------- > Apache Aries PMC member & Enterprise OSGi advocate > Enterprise OSGi in Action (http://www.manning.com/cummins) > ------------------- > > > ------------------------------ > Date: Thu, 2 Feb 2012 21:22:01 +0100 > > Subject: Re: JPA extended persistence exception > From: [email protected] > To: [email protected] > > Hi, > > I'm quite new to JPA, in fact I've simply copied &pasted the example from > Aries JPA page. > I've removed type="EXTENDED" from the XML but I've experienced the same > problem: is there a way to achieve my goal ? > > Regards > > On Wed, Feb 1, 2012 at 09:52, Timothy Ward <[email protected]>wrote: > > Hi, > > Sorry, I should have been clearer with my question. What I was trying to > find out was the usage pattern for the EntityManager. Why does it need to > be extended scope? The number of use cases for extended scope is > significantly smaller than the number of use cases for a transaction scope > entity manager, which is why transaction scope is the default. As I > mentioned before extended scope EntityManagers are not supported by the > Aries JPA container, except when injected into stateful EJBs by the Aries > EJB component. I'm hoping to help you avoid the next problem I see on the > horizon. > > Regards, > > > > Tim Ward > ------------------- > Apache Aries PMC member & Enterprise OSGi advocate > Enterprise OSGi in Action (http://www.manning.com/cummins) > ------------------- > > > ------------------------------ > Date: Tue, 31 Jan 2012 23:31:05 +0100 > Subject: Re: JPA extended persistence exception > > From: [email protected] > To: [email protected] > > Hi, > > the goal is simple: configure some JPA properties via ConfigAdmin (so, no > need to re-deploy a bundle fo simple tweaks). > > In the example, the configurable property is javax.persistence.jdbc.url > but it could be applied to any property (e.g. it would be nice to set the > logging level of the chosen JPA implementation). > > Luca > > On Tue, Jan 31, 2012 at 18:00, Timothy Ward <[email protected]>wrote: > > Hi, > > That's not an error I have seen before, and it has me a little stumped. I > can look into it, but I can also warn you that EXTENDED scope > EntityManagers are only supported by the Aries EJB component (Extended > scope is defined in terms of Stateful Session Beans). What is it that you > are trying to accomplish? > > Tim Ward > ------------------- > Apache Aries PMC member & Enterprise OSGi advocate > Enterprise OSGi in Action (http://www.manning.com/cummins) > ------------------- > > > ------------------------------ > Date: Tue, 31 Jan 2012 11:51:39 +0100 > Subject: JPA extended persistence exception > From: [email protected] > To: [email protected] > > > Hi, > I've deployed the following blueprint xml on Karaf (2.2.5) : > > <blueprint > xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" > xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.1.0" > xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"> > > <cm:property-placeholder persistent-id="DM-CFG"> > <cm:default-properties> > <cm:property name="jdbc.url" > value="jdbc:derby:./data/jpa;create=true"/> > </cm:default-properties> > </cm:property-placeholder> > > <bean id="DM" class="lb.sandbox.osgi.jpa.DataManager" init-method="init"> > <jpa:context property="em" unitname="LBU" type="EXTENDED"> > <map> > <entry key="javax.persistence.jdbc.url" value="${jdbc.url}"/> > </map> > </jpa:context> > </bean> > > <service ref="DM" interface="lb.sandbox.osgi.jpa.IDataManager"/> > > </blueprint> > > But I got the following exception even the example has been taken from the > Aries webpage : > > 2012-01-20 15:55:22,471 | ERROR | rint Extender: 1 | > BlueprintContainerImpl | container.BlueprintContainerImpl 358 | > 9 - org.apache.aries.blueprint - 0.3.1 | Unable to start blueprint > container for bundle lb.sandbox.osgi.jpa > org.osgi.service.blueprint.container.ComponentDefinitionException: Unable > to validate xml > at > org.apache.aries.blueprint.container.Parser.validate(Parser.java:288)[9:org.apache.aries.blueprint:0.3.1] > > at > org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:275)[9:org.apache.aries.blueprint:0.3.1] > > at > org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:227)[9:org.apache.aries.blueprint:0.3.1] > > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)[:1.6.0_29] > > at > java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_29] > > at > java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_29] > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)[:1.6.0_29] > > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)[:1.6.0_29] > > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_29] > > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_29] > > at java.lang.Thread.run(Thread.java:662)[:1.6.0_29] > Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid > content was found starting with element 'map'. One of '{" > http://aries.apache.org/xmlns/jpa/v1.1.0":map}' is expected. > at > com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)[:1.6.0_29] > > at > com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)[:1.6.0_29] > > at > com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)[:1.6.0_29] > > at > com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)[:1.6.0_29] > > at > com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:417)[:1.6.0_29] > > at > com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3182)[:1.6.0_29] > > at > com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1806)[:1.6.0_29] > > at > com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)[:1.6.0_29] > > at > com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.beginNode(DOMValidatorHelper.java:273)[:1.6.0_29] > > at > com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:240)[:1.6.0_29] > > at > com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:186)[:1.6.0_29] > > at > com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:104)[:1.6.0_29] > > at > javax.xml.validation.Validator.validate(Validator.java:127)[:1.6.0_29] > at > org.apache.aries.blueprint.container.Parser.validate(Parser.java:285)[9:org.apache.aries.blueprint:0.3.1] > > ... 10 more > > What's wrong ? > > > >
