Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

classic Classic list List threaded Threaded
51 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt

Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Christian Schneider
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian

On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
Having problems getting this to work. I get the following in the log file:

2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-db
2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-db

No EntityManagerFactory service is being created.

Looks like I've missed something. The only changes I've made is the blueprint xml and the injection of the EntityManager using the annotation. Do I need to change anything else, like the persistence.xml?

/Bengt

2016-07-06 10:24 GMT+02:00 Bengt Rodehav <[hidden email]>:
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Christian Schneider
If no EntityManagerFactory service is created then this is not a problem with the blueprint.
Do you have the Meta-Persistence manifest entry?
See
https://github.com/cschneider/Karaf-Tutorial/blob/master/tasklist-ds/model/bnd.bnd

As soon as you have the entry you should see in the log that Aries JPA parses the persistence xml and tries to create the EMF. It should report in the log if something is missing.

For the blueprint you have to add the enable Elements for jpa and tx as they create the interceptors.

Christian

On 06.07.2016 10:51, Bengt Rodehav wrote:
Having problems getting this to work. I get the following in the log file:

2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-db
2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-db

No EntityManagerFactory service is being created.

Looks like I've missed something. The only changes I've made is the blueprint xml and the injection of the EntityManager using the annotation. Do I need to change anything else, like the persistence.xml?

/Bengt

2016-07-06 10:24 GMT+02:00 Bengt Rodehav <[hidden email]>:
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com




-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
I do have the correct information in the manifest:

Meta-Persistence: META-INF/persistence.xml

But I think this indicates that something is wrong:

2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain


What is the SPI-provider?

/Bengt

2016-07-06 11:04 GMT+02:00 Christian Schneider <[hidden email]>:
If no EntityManagerFactory service is created then this is not a problem with the blueprint.
Do you have the Meta-Persistence manifest entry?
See
https://github.com/cschneider/Karaf-Tutorial/blob/master/tasklist-ds/model/bnd.bnd

As soon as you have the entry you should see in the log that Aries JPA parses the persistence xml and tries to create the EMF. It should report in the log if something is missing.

For the blueprint you have to add the enable Elements for jpa and tx as they create the interceptors.

Christian


On 06.07.2016 10:51, Bengt Rodehav wrote:
Having problems getting this to work. I get the following in the log file:

2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-db
2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-db

No EntityManagerFactory service is being created.

Looks like I've missed something. The only changes I've made is the blueprint xml and the injection of the EntityManager using the annotation. Do I need to change anything else, like the persistence.xml?

/Bengt

2016-07-06 10:24 GMT+02:00 Bengt Rodehav <[hidden email]>:
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com




-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
Actually a more complete log says:

2016-07-06 13:35:13,732 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker  102 | Found persistence unit filetransferhistoryPU in bundle se.digia.connect.services.filetransfer.history-domain with provider org.apache.openjpa.persistence.PersistenceProviderImpl.
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker   93 | Persistence units added for bundle se.digia.connect.services.filetransfer.history-domain event 128
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain

This sounds like the persistence units have been added but there is something wrong with the "SPI-provider".

/Bengt


2016-07-06 13:36 GMT+02:00 Bengt Rodehav <[hidden email]>:
I do have the correct information in the manifest:

Meta-Persistence: META-INF/persistence.xml

But I think this indicates that something is wrong:

2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain


What is the SPI-provider?

/Bengt

2016-07-06 11:04 GMT+02:00 Christian Schneider <[hidden email]>:
If no EntityManagerFactory service is created then this is not a problem with the blueprint.
Do you have the Meta-Persistence manifest entry?
See
https://github.com/cschneider/Karaf-Tutorial/blob/master/tasklist-ds/model/bnd.bnd

As soon as you have the entry you should see in the log that Aries JPA parses the persistence xml and tries to create the EMF. It should report in the log if something is missing.

For the blueprint you have to add the enable Elements for jpa and tx as they create the interceptors.

Christian


On 06.07.2016 10:51, Bengt Rodehav wrote:
Having problems getting this to work. I get the following in the log file:

2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-db
2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-db

No EntityManagerFactory service is being created.

Looks like I've missed something. The only changes I've made is the blueprint xml and the injection of the EntityManager using the annotation. Do I need to change anything else, like the persistence.xml?

/Bengt

2016-07-06 10:24 GMT+02:00 Bengt Rodehav <[hidden email]>:
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com




-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Christian Schneider
You can ignore these messages. they come from Aries spi-fly and simply say that spi-fly looked into your bundle and decided that it does not need to do anything. I have committed a change to spi-fly recently to log these messages only on level debug as they confuse a lot of people.

Christian

2016-07-06 13:37 GMT+02:00 Bengt Rodehav <[hidden email]>:
Actually a more complete log says:

2016-07-06 13:35:13,732 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker  102 | Found persistence unit filetransferhistoryPU in bundle se.digia.connect.services.filetransfer.history-domain with provider org.apache.openjpa.persistence.PersistenceProviderImpl.
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker   93 | Persistence units added for bundle se.digia.connect.services.filetransfer.history-domain event 128
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain

This sounds like the persistence units have been added but there is something wrong with the "SPI-provider".

/Bengt


2016-07-06 13:36 GMT+02:00 Bengt Rodehav <[hidden email]>:
I do have the correct information in the manifest:

Meta-Persistence: META-INF/persistence.xml

But I think this indicates that something is wrong:

2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain


What is the SPI-provider?

/Bengt

2016-07-06 11:04 GMT+02:00 Christian Schneider <[hidden email]>:
If no EntityManagerFactory service is created then this is not a problem with the blueprint.
Do you have the Meta-Persistence manifest entry?
See
https://github.com/cschneider/Karaf-Tutorial/blob/master/tasklist-ds/model/bnd.bnd

As soon as you have the entry you should see in the log that Aries JPA parses the persistence xml and tries to create the EMF. It should report in the log if something is missing.

For the blueprint you have to add the enable Elements for jpa and tx as they create the interceptors.

Christian


On 06.07.2016 10:51, Bengt Rodehav wrote:
Having problems getting this to work. I get the following in the log file:

2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-db
2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-db

No EntityManagerFactory service is being created.

Looks like I've missed something. The only changes I've made is the blueprint xml and the injection of the EntityManager using the annotation. Do I need to change anything else, like the persistence.xml?

/Bengt

2016-07-06 10:24 GMT+02:00 Bengt Rodehav <[hidden email]>:
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com




-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com





--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
OK - thanks Christian.

Do you have any idea why the EntityManagerFactory service does not seem to be published. The logging implies that the persistence unit is found and added. What could be missing?

/Bengt

2016-07-06 19:36 GMT+02:00 Christian Schneider <[hidden email]>:
You can ignore these messages. they come from Aries spi-fly and simply say that spi-fly looked into your bundle and decided that it does not need to do anything. I have committed a change to spi-fly recently to log these messages only on level debug as they confuse a lot of people.

Christian

2016-07-06 13:37 GMT+02:00 Bengt Rodehav <[hidden email]>:
Actually a more complete log says:

2016-07-06 13:35:13,732 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker  102 | Found persistence unit filetransferhistoryPU in bundle se.digia.connect.services.filetransfer.history-domain with provider org.apache.openjpa.persistence.PersistenceProviderImpl.
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker   93 | Persistence units added for bundle se.digia.connect.services.filetransfer.history-domain event 128
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain

This sounds like the persistence units have been added but there is something wrong with the "SPI-provider".

/Bengt


2016-07-06 13:36 GMT+02:00 Bengt Rodehav <[hidden email]>:
I do have the correct information in the manifest:

Meta-Persistence: META-INF/persistence.xml

But I think this indicates that something is wrong:

2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain


What is the SPI-provider?

/Bengt

2016-07-06 11:04 GMT+02:00 Christian Schneider <[hidden email]>:
If no EntityManagerFactory service is created then this is not a problem with the blueprint.
Do you have the Meta-Persistence manifest entry?
See
https://github.com/cschneider/Karaf-Tutorial/blob/master/tasklist-ds/model/bnd.bnd

As soon as you have the entry you should see in the log that Aries JPA parses the persistence xml and tries to create the EMF. It should report in the log if something is missing.

For the blueprint you have to add the enable Elements for jpa and tx as they create the interceptors.

Christian


On 06.07.2016 10:51, Bengt Rodehav wrote:
Having problems getting this to work. I get the following in the log file:

2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-db
2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-db

No EntityManagerFactory service is being created.

Looks like I've missed something. The only changes I've made is the blueprint xml and the injection of the EntityManager using the annotation. Do I need to change anything else, like the persistence.xml?

/Bengt

2016-07-06 10:24 GMT+02:00 Bengt Rodehav <[hidden email]>:
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com




-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com





--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Christian Schneider
The first thing Aries JPA does after finding the bundle is to locate a suitable PersistenceProvider service. So one thing to check is of the openjpa PersistenceProvider service is registered.

I am pretty sure the problem is with the openjpa version though. Openjpa 2.4.0 does not support JTA 1.2. In the newest karaf version there should be a feature for openjpa 2.4.1 which should work
with JTA 1.2. This is important as Aries JPA 2 requires JTA 1.2 for the @Transactional support.

Another issue might be with the JPA api version. Openjpa is only compatible to jpa 2.0. So you have to make sure your own bundle does not depend on jpa 2.1.

Christian

On 07.07.2016 09:10, Bengt Rodehav wrote:
OK - thanks Christian.

Do you have any idea why the EntityManagerFactory service does not seem to be published. The logging implies that the persistence unit is found and added. What could be missing?

/Bengt

2016-07-06 19:36 GMT+02:00 Christian Schneider <[hidden email]>:
You can ignore these messages. they come from Aries spi-fly and simply say that spi-fly looked into your bundle and decided that it does not need to do anything. I have committed a change to spi-fly recently to log these messages only on level debug as they confuse a lot of people.

Christian

2016-07-06 13:37 GMT+02:00 Bengt Rodehav <[hidden email]>:
Actually a more complete log says:

2016-07-06 13:35:13,732 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker  102 | Found persistence unit filetransferhistoryPU in bundle se.digia.connect.services.filetransfer.history-domain with provider org.apache.openjpa.persistence.PersistenceProviderImpl.
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker   93 | Persistence units added for bundle se.digia.connect.services.filetransfer.history-domain event 128
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain

This sounds like the persistence units have been added but there is something wrong with the "SPI-provider".

/Bengt


2016-07-06 13:36 GMT+02:00 Bengt Rodehav <[hidden email]>:
I do have the correct information in the manifest:

Meta-Persistence: META-INF/persistence.xml

But I think this indicates that something is wrong:

2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain


What is the SPI-provider?

/Bengt

2016-07-06 11:04 GMT+02:00 Christian Schneider <[hidden email]>:
If no EntityManagerFactory service is created then this is not a problem with the blueprint.
Do you have the Meta-Persistence manifest entry?
See
https://github.com/cschneider/Karaf-Tutorial/blob/master/tasklist-ds/model/bnd.bnd

As soon as you have the entry you should see in the log that Aries JPA parses the persistence xml and tries to create the EMF. It should report in the log if something is missing.

For the blueprint you have to add the enable Elements for jpa and tx as they create the interceptors.

Christian


On 06.07.2016 10:51, Bengt Rodehav wrote:
Having problems getting this to work. I get the following in the log file:

2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-db
2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-db

No EntityManagerFactory service is being created.

Looks like I've missed something. The only changes I've made is the blueprint xml and the injection of the EntityManager using the annotation. Do I need to change anything else, like the persistence.xml?

/Bengt

2016-07-06 10:24 GMT+02:00 Bengt Rodehav <[hidden email]>:
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com




-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com





--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
Thanks a lot for your reply Christian.

It does sound like I have a versioning problem. I was  very unsure about what versions of jpa/jta/openjpa to use when upgrading from Karaf 2.4.1.

As it stands, I use 

- OpenJPA 2.4.1 (I use the Karaf "openjpa" feature version 2.4.1)
- JTA version 1.1 at compile time but JTA 1.2 seems to be installed at runtime. Probably due to the "openjpa" 2.4.1 feature requiring it
- JPA. In runtime both 1.1 and 2.1 are installed. The former because I compile against it and the latter due to the "openjpa" 2.4.1 feature (I think)

Wow what a mess, thanks for pointing this out.

So, if I want to use "the latest and greatest" I should use (both at compile time and runtime of course):

- OpenJPA 2.4.1 (I guess this one is OK since I do use it)
- JTA 1.2 (Need to change the compile version)
- JPA 2.1 (Need to change the compile version)

Does that sound OK?


How do I check if OpenJPA is up-and-running properly?

service:list PersistenceProvider gives me this:

[javax.persistence.spi.PersistenceProvider]
-------------------------------------------
 javax.persistence.provider = org.apache.openjpa.persistence.PersistenceProviderImpl
 javax.persistence.spi.PersistenceProvider = org.apache.openjpa.persistence.PersistenceProviderImpl
 service.bundleid = 106
 service.id = 309
 service.scope = singleton
Provided by :
 OpenJPA Aggregate Jar (106)
Used by:
 Apache Geronimo JSR-317 JPA 2.0 Spec API (70)


/Bengt


2016-07-07 9:23 GMT+02:00 Christian Schneider <[hidden email]>:
The first thing Aries JPA does after finding the bundle is to locate a suitable PersistenceProvider service. So one thing to check is of the openjpa PersistenceProvider service is registered.

I am pretty sure the problem is with the openjpa version though. Openjpa 2.4.0 does not support JTA 1.2. In the newest karaf version there should be a feature for openjpa 2.4.1 which should work
with JTA 1.2. This is important as Aries JPA 2 requires JTA 1.2 for the @Transactional support.

Another issue might be with the JPA api version. Openjpa is only compatible to jpa 2.0. So you have to make sure your own bundle does not depend on jpa 2.1.

Christian


On 07.07.2016 09:10, Bengt Rodehav wrote:
OK - thanks Christian.

Do you have any idea why the EntityManagerFactory service does not seem to be published. The logging implies that the persistence unit is found and added. What could be missing?

/Bengt

2016-07-06 19:36 GMT+02:00 Christian Schneider <[hidden email]>:
You can ignore these messages. they come from Aries spi-fly and simply say that spi-fly looked into your bundle and decided that it does not need to do anything. I have committed a change to spi-fly recently to log these messages only on level debug as they confuse a lot of people.

Christian

2016-07-06 13:37 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
Actually a more complete log says:

2016-07-06 13:35:13,732 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker  102 | Found persistence unit filetransferhistoryPU in bundle se.digia.connect.services.filetransfer.history-domain with provider org.apache.openjpa.persistence.PersistenceProviderImpl.
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker   93 | Persistence units added for bundle se.digia.connect.services.filetransfer.history-domain event 128
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain

This sounds like the persistence units have been added but there is something wrong with the "SPI-provider".

/Bengt


2016-07-06 13:36 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
I do have the correct information in the manifest:

Meta-Persistence: META-INF/persistence.xml

But I think this indicates that something is wrong:

2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain


What is the SPI-provider?

/Bengt

2016-07-06 11:04 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
If no EntityManagerFactory service is created then this is not a problem with the blueprint.
Do you have the Meta-Persistence manifest entry?
See
https://github.com/cschneider/Karaf-Tutorial/blob/master/tasklist-ds/model/bnd.bnd

As soon as you have the entry you should see in the log that Aries JPA parses the persistence xml and tries to create the EMF. It should report in the log if something is missing.

For the blueprint you have to add the enable Elements for jpa and tx as they create the interceptors.

Christian


On 06.07.2016 10:51, Bengt Rodehav wrote:
Having problems getting this to work. I get the following in the log file:

2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-db
2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-db

No EntityManagerFactory service is being created.

Looks like I've missed something. The only changes I've made is the blueprint xml and the injection of the EntityManager using the annotation. Do I need to change anything else, like the persistence.xml?

/Bengt

2016-07-06 10:24 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com




-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com





--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
Reading your post again Christian I realize that I should not use JPA 2.1 but JPA 2.0.

I seem to have JPA 2.0 and JPA 2.1 installed at runtime:

karaf@root()> la | grep -i jpa
 37 | Active   |  80 | 2.3.0                 | Apache Aries JPA Container API
 38 | Active   |  80 | 2.3.0                 | Apache Aries JPA blueprint
 39 | Active   |  80 | 2.3.0                 | Apache Aries JPA container
 40 | Active   |  80 | 2.3.0                 | Apache Aries JPA support
 70 | Active   |  80 | 1.1                   | Apache Geronimo JSR-317 JPA 2.0 Spec API
106 | Active   |  80 | 2.4.1                 | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
 17 | Active   |  80 | 2.1.0.v201304241213   | Java Persistence API 2.1
175 | Active   |  80 | 2.8.0.SNAPSHOT        | Connect :: persistence-util

I don't really know why the JPA version 2.1 (2.1.0.v201304241213) is being installed. I do not do this explicitly.

Looking at OpenJPA 2.4.1, it seems to depend on JTA 1.1 not JTA 1.2.

Looked again at my JPA version. I do use JPA 2.0. But I use version 1.1 of artifact geronimo-jpa_2.0_spec which caused me to believe I was using JPA 1.1....

I'm still kind of confused. It would be thankful if you could tell me what features (and versions of those features) I should install in order to use the latest version (2.4.1) of OpenJPA.

/Bengt




2016-07-07 9:54 GMT+02:00 Bengt Rodehav <[hidden email]>:
Thanks a lot for your reply Christian.

It does sound like I have a versioning problem. I was  very unsure about what versions of jpa/jta/openjpa to use when upgrading from Karaf 2.4.1.

As it stands, I use 

- OpenJPA 2.4.1 (I use the Karaf "openjpa" feature version 2.4.1)
- JTA version 1.1 at compile time but JTA 1.2 seems to be installed at runtime. Probably due to the "openjpa" 2.4.1 feature requiring it
- JPA. In runtime both 1.1 and 2.1 are installed. The former because I compile against it and the latter due to the "openjpa" 2.4.1 feature (I think)

Wow what a mess, thanks for pointing this out.

So, if I want to use "the latest and greatest" I should use (both at compile time and runtime of course):

- OpenJPA 2.4.1 (I guess this one is OK since I do use it)
- JTA 1.2 (Need to change the compile version)
- JPA 2.1 (Need to change the compile version)

Does that sound OK?


How do I check if OpenJPA is up-and-running properly?

service:list PersistenceProvider gives me this:

[javax.persistence.spi.PersistenceProvider]
-------------------------------------------
 javax.persistence.provider = org.apache.openjpa.persistence.PersistenceProviderImpl
 javax.persistence.spi.PersistenceProvider = org.apache.openjpa.persistence.PersistenceProviderImpl
 service.bundleid = 106
 service.id = 309
 service.scope = singleton
Provided by :
 OpenJPA Aggregate Jar (106)
Used by:
 Apache Geronimo JSR-317 JPA 2.0 Spec API (70)


/Bengt


2016-07-07 9:23 GMT+02:00 Christian Schneider <[hidden email]>:
The first thing Aries JPA does after finding the bundle is to locate a suitable PersistenceProvider service. So one thing to check is of the openjpa PersistenceProvider service is registered.

I am pretty sure the problem is with the openjpa version though. Openjpa 2.4.0 does not support JTA 1.2. In the newest karaf version there should be a feature for openjpa 2.4.1 which should work
with JTA 1.2. This is important as Aries JPA 2 requires JTA 1.2 for the @Transactional support.

Another issue might be with the JPA api version. Openjpa is only compatible to jpa 2.0. So you have to make sure your own bundle does not depend on jpa 2.1.

Christian


On 07.07.2016 09:10, Bengt Rodehav wrote:
OK - thanks Christian.

Do you have any idea why the EntityManagerFactory service does not seem to be published. The logging implies that the persistence unit is found and added. What could be missing?

/Bengt

2016-07-06 19:36 GMT+02:00 Christian Schneider <[hidden email]>:
You can ignore these messages. they come from Aries spi-fly and simply say that spi-fly looked into your bundle and decided that it does not need to do anything. I have committed a change to spi-fly recently to log these messages only on level debug as they confuse a lot of people.

Christian

2016-07-06 13:37 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
Actually a more complete log says:

2016-07-06 13:35:13,732 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker  102 | Found persistence unit filetransferhistoryPU in bundle se.digia.connect.services.filetransfer.history-domain with provider org.apache.openjpa.persistence.PersistenceProviderImpl.
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker   93 | Persistence units added for bundle se.digia.connect.services.filetransfer.history-domain event 128
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain

This sounds like the persistence units have been added but there is something wrong with the "SPI-provider".

/Bengt


2016-07-06 13:36 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
I do have the correct information in the manifest:

Meta-Persistence: META-INF/persistence.xml

But I think this indicates that something is wrong:

2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain


What is the SPI-provider?

/Bengt

2016-07-06 11:04 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
If no EntityManagerFactory service is created then this is not a problem with the blueprint.
Do you have the Meta-Persistence manifest entry?
See
https://github.com/cschneider/Karaf-Tutorial/blob/master/tasklist-ds/model/bnd.bnd

As soon as you have the entry you should see in the log that Aries JPA parses the persistence xml and tries to create the EMF. It should report in the log if something is missing.

For the blueprint you have to add the enable Elements for jpa and tx as they create the interceptors.

Christian


On 06.07.2016 10:51, Bengt Rodehav wrote:
Having problems getting this to work. I get the following in the log file:

2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-db
2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-db

No EntityManagerFactory service is being created.

Looks like I've missed something. The only changes I've made is the blueprint xml and the injection of the EntityManager using the annotation. Do I need to change anything else, like the persistence.xml?

/Bengt

2016-07-06 10:24 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com




-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com





--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Charlie Mordant

2016-07-07 10:28 GMT+02:00 Bengt Rodehav <[hidden email]>:
Reading your post again Christian I realize that I should not use JPA 2.1 but JPA 2.0.

I seem to have JPA 2.0 and JPA 2.1 installed at runtime:

karaf@root()> la | grep -i jpa
 37 | Active   |  80 | 2.3.0                 | Apache Aries JPA Container API
 38 | Active   |  80 | 2.3.0                 | Apache Aries JPA blueprint
 39 | Active   |  80 | 2.3.0                 | Apache Aries JPA container
 40 | Active   |  80 | 2.3.0                 | Apache Aries JPA support
 70 | Active   |  80 | 1.1                   | Apache Geronimo JSR-317 JPA 2.0 Spec API
106 | Active   |  80 | 2.4.1                 | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
 17 | Active   |  80 | 2.1.0.v201304241213   | Java Persistence API 2.1
175 | Active   |  80 | 2.8.0.SNAPSHOT        | Connect :: persistence-util

I don't really know why the JPA version 2.1 (2.1.0.v201304241213) is being installed. I do not do this explicitly.

Looking at OpenJPA 2.4.1, it seems to depend on JTA 1.1 not JTA 1.2.

Looked again at my JPA version. I do use JPA 2.0. But I use version 1.1 of artifact geronimo-jpa_2.0_spec which caused me to believe I was using JPA 1.1....

I'm still kind of confused. It would be thankful if you could tell me what features (and versions of those features) I should install in order to use the latest version (2.4.1) of OpenJPA.

/Bengt




2016-07-07 9:54 GMT+02:00 Bengt Rodehav <[hidden email]>:
Thanks a lot for your reply Christian.

It does sound like I have a versioning problem. I was  very unsure about what versions of jpa/jta/openjpa to use when upgrading from Karaf 2.4.1.

As it stands, I use 

- OpenJPA 2.4.1 (I use the Karaf "openjpa" feature version 2.4.1)
- JTA version 1.1 at compile time but JTA 1.2 seems to be installed at runtime. Probably due to the "openjpa" 2.4.1 feature requiring it
- JPA. In runtime both 1.1 and 2.1 are installed. The former because I compile against it and the latter due to the "openjpa" 2.4.1 feature (I think)

Wow what a mess, thanks for pointing this out.

So, if I want to use "the latest and greatest" I should use (both at compile time and runtime of course):

- OpenJPA 2.4.1 (I guess this one is OK since I do use it)
- JTA 1.2 (Need to change the compile version)
- JPA 2.1 (Need to change the compile version)

Does that sound OK?


How do I check if OpenJPA is up-and-running properly?

service:list PersistenceProvider gives me this:

[javax.persistence.spi.PersistenceProvider]
-------------------------------------------
 javax.persistence.provider = org.apache.openjpa.persistence.PersistenceProviderImpl
 javax.persistence.spi.PersistenceProvider = org.apache.openjpa.persistence.PersistenceProviderImpl
 service.bundleid = 106
 service.id = 309
 service.scope = singleton
Provided by :
 OpenJPA Aggregate Jar (106)
Used by:
 Apache Geronimo JSR-317 JPA 2.0 Spec API (70)


/Bengt


2016-07-07 9:23 GMT+02:00 Christian Schneider <[hidden email]>:
The first thing Aries JPA does after finding the bundle is to locate a suitable PersistenceProvider service. So one thing to check is of the openjpa PersistenceProvider service is registered.

I am pretty sure the problem is with the openjpa version though. Openjpa 2.4.0 does not support JTA 1.2. In the newest karaf version there should be a feature for openjpa 2.4.1 which should work
with JTA 1.2. This is important as Aries JPA 2 requires JTA 1.2 for the @Transactional support.

Another issue might be with the JPA api version. Openjpa is only compatible to jpa 2.0. So you have to make sure your own bundle does not depend on jpa 2.1.

Christian


On 07.07.2016 09:10, Bengt Rodehav wrote:
OK - thanks Christian.

Do you have any idea why the EntityManagerFactory service does not seem to be published. The logging implies that the persistence unit is found and added. What could be missing?

/Bengt

2016-07-06 19:36 GMT+02:00 Christian Schneider <[hidden email]>:
You can ignore these messages. they come from Aries spi-fly and simply say that spi-fly looked into your bundle and decided that it does not need to do anything. I have committed a change to spi-fly recently to log these messages only on level debug as they confuse a lot of people.

Christian

2016-07-06 13:37 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
Actually a more complete log says:

2016-07-06 13:35:13,732 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker  102 | Found persistence unit filetransferhistoryPU in bundle se.digia.connect.services.filetransfer.history-domain with provider org.apache.openjpa.persistence.PersistenceProviderImpl.
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker   93 | Persistence units added for bundle se.digia.connect.services.filetransfer.history-domain event 128
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain

This sounds like the persistence units have been added but there is something wrong with the "SPI-provider".

/Bengt


2016-07-06 13:36 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
I do have the correct information in the manifest:

Meta-Persistence: META-INF/persistence.xml

But I think this indicates that something is wrong:

2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain


What is the SPI-provider?

/Bengt

2016-07-06 11:04 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
If no EntityManagerFactory service is created then this is not a problem with the blueprint.
Do you have the Meta-Persistence manifest entry?
See
https://github.com/cschneider/Karaf-Tutorial/blob/master/tasklist-ds/model/bnd.bnd

As soon as you have the entry you should see in the log that Aries JPA parses the persistence xml and tries to create the EMF. It should report in the log if something is missing.

For the blueprint you have to add the enable Elements for jpa and tx as they create the interceptors.

Christian


On 06.07.2016 10:51, Bengt Rodehav wrote:
Having problems getting this to work. I get the following in the log file:

2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-db
2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-db

No EntityManagerFactory service is being created.

Looks like I've missed something. The only changes I've made is the blueprint xml and the injection of the EntityManager using the annotation. Do I need to change anything else, like the persistence.xml?

/Bengt

2016-07-06 10:24 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com




-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com





--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com





--
Charlie Mordant

Full OSGI/EE stack made with Karaf: https://github.com/OsgiliathEnterprise/net.osgiliath.parent
Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
Thanks a lot - will check it out!

/Bengt

2016-07-07 11:56 GMT+02:00 Charlie Mordant <[hidden email]>:

2016-07-07 10:28 GMT+02:00 Bengt Rodehav <[hidden email]>:
Reading your post again Christian I realize that I should not use JPA 2.1 but JPA 2.0.

I seem to have JPA 2.0 and JPA 2.1 installed at runtime:

karaf@root()> la | grep -i jpa
 37 | Active   |  80 | 2.3.0                 | Apache Aries JPA Container API
 38 | Active   |  80 | 2.3.0                 | Apache Aries JPA blueprint
 39 | Active   |  80 | 2.3.0                 | Apache Aries JPA container
 40 | Active   |  80 | 2.3.0                 | Apache Aries JPA support
 70 | Active   |  80 | 1.1                   | Apache Geronimo JSR-317 JPA 2.0 Spec API
106 | Active   |  80 | 2.4.1                 | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
 17 | Active   |  80 | 2.1.0.v201304241213   | Java Persistence API 2.1
175 | Active   |  80 | 2.8.0.SNAPSHOT        | Connect :: persistence-util

I don't really know why the JPA version 2.1 (2.1.0.v201304241213) is being installed. I do not do this explicitly.

Looking at OpenJPA 2.4.1, it seems to depend on JTA 1.1 not JTA 1.2.

Looked again at my JPA version. I do use JPA 2.0. But I use version 1.1 of artifact geronimo-jpa_2.0_spec which caused me to believe I was using JPA 1.1....

I'm still kind of confused. It would be thankful if you could tell me what features (and versions of those features) I should install in order to use the latest version (2.4.1) of OpenJPA.

/Bengt




2016-07-07 9:54 GMT+02:00 Bengt Rodehav <[hidden email]>:
Thanks a lot for your reply Christian.

It does sound like I have a versioning problem. I was  very unsure about what versions of jpa/jta/openjpa to use when upgrading from Karaf 2.4.1.

As it stands, I use 

- OpenJPA 2.4.1 (I use the Karaf "openjpa" feature version 2.4.1)
- JTA version 1.1 at compile time but JTA 1.2 seems to be installed at runtime. Probably due to the "openjpa" 2.4.1 feature requiring it
- JPA. In runtime both 1.1 and 2.1 are installed. The former because I compile against it and the latter due to the "openjpa" 2.4.1 feature (I think)

Wow what a mess, thanks for pointing this out.

So, if I want to use "the latest and greatest" I should use (both at compile time and runtime of course):

- OpenJPA 2.4.1 (I guess this one is OK since I do use it)
- JTA 1.2 (Need to change the compile version)
- JPA 2.1 (Need to change the compile version)

Does that sound OK?


How do I check if OpenJPA is up-and-running properly?

service:list PersistenceProvider gives me this:

[javax.persistence.spi.PersistenceProvider]
-------------------------------------------
 javax.persistence.provider = org.apache.openjpa.persistence.PersistenceProviderImpl
 javax.persistence.spi.PersistenceProvider = org.apache.openjpa.persistence.PersistenceProviderImpl
 service.bundleid = 106
 service.id = 309
 service.scope = singleton
Provided by :
 OpenJPA Aggregate Jar (106)
Used by:
 Apache Geronimo JSR-317 JPA 2.0 Spec API (70)


/Bengt


2016-07-07 9:23 GMT+02:00 Christian Schneider <[hidden email]>:
The first thing Aries JPA does after finding the bundle is to locate a suitable PersistenceProvider service. So one thing to check is of the openjpa PersistenceProvider service is registered.

I am pretty sure the problem is with the openjpa version though. Openjpa 2.4.0 does not support JTA 1.2. In the newest karaf version there should be a feature for openjpa 2.4.1 which should work
with JTA 1.2. This is important as Aries JPA 2 requires JTA 1.2 for the @Transactional support.

Another issue might be with the JPA api version. Openjpa is only compatible to jpa 2.0. So you have to make sure your own bundle does not depend on jpa 2.1.

Christian


On 07.07.2016 09:10, Bengt Rodehav wrote:
OK - thanks Christian.

Do you have any idea why the EntityManagerFactory service does not seem to be published. The logging implies that the persistence unit is found and added. What could be missing?

/Bengt

2016-07-06 19:36 GMT+02:00 Christian Schneider <[hidden email]>:
You can ignore these messages. they come from Aries spi-fly and simply say that spi-fly looked into your bundle and decided that it does not need to do anything. I have committed a change to spi-fly recently to log these messages only on level debug as they confuse a lot of people.

Christian

2016-07-06 13:37 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
Actually a more complete log says:

2016-07-06 13:35:13,732 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker  102 | Found persistence unit filetransferhistoryPU in bundle se.digia.connect.services.filetransfer.history-domain with provider org.apache.openjpa.persistence.PersistenceProviderImpl.
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | PersistenceBundleTracker         | er.impl.PersistenceBundleTracker   93 | Persistence units added for bundle se.digia.connect.services.filetransfer.history-domain event 128
2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain

This sounds like the persistence units have been added but there is something wrong with the "SPI-provider".

/Bengt


2016-07-06 13:36 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
I do have the correct information in the manifest:

Meta-Persistence: META-INF/persistence.xml

But I think this indicates that something is wrong:

2016-07-06 13:35:13,733 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-domain
2016-07-06 13:35:13,734 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-domain


What is the SPI-provider?

/Bengt

2016-07-06 11:04 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
If no EntityManagerFactory service is created then this is not a problem with the blueprint.
Do you have the Meta-Persistence manifest entry?
See
https://github.com/cschneider/Karaf-Tutorial/blob/master/tasklist-ds/model/bnd.bnd

As soon as you have the entry you should see in the log that Aries JPA parses the persistence xml and tries to create the EMF. It should report in the log if something is missing.

For the blueprint you have to add the enable Elements for jpa and tx as they create the interceptors.

Christian


On 06.07.2016 10:51, Bengt Rodehav wrote:
Having problems getting this to work. I get the following in the log file:

2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | Bundle Considered for SPI providers: se.digia.connect.services.filetransfer.history-db
2016-07-06 10:46:54,710 | INFO  | nsole user karaf | bundle                           | ?                                   ? | No 'SPI-Provider' Manifest header. Skipping bundle: se.digia.connect.services.filetransfer.history-db

No EntityManagerFactory service is being created.

Looks like I've missed something. The only changes I've made is the blueprint xml and the injection of the EntityManager using the annotation. Do I need to change anything else, like the persistence.xml?

/Bengt

2016-07-06 10:24 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
OK - thanks Christian. Will try the annotations.

/Bengt

2016-07-06 10:18 GMT+02:00 Christian Schneider <[hidden email][hidden email]>:
Hi Bengt,

Aries JPA 2 only supports the annotations. You can install Aries JPA 1.x into karaf 4.0.5 if you want the old xml style.

Christian


On 06.07.2016 09:58, Bengt Rodehav wrote:
I'm migrating from Karaf 2.4.1 to 4.0.5. I also go from JPA 1.0 to 2.0.

Previously my Blueprint XML looked like this:


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />  

</blueprint>


I have now changed to:

<?xml version="1.0" encoding="UTF-8"?>
  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0"> <!-- tjoho -->

  <bean id="messageService" class="se.digia.connect.iso20022.history.impl.MessageHistoryService">
    <tx:transaction method="*" value="RequiresNew" />
    <jpa:context property="entityManager" unitname="iso20022PU" />
  </bean>

  <service ref="messageService" interface="se.digia.connect.iso20022.history.api.IMessageHistoryService" />
  
</blueprint>

On Karaf startup I get the following error:

2016-07-06 09:46:42,154 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  437 | Unable to start blueprint container for bundle se.digia.connect.services.filetransfer.history-db/2.8.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:343)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[25:org.apache.aries.blueprint.core:1.6.1]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[25:org.apache.aries.blueprint.core:1.6.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_74]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_74]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_74]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)[:]
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)[:]
at javax.xml.validation.Validator.validate(Unknown Source)[:2.7.0]
at org.apache.aries.blueprint.parser.Parser.validate(Parser.java:346)[25:org.apache.aries.blueprint.core:1.6.1]
... 14 more

I read at http://aries.apache.org/modules/jpaproject.html that annotations can now be used for the injection of the perstence unit context. But, is it the only way to do it? Is there no way to do it using the jpa:context element anymore?

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com




-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com





--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com





--
Charlie Mordant

Full OSGI/EE stack made with Karaf: https://github.com/OsgiliathEnterprise/net.osgiliath.parent

Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Christian Schneider
In reply to this post by Bengt Rodehav
Can you start from an empty karaf 4.0.5 and then do

feature:install openjpa jpa

This should install openjpa 2.4.1 and aries jpa 2.3.0 with javax.persistence 2.0 and jta 1.2.

This configuration should work. So maybe something else you install requires the jpa 2.1 spec.

Christian




On 07.07.2016 10:28, Bengt Rodehav wrote:
Reading your post again Christian I realize that I should not use JPA 2.1 but JPA 2.0.

I seem to have JPA 2.0 and JPA 2.1 installed at runtime:

karaf@root()> la | grep -i jpa
 37 | Active   |  80 | 2.3.0                 | Apache Aries JPA Container API
 38 | Active   |  80 | 2.3.0                 | Apache Aries JPA blueprint
 39 | Active   |  80 | 2.3.0                 | Apache Aries JPA container
 40 | Active   |  80 | 2.3.0                 | Apache Aries JPA support
 70 | Active   |  80 | 1.1                   | Apache Geronimo JSR-317 JPA 2.0 Spec API
106 | Active   |  80 | 2.4.1                 | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
 17 | Active   |  80 | 2.1.0.v201304241213   | Java Persistence API 2.1
175 | Active   |  80 | 2.8.0.SNAPSHOT        | Connect :: persistence-util

I don't really know why the JPA version 2.1 (2.1.0.v201304241213) is being installed. I do not do this explicitly.

Looking at OpenJPA 2.4.1, it seems to depend on JTA 1.1 not JTA 1.2.

Looked again at my JPA version. I do use JPA 2.0. But I use version 1.1 of artifact geronimo-jpa_2.0_spec which caused me to believe I was using JPA 1.1....

I'm still kind of confused. It would be thankful if you could tell me what features (and versions of those features) I should install in order to use the latest version (2.4.1) of OpenJPA.

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
On a fresh Karaf 4.0.5 I do:

la | grep -i jpa
la | grep -i persistence

Nothing is displayed. I then do:

feature:install openjpa jpa

If I then execute the above commands I get:

karaf@root()> la | grep -i jpa
62 | Active   |  80 | 2.3.0               | Apache Aries JPA Container API
63 | Active   |  80 | 2.3.0               | Apache Aries JPA blueprint
64 | Active   |  80 | 2.3.0               | Apache Aries JPA container
65 | Active   |  80 | 2.3.0               | Apache Aries JPA support
71 | Active   |  80 | 1.1                 | Apache Geronimo JSR-317 JPA 2.0 Spec AP
73 | Active   |  80 | 2.4.1               | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
55 | Active   |  80 | 2.1.0.v201304241213 | Java Persistence API 2.1
karaf@root()>

So JPA 2.1 has indeed been installed. I don't know if this is why I have problems but it still seems strange.

/Bengt


2016-07-07 13:11 GMT+02:00 Christian Schneider <[hidden email]>:
Can you start from an empty karaf 4.0.5 and then do

feature:install openjpa jpa

This should install openjpa 2.4.1 and aries jpa 2.3.0 with javax.persistence 2.0 and jta 1.2.

This configuration should work. So maybe something else you install requires the jpa 2.1 spec.

Christian





On 07.07.2016 10:28, Bengt Rodehav wrote:
Reading your post again Christian I realize that I should not use JPA 2.1 but JPA 2.0.

I seem to have JPA 2.0 and JPA 2.1 installed at runtime:

karaf@root()> la | grep -i jpa
 37 | Active   |  80 | 2.3.0                 | Apache Aries JPA Container API
 38 | Active   |  80 | 2.3.0                 | Apache Aries JPA blueprint
 39 | Active   |  80 | 2.3.0                 | Apache Aries JPA container
 40 | Active   |  80 | 2.3.0                 | Apache Aries JPA support
 70 | Active   |  80 | 1.1                   | Apache Geronimo JSR-317 JPA 2.0 Spec API
106 | Active   |  80 | 2.4.1                 | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
 17 | Active   |  80 | 2.1.0.v201304241213   | Java Persistence API 2.1
175 | Active   |  80 | 2.8.0.SNAPSHOT        | Connect :: persistence-util

I don't really know why the JPA version 2.1 (2.1.0.v201304241213) is being installed. I do not do this explicitly.

Looking at OpenJPA 2.4.1, it seems to depend on JTA 1.1 not JTA 1.2.

Looked again at my JPA version. I do use JPA 2.0. But I use version 1.1 of artifact geronimo-jpa_2.0_spec which caused me to believe I was using JPA 1.1....

I'm still kind of confused. It would be thankful if you could tell me what features (and versions of those features) I should install in order to use the latest version (2.4.1) of OpenJPA.

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
It seems to be the "jpa" feature that installs JPA 2.1.

2016-07-07 13:58 GMT+02:00 Bengt Rodehav <[hidden email]>:
On a fresh Karaf 4.0.5 I do:

la | grep -i jpa
la | grep -i persistence

Nothing is displayed. I then do:

feature:install openjpa jpa

If I then execute the above commands I get:

karaf@root()> la | grep -i jpa
62 | Active   |  80 | 2.3.0               | Apache Aries JPA Container API
63 | Active   |  80 | 2.3.0               | Apache Aries JPA blueprint
64 | Active   |  80 | 2.3.0               | Apache Aries JPA container
65 | Active   |  80 | 2.3.0               | Apache Aries JPA support
71 | Active   |  80 | 1.1                 | Apache Geronimo JSR-317 JPA 2.0 Spec AP
73 | Active   |  80 | 2.4.1               | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
55 | Active   |  80 | 2.1.0.v201304241213 | Java Persistence API 2.1
karaf@root()>

So JPA 2.1 has indeed been installed. I don't know if this is why I have problems but it still seems strange.

/Bengt


2016-07-07 13:11 GMT+02:00 Christian Schneider <[hidden email]>:
Can you start from an empty karaf 4.0.5 and then do

feature:install openjpa jpa

This should install openjpa 2.4.1 and aries jpa 2.3.0 with javax.persistence 2.0 and jta 1.2.

This configuration should work. So maybe something else you install requires the jpa 2.1 spec.

Christian





On 07.07.2016 10:28, Bengt Rodehav wrote:
Reading your post again Christian I realize that I should not use JPA 2.1 but JPA 2.0.

I seem to have JPA 2.0 and JPA 2.1 installed at runtime:

karaf@root()> la | grep -i jpa
 37 | Active   |  80 | 2.3.0                 | Apache Aries JPA Container API
 38 | Active   |  80 | 2.3.0                 | Apache Aries JPA blueprint
 39 | Active   |  80 | 2.3.0                 | Apache Aries JPA container
 40 | Active   |  80 | 2.3.0                 | Apache Aries JPA support
 70 | Active   |  80 | 1.1                   | Apache Geronimo JSR-317 JPA 2.0 Spec API
106 | Active   |  80 | 2.4.1                 | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
 17 | Active   |  80 | 2.1.0.v201304241213   | Java Persistence API 2.1
175 | Active   |  80 | 2.8.0.SNAPSHOT        | Connect :: persistence-util

I don't really know why the JPA version 2.1 (2.1.0.v201304241213) is being installed. I do not do this explicitly.

Looking at OpenJPA 2.4.1, it seems to depend on JTA 1.1 not JTA 1.2.

Looked again at my JPA version. I do use JPA 2.0. But I use version 1.1 of artifact geronimo-jpa_2.0_spec which caused me to believe I was using JPA 1.1....

I'm still kind of confused. It would be thankful if you could tell me what features (and versions of those features) I should install in order to use the latest version (2.4.1) of OpenJPA.

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
Installing feature "openjpa" also installs JPA 2.0 (version 1.1) so I shouldn't need to install JPA manually as well. However, then I won't get the Aries support for JPA. Feels a bit weird.

What Aries JPa version should be used together with OpenJPA 2.4.1?

/Bengt

2016-07-07 14:04 GMT+02:00 Bengt Rodehav <[hidden email]>:
It seems to be the "jpa" feature that installs JPA 2.1.

2016-07-07 13:58 GMT+02:00 Bengt Rodehav <[hidden email]>:
On a fresh Karaf 4.0.5 I do:

la | grep -i jpa
la | grep -i persistence

Nothing is displayed. I then do:

feature:install openjpa jpa

If I then execute the above commands I get:

karaf@root()> la | grep -i jpa
62 | Active   |  80 | 2.3.0               | Apache Aries JPA Container API
63 | Active   |  80 | 2.3.0               | Apache Aries JPA blueprint
64 | Active   |  80 | 2.3.0               | Apache Aries JPA container
65 | Active   |  80 | 2.3.0               | Apache Aries JPA support
71 | Active   |  80 | 1.1                 | Apache Geronimo JSR-317 JPA 2.0 Spec AP
73 | Active   |  80 | 2.4.1               | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
55 | Active   |  80 | 2.1.0.v201304241213 | Java Persistence API 2.1
karaf@root()>

So JPA 2.1 has indeed been installed. I don't know if this is why I have problems but it still seems strange.

/Bengt


2016-07-07 13:11 GMT+02:00 Christian Schneider <[hidden email]>:
Can you start from an empty karaf 4.0.5 and then do

feature:install openjpa jpa

This should install openjpa 2.4.1 and aries jpa 2.3.0 with javax.persistence 2.0 and jta 1.2.

This configuration should work. So maybe something else you install requires the jpa 2.1 spec.

Christian





On 07.07.2016 10:28, Bengt Rodehav wrote:
Reading your post again Christian I realize that I should not use JPA 2.1 but JPA 2.0.

I seem to have JPA 2.0 and JPA 2.1 installed at runtime:

karaf@root()> la | grep -i jpa
 37 | Active   |  80 | 2.3.0                 | Apache Aries JPA Container API
 38 | Active   |  80 | 2.3.0                 | Apache Aries JPA blueprint
 39 | Active   |  80 | 2.3.0                 | Apache Aries JPA container
 40 | Active   |  80 | 2.3.0                 | Apache Aries JPA support
 70 | Active   |  80 | 1.1                   | Apache Geronimo JSR-317 JPA 2.0 Spec API
106 | Active   |  80 | 2.4.1                 | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
 17 | Active   |  80 | 2.1.0.v201304241213   | Java Persistence API 2.1
175 | Active   |  80 | 2.8.0.SNAPSHOT        | Connect :: persistence-util

I don't really know why the JPA version 2.1 (2.1.0.v201304241213) is being installed. I do not do this explicitly.

Looking at OpenJPA 2.4.1, it seems to depend on JTA 1.1 not JTA 1.2.

Looked again at my JPA version. I do use JPA 2.0. But I use version 1.1 of artifact geronimo-jpa_2.0_spec which caused me to believe I was using JPA 1.1....

I'm still kind of confused. It would be thankful if you could tell me what features (and versions of those features) I should install in order to use the latest version (2.4.1) of OpenJPA.

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com



Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Christian Schneider
Genereally Aries JPA should work with OpenJPA 2.4.1 but I think there is some bug in karaf 4.0.5.

I just tested again and found that persistence api 2.0 and 2.1 are both installed. This fails as Aries JPA can only bind to one of these and will choose the higher version.
As a workaround you should be able to create your own feature copied from the Aries JPA feature but make sure you install the persistence api only in version 2.0.

I will try to create a working version of the features for karaf 4.0.6.

Christian


On 07.07.2016 14:07, Bengt Rodehav wrote:
Installing feature "openjpa" also installs JPA 2.0 (version 1.1) so I shouldn't need to install JPA manually as well. However, then I won't get the Aries support for JPA. Feels a bit weird.

What Aries JPa version should be used together with OpenJPA 2.4.1?

/Bengt

2016-07-07 14:04 GMT+02:00 Bengt Rodehav <[hidden email]>:
It seems to be the "jpa" feature that installs JPA 2.1.

2016-07-07 13:58 GMT+02:00 Bengt Rodehav <[hidden email]>:
On a fresh Karaf 4.0.5 I do:

la | grep -i jpa
la | grep -i persistence

Nothing is displayed. I then do:

feature:install openjpa jpa

If I then execute the above commands I get:

karaf@root()> la | grep -i jpa
62 | Active   |  80 | 2.3.0               | Apache Aries JPA Container API
63 | Active   |  80 | 2.3.0               | Apache Aries JPA blueprint
64 | Active   |  80 | 2.3.0               | Apache Aries JPA container
65 | Active   |  80 | 2.3.0               | Apache Aries JPA support
71 | Active   |  80 | 1.1                 | Apache Geronimo JSR-317 JPA 2.0 Spec AP
73 | Active   |  80 | 2.4.1               | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
55 | Active   |  80 | 2.1.0.v201304241213 | Java Persistence API 2.1
karaf@root()>

So JPA 2.1 has indeed been installed. I don't know if this is why I have problems but it still seems strange.

/Bengt


2016-07-07 13:11 GMT+02:00 Christian Schneider <[hidden email]>:
Can you start from an empty karaf 4.0.5 and then do

feature:install openjpa jpa

This should install openjpa 2.4.1 and aries jpa 2.3.0 with javax.persistence 2.0 and jta 1.2.

This configuration should work. So maybe something else you install requires the jpa 2.1 spec.

Christian





On 07.07.2016 10:28, Bengt Rodehav wrote:
Reading your post again Christian I realize that I should not use JPA 2.1 but JPA 2.0.

I seem to have JPA 2.0 and JPA 2.1 installed at runtime:

karaf@root()> la | grep -i jpa
 37 | Active   |  80 | 2.3.0                 | Apache Aries JPA Container API
 38 | Active   |  80 | 2.3.0                 | Apache Aries JPA blueprint
 39 | Active   |  80 | 2.3.0                 | Apache Aries JPA container
 40 | Active   |  80 | 2.3.0                 | Apache Aries JPA support
 70 | Active   |  80 | 1.1                   | Apache Geronimo JSR-317 JPA 2.0 Spec API
106 | Active   |  80 | 2.4.1                 | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
 17 | Active   |  80 | 2.1.0.v201304241213   | Java Persistence API 2.1
175 | Active   |  80 | 2.8.0.SNAPSHOT        | Connect :: persistence-util

I don't really know why the JPA version 2.1 (2.1.0.v201304241213) is being installed. I do not do this explicitly.

Looking at OpenJPA 2.4.1, it seems to depend on JTA 1.1 not JTA 1.2.

Looked again at my JPA version. I do use JPA 2.0. But I use version 1.1 of artifact geronimo-jpa_2.0_spec which caused me to believe I was using JPA 1.1....

I'm still kind of confused. It would be thankful if you could tell me what features (and versions of those features) I should install in order to use the latest version (2.4.1) of OpenJPA.

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com





-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Karaf 2.4.1 to 4.0.5, JPA problems

Bengt Rodehav
OK - thanks a lot for all your help Christian.

/Bengt


2016-07-07 14:14 GMT+02:00 Christian Schneider <[hidden email]>:
Genereally Aries JPA should work with OpenJPA 2.4.1 but I think there is some bug in karaf 4.0.5.

I just tested again and found that persistence api 2.0 and 2.1 are both installed. This fails as Aries JPA can only bind to one of these and will choose the higher version.
As a workaround you should be able to create your own feature copied from the Aries JPA feature but make sure you install the persistence api only in version 2.0.

I will try to create a working version of the features for karaf 4.0.6.

Christian



On 07.07.2016 14:07, Bengt Rodehav wrote:
Installing feature "openjpa" also installs JPA 2.0 (version 1.1) so I shouldn't need to install JPA manually as well. However, then I won't get the Aries support for JPA. Feels a bit weird.

What Aries JPa version should be used together with OpenJPA 2.4.1?

/Bengt

2016-07-07 14:04 GMT+02:00 Bengt Rodehav <[hidden email]>:
It seems to be the "jpa" feature that installs JPA 2.1.

2016-07-07 13:58 GMT+02:00 Bengt Rodehav <[hidden email][hidden email]>:
On a fresh Karaf 4.0.5 I do:

la | grep -i jpa
la | grep -i persistence

Nothing is displayed. I then do:

feature:install openjpa jpa

If I then execute the above commands I get:

karaf@root()> la | grep -i jpa
62 | Active   |  80 | 2.3.0               | Apache Aries JPA Container API
63 | Active   |  80 | 2.3.0               | Apache Aries JPA blueprint
64 | Active   |  80 | 2.3.0               | Apache Aries JPA container
65 | Active   |  80 | 2.3.0               | Apache Aries JPA support
71 | Active   |  80 | 1.1                 | Apache Geronimo JSR-317 JPA 2.0 Spec AP
73 | Active   |  80 | 2.4.1               | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
55 | Active   |  80 | 2.1.0.v201304241213 | Java Persistence API 2.1
karaf@root()>

So JPA 2.1 has indeed been installed. I don't know if this is why I have problems but it still seems strange.

/Bengt


2016-07-07 13:11 GMT+02:00 Christian Schneider <[hidden email]>:
Can you start from an empty karaf 4.0.5 and then do

feature:install openjpa jpa

This should install openjpa 2.4.1 and aries jpa 2.3.0 with javax.persistence 2.0 and jta 1.2.

This configuration should work. So maybe something else you install requires the jpa 2.1 spec.

Christian





On 07.07.2016 10:28, Bengt Rodehav wrote:
Reading your post again Christian I realize that I should not use JPA 2.1 but JPA 2.0.

I seem to have JPA 2.0 and JPA 2.1 installed at runtime:

karaf@root()> la | grep -i jpa
 37 | Active   |  80 | 2.3.0                 | Apache Aries JPA Container API
 38 | Active   |  80 | 2.3.0                 | Apache Aries JPA blueprint
 39 | Active   |  80 | 2.3.0                 | Apache Aries JPA container
 40 | Active   |  80 | 2.3.0                 | Apache Aries JPA support
 70 | Active   |  80 | 1.1                   | Apache Geronimo JSR-317 JPA 2.0 Spec API
106 | Active   |  80 | 2.4.1                 | OpenJPA Aggregate Jar
karaf@root()> la | grep -i persistence
 17 | Active   |  80 | 2.1.0.v201304241213   | Java Persistence API 2.1
175 | Active   |  80 | 2.8.0.SNAPSHOT        | Connect :: persistence-util

I don't really know why the JPA version 2.1 (2.1.0.v201304241213) is being installed. I do not do this explicitly.

Looking at OpenJPA 2.4.1, it seems to depend on JTA 1.1 not JTA 1.2.

Looked again at my JPA version. I do use JPA 2.0. But I use version 1.1 of artifact geronimo-jpa_2.0_spec which caused me to believe I was using JPA 1.1....

I'm still kind of confused. It would be thankful if you could tell me what features (and versions of those features) I should install in order to use the latest version (2.4.1) of OpenJPA.

/Bengt



-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com





-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

123