I have a few microservices running in Karaf (4.2.7).
I am getting this error when starting up Karaf.
I think it's not affecting the services and should be something simple to fix.
I mean the services seem operational and all configured data sources also are in good shape (I tested them one by one).
We don't use PAX, we use blueprints for our data sources.
What could be causing this error and how should I fix it?
2019-10-17T11:42:08,386 | INFO | FelixStartLevel | JtaPlatformInitiator | 177 - org.hibernate.orm.core - 5.4.2.Final | HHH000490: Using JtaPlatform implementation: [org.hibernate.osgi.OsgiJtaPlatform]
2019-10-17T11:42:08,413 | INFO | FelixStartLevel | PersistenceProviderTracker | 52 - org.apache.aries.jpa.container - 2.7.2 | Found provider for ybkDS org.hibernate.jpa.HibernatePersistenceProvider
2019-10-17T11:42:08,414 | ERROR | FelixStartLevel | Felix | 6 - org.ops4j.pax.logging.pax-logging-api - 1.11.2 | Bundle org.apache.aries.jpa.container [52] EventDispatcher: Error during dispatch. (java.lang.ClassCastException: org.apache.openjpa.persistence.PersistenceProviderImpl cannot be cast to javax.persistence.spi.PersistenceProvider)
java.lang.ClassCastException: org.apache.openjpa.persistence.PersistenceProviderImpl cannot be cast to javax.persistence.spi.PersistenceProvider
at org.apache.aries.jpa.container.impl.PersistenceProviderTracker.addingService(PersistenceProviderTracker.java:84) ~[?:?]
at org.apache.aries.jpa.container.impl.PersistenceProviderTracker.addingService(PersistenceProviderTracker.java:44) ~[?:?]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261) ~[osgi.core-6.0.0.jar:?]
at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.trackProvider(PersistenceBundleTracker.java:229) ~[?:?]
at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.findPersistenceUnits(PersistenceBundleTracker.java:213) ~[?:?]
at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.addingBundle(PersistenceBundleTracker.java:98) ~[?:?]
at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.addingBundle(PersistenceBundleTracker.java:44) ~[?:?]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:415) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) ~[osgi.core-6.0.0.jar:?]
at org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915) ~[org.apache.felix.framework-5.6.12.jar:?]
at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834) [org.apache.felix.framework-5.6.12.jar:?]
at org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:516) [org.apache.felix.framework-5.6.12.jar:?]
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4579) [org.apache.felix.framework-5.6.12.jar:?]
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2231) [org.apache.felix.framework-5.6.12.jar:?]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2146) [org.apache.felix.framework-5.6.12.jar:?]
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1373) [org.apache.felix.framework-5.6.12.jar:?]
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308) [org.apache.felix.framework-5.6.12.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_192]
I solved this issue by removing/uninstalling OpenJPA
from Karaf.
Seems I have other features installed in Karaf which already cover JPA.
These features are: hibernate, jpa, also Apache Aries JPA blueprint 2.5.0.
I am pretty sure one of these covers JPA. So having OpenJPA on top of these was causing the issue.
NOTE: The answer from jbonofre
was correct, I think. Not sure why they had him delete this answer.
"Don't you have two JPA engines deployed ? Like you use OpenJPA in your bundle/persistence.xml but you have Hibernate also installed ?"
I solved my issue before seeing it but it seems that's exactly what the problem was, I already had more than 1 JPA providers. So removing OpenJPA solved the issue.