0 Replies Latest reply on Feb 12, 2016 2:05 PM by asafbennatan

    weld beanmanager wont respect java classloaders

    asafbennatan

      Hi,

      i have a bit of a strange setup ,

      im running wildfly 10 (with weld) and in some point while the server starts - it loads a class from external jar , i'm loading these class using a different classloader for each jar,

      i'm facing the current issue , i have a jar loaded with class A , and then another jar loaded with the same class A (but a different version ) the two A classes are using different class loaders and so they are not equal,

      when creating an instance of an A i obtain the correct A class (lets call them A1 and A2)

      i create them using this snippet

      AnnotatedType<T> plugType = beanManager.createAnnotatedType(type);

        InjectionTarget<T> it = beanManager.createInjectionTarget(plugType);

        CreationalContext<T> ctx = beanManager.createCreationalContext(null);

        T plug = it.produce(ctx);

        it.inject(plug, ctx);

        it.postConstruct(plug);

      everything works fine for A1,

      but then while trying to instanciate A2 i notice that the backtype of plugType  is actually A1 and  so the instance created is of A1 and not A2,

      please help

      Thanks.