How to resolve custom transaction manager dependency the best way?

20 views
Skip to first unread message

kevin.s...@dooapp.com

unread,
Jan 12, 2017, 12:43:47 PM1/12/17
to wisdom-discuss
Hi,

We use a custom transaction manager lookup in our wisdom application:
modeshape-test.json:
"storage": {
"persistence": {
"type": "db",
"connectionUrl": "***",
"driver": "com.mysql.jdbc.Driver",
"username": "***",
"password": "***"
},
"transactionManagerLookup": {
"name": "com.dooapp.cloud.service.AtomikosTransactionManagerLookup"
}
}

But the only way that we find to make it works, is to update the OSGI configuration of the wisdom-jcr-core module with the option:
DynamicImport-Package: *

Without the option, the class com.dooapp.cloud.service.AtomikosTransactionManagerLookup cannot be find by OSGI. You'll find below the stacktrace.

Since the DynamicImport-Package: * option break the OSGI architecture, do you know a better way to do it?

Thank you in advance

17:54:19.879 [[iPOJO] pool-1-thread-1] ERROR o.o.util.log.impl.osgi.LoggerService - [ERROR]  : javax.jcr.RepositoryException: Error while starting cloud-repository-test repository: Unable to create TransactionManagerLookup instance com.dooapp.cloud.service.AtomikosTransactionManagerLookup. Please check your configuration.
java
.lang.IllegalStateException: javax.jcr.RepositoryException: Error while starting 'cloud-repository-test' repository: Unable to create TransactionManagerLookup instance 'com.dooapp.cloud.service.AtomikosTransactionManagerLookup'. Please check your configuration.
        at org
.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:171) ~[org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java) ~[org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:560) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.InstanceManager.stateChanged(InstanceManager.java:1533) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:585) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.HandlerManager.stateChanged(HandlerManager.java:239) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.Handler.setValidity(Handler.java:174) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_checkContext(DependencyHandler.java:170) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.handlers.dependency.DependencyHandler.checkContext(DependencyHandler.java) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_validate(DependencyHandler.java:133) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.handlers.dependency.DependencyHandler.validate(DependencyHandler.java) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.util.DependencyModel.validate(DependencyModel.java:522) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.util.DependencyModel.computeAndSetDependencyState(DependencyModel.java:362) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.util.DependencyModel.onChange(DependencyModel.java:1123) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.dependency.impl.ServiceReferenceManager.fireUpdate(ServiceReferenceManager.java:561) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.dependency.impl.ServiceReferenceManager.onNewMatchingService(ServiceReferenceManager.java:525) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.dependency.impl.ServiceReferenceManager.addedService(ServiceReferenceManager.java:504) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.util.Tracker$Tracked.trackAdding(Tracker.java:711) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.util.Tracker$Tracked.track(Tracker.java:672) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.util.Tracker$Tracked.serviceChanged(Tracker.java:633) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:991) [chameleon-core-1.10.9.jar:na]
        at org
.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:839) [chameleon-core-1.10.9.jar:na]
        at org
.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:546) [chameleon-core-1.10.9.jar:na]
        at org
.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4557) [chameleon-core-1.10.9.jar:na]
        at org
.apache.felix.framework.Felix.registerService(Felix.java:3549) [chameleon-core-1.10.9.jar:na]
        at org
.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348) [chameleon-core-1.10.9.jar:na]
        at org
.apache.felix.ipojo.IPojoContext.registerService(IPojoContext.java:395) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.handlers.providedservice.ProvidedService.registerService(ProvidedService.java:351) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.__M_stateChanged(ProvidedServiceHandler.java:503) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.stateChanged(ProvidedServiceHandler.java) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:560) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:440) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.extender.internal.linker.ManagedType$InstanceSupport$1.call(ManagedType.java:312) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.extender.internal.linker.ManagedType$InstanceSupport$1.call(ManagedType.java:306) [org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.extender.internal.queue.JobInfoCallable.call(JobInfoCallable.java:114) [org.apache.felix.ipojo-1.12.1.jar:na]
        at java
.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111]
        at java
.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111]
        at java
.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111]
        at java
.lang.Thread.run(Thread.java:745) [na:1.8.0_111]
Caused by: javax.jcr.RepositoryException: Error while starting 'cloud-repository-test' repository: Unable to create TransactionManagerLookup instance 'com.dooapp.cloud.service.AtomikosTransactionManagerLookup'. Please check your configuration.
        at org
.modeshape.jcr.JcrRepository.login(JcrRepository.java:635) ~[modeshape-jcr-5.2.0.Final.jar:5.2.0.Final]
        at org
.modeshape.jcr.JcrRepository.login(JcrRepository.java:594) ~[modeshape-jcr-5.2.0.Final.jar:5.2.0.Final]
        at org
.modeshape.jcr.JcrRepository.login(JcrRepository.java:136) ~[modeshape-jcr-5.2.0.Final.jar:5.2.0.Final]
        at org
.wisdom.jcrom.runtime.JcrRepository.__M_start(JcrRepository.java:74) ~[org.wisdom.framework.jcr.wisdom.jcr.core-0.4.0-SNAPSHOT.jar:na]
        at org
.wisdom.jcrom.runtime.JcrRepository.start(JcrRepository.java) ~[org.wisdom.framework.jcr.wisdom.jcr.core-0.4.0-SNAPSHOT.jar:na]
        at sun
.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_111]
        at sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_111]
        at sun
.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_111]
        at java
.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_111]
        at org
.apache.felix.ipojo.util.Callback.call(Callback.java:233) ~[org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.util.Callback.call(Callback.java:193) ~[org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallback.call(LifecycleCallback.java:86) ~[org.apache.felix.ipojo-1.12.1.jar:na]
        at org
.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:162) ~[org.apache.felix.ipojo-1.12.1.jar:na]
       
... 41 common frames omitted
Caused by: java.lang.RuntimeException: Unable to create TransactionManagerLookup instance 'com.dooapp.cloud.service.AtomikosTransactionManagerLookup'. Please check your configuration.
        at org
.modeshape.jcr.RepositoryConfiguration.getTransactionManagerLookup(RepositoryConfiguration.java:940) ~[modeshape-jcr-5.2.0.Final.jar:5.2.0.Final]
        at org
.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:1036) ~[modeshape-jcr-5.2.0.Final.jar:5.2.0.Final]
        at org
.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:937) ~[modeshape-jcr-5.2.0.Final.jar:5.2.0.Final]
        at org
.modeshape.jcr.JcrRepository.doStart(JcrRepository.java:368) ~[modeshape-jcr-5.2.0.Final.jar:5.2.0.Final]
        at org
.modeshape.jcr.JcrRepository.login(JcrRepository.java:633) ~[modeshape-jcr-5.2.0.Final.jar:5.2.0.Final]
       
... 53 common frames omitted
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.dooapp.cloud.service.AtomikosTransactionManagerLookup
        at org
.modeshape.common.util.Reflection.getInstance(Reflection.java:307) ~[modeshape-common-5.2.0.Final.jar:5.2.0.Final]
        at org
.modeshape.jcr.RepositoryConfiguration$Component.createGenericComponent(RepositoryConfiguration.java:2682) ~[modeshape-jcr-5.2.0.Final.jar:5.2.0.Final]
        at org
.modeshape.jcr.RepositoryConfiguration$Component.createInstance(RepositoryConfiguration.java:2676) ~[modeshape-jcr-5.2.0.Final.jar:5.2.0.Final]
        at org
.modeshape.jcr.RepositoryConfiguration.getTransactionManagerLookup(RepositoryConfiguration.java:938) ~[modeshape-jcr-5.2.0.Final.jar:5.2.0.Final]
       
... 57 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.dooapp.cloud.service.AtomikosTransactionManagerLookup
        at java
.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_111]
        at org
.modeshape.common.util.DelegatingClassLoader.findClass(DelegatingClassLoader.java:51) ~[modeshape-common-5.2.0.Final.jar:5.2.0.Final]
        at java
.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_111]
        at java
.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_111]
        at java
.lang.Class.forName0(Native Method) ~[na:1.8.0_111]
        at java
.lang.Class.forName(Class.java:348) ~[na:1.8.0_111]
        at org
.modeshape.common.util.Reflection.getInstance(Reflection.java:291) ~[modeshape-common-5.2.0.Final.jar:5.2.0.Final]
       
... 60 common frames omitted


Clement Escoffier

unread,
Jan 16, 2017, 2:02:20 AM1/16/17
to wisdom-...@googlegroups.com
Hi,

The code handling the transactionManagerLookup and so responsible for loading the class should to a “bundle” search instead. It’s what is done in the OpenJPA manager for example. So you don’t need to use a dynamic-import and you will be bound a the first bundle exporting the package containing the class. 

Clement

--
You received this message because you are subscribed to the Google Groups "wisdom-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wisdom-discus...@googlegroups.com.
Visit this group at https://groups.google.com/group/wisdom-discuss.
To view this discussion on the web visit https://groups.google.com/d/msgid/wisdom-discuss/fa166e51-49ba-4b07-94fe-cdac0cd4cd42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages