Hello,

I finally fixed my  issue, by setting the package containning my class as
dynamic Import package in bundle launching the thread, I would like to use
a simple import package , but felix plugin (maven-bundle-plugin) overrite
my package when it generates other imports (by scanning my classes)

Cheers,

Mohamed

2018-09-25 9:37 GMT+02:00 Mohamed AFIF <afif.moha...@gmail.com>:

> Hi  Ancoron,
>
> Thanks for takin time to answer me.
>
> using   bundle as fragment is really new for me, i did not know that
> exists so I don't know if it is complicated to set.
> For your question :
> Doesn't Activiti pick up OSGi services registered as a TaskListener?
>
> Yes , but it it should set as  "delegate expression" and oviously exposed
> by blueprint as service,  so  activiti will pick it up . But in my case it
> is declard as "class" it means it will be instantiated by activiti at
> runtime, and this is because  this class has attributes which will be set
> at runtime , I mean during workflow excution.
>
>
> Regards
>
> Mohamed
>
>
> 2018-09-24 22:02 GMT+02:00 Ancoron Luciferis <
> ancoron.lucife...@googlemail.com>:
>
>> 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
>> > osgi-dev@mail.osgi.org
>> > https://mail.osgi.org/mailman/listinfo/osgi-dev
>> >
>>
>>
>
>
> --
>
> Cdt
> Mohamed AFIF
>



-- 

Cdt
Mohamed AFIF
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to