Hi,
although this is rather off-topic and should be discussed inside the
Activiti community rather than the general OSGi development list, I
personally have worked with Activiti inside OSGi.
The key is to get your classes "visible" to the bundle that created the
Job Executor (so most likely the engine).
A simple way is to provide your classes as Fragment Bundle(s) and attach
them to the engine Bundle as the host. This way, the engine class-loader
will get expanded with your classes.
Alternatively, you'd have to modify the engine Bundle and add
Dynamic-Imports (which are really deprecated) and have your Bundle
export the packages of your listener classes.
Doesn't Activiti pick up OSGi services registered as a TaskListener?
That would actually be the proper way of integrating inside a
service-oriented platform like OSGi.
Cheers,
Ancoron
On 24/09/18 18:49, Mohamed AFIF via osgi-dev wrote:
> Hello ALL,
>
> I'm facing an issue, and I don't know how to solve it, indeed In our
> project we 're using activiti in karaf , and this is my problematic,
>
> 1- I have bundle A who exposes a webservice using cxf say that the
> webservice class is MyAWebService, and we have a bundle B which contains
> class MyBWebService the sub class of MyAWebService
> (MyAWebService extends MyBWebService ).
>
> 2- in our activiti process we define a Listner
> MyTaskListner(implementing TaskListner) as Class it means it will be
> instanciated by Activiti engine.
> the class listner islocated in bundle B.
>
> Thus when I run my workflow, and when activiti try to instanciate
> MyTaskListner, it throws "can't instanciate...." which is in the real
> NoClassFoundException,
> because the classloader trying to load this class cna not get it, and
> this is why, indeed activiti , because of the ClassDelegate of activit
> when it runs its method
> notify, it trys to instanciate MyTaskListner, and thus to load it using
> the org.activiti.engine.impl.util.ReflectUtil.loadClass() method (code
> below)
> so my problem is that Thread.currentThread().getContextClassLoader()
> returns a BundleDelegatingClassLoader on bundle A , which not contains
> MyTaskListner class.
>
> 1-so my first question is what BundleDelegatingClassLoader does really?
> 2- which workaround could I use to force the
> BundleDelegatingClassLoader to looks to my bundle B
>
> Thanks a lot for your Help
>
> public static Class<?> loadClass(String className) {
> Class<?> clazz = null;
> ClassLoader classLoader = getCustomClassLoader();
>
> // First exception in chain of classloaders will be used as cause
> when no class is found in any of them
> Throwable throwable = null;
>
> if(classLoader != null) {
> try {
> LOG.trace("Trying to load class with custom classloader: {}",
> className);
> clazz = loadClass(classLoader, className);
> } catch(Throwable t) {
> throwable = t;
> }
> }
> if(clazz == null) {
> try {
> LOG.trace("Trying to load class with current thread context
> classloader: {}", className);
> clazz = loadClass(Thread.currentThread().getContextClassLoader(),
> className);
> } catch(Throwable t) {
> if(throwable == null) {
> throwable = t;
> }
> }
> if(clazz == null) {
> try {
> LOG.trace("Trying to load class with local classloader: {}",
> className);
> clazz = loadClass(ReflectUtil.class.getClassLoader(), className);
> } catch(Throwable t) {
> if(throwable == null) {
> throwable = t;
> }
> }
> }
> }
>
> if(clazz == null) {
> throw new ActivitiClassLoadingException(className, throwable);
> }
> return clazz;
> }
>
>
>
>
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev