[weld-dev] Issue with weld 2.1.0.Final on OSGI

Jozef Hartinger jharting at redhat.com
Thu Nov 14 03:17:06 EST 2013


Glad you got it working!

On 11/13/2013 05:08 PM, Charles Moulliard wrote:
> Hi Jozef,
>
> Thx for the info. Been able to figure out the issue by using 
> Require-Bundle within my example otherwise the package was not imported.
>
> Remark : I will have a look later on to PAx-CDI to allow to import 
> packages of CDI and not like now using Require-Bundle
>
> Regards,
>
> Charles
>
>
> On 11/11/13 09:01, Jozef Hartinger wrote:
>> Hi Charles,
>>
>> Weld uses Pax CDI provided BundleResourceLoader[1] to load classes in 
>> an OSGi bundle. It loads only those that are discovered by 
>> BeanScanner[2].
>>
>> When you call getBeans() Weld does not load the parameter class 
>> anyhow since you already provided a loaded class. Weld will try to 
>> match the type you pass to getBeans() with the types of beans it had 
>> loaded.
>>
>> Jozef
>>
>> [1] 
>> https://github.com/ops4j/org.ops4j.pax.cdi/blob/master/pax-cdi-weld/src/main/java/org/ops4j/pax/cdi/weld/impl/bda/BundleResourceLoader.java
>> [2] 
>> https://github.com/ops4j/org.ops4j.pax.cdi/blob/master/pax-cdi-spi/src/main/java/org/ops4j/pax/cdi/spi/scan/BeanScanner.java
>>
>> On 11/08/2013 07:11 PM, Charles Moulliard wrote:
>>> Hi,
>>>
>>> The following code which is working fine and returns a bean when we run
>>> Junit Test with DeltaSpike does not work when Weld 2.1.0.Final is
>>> deployed on Karaf (OSGI v4.3) with Pax-CDI. Apparently the bean is not
>>> retrieved when we call "beanManager.getBeans("
>>>
>>>
>>>       protected CamelContext getCamelContext(String context, 
>>> BeanManager
>>> beanManager) {
>>>           if (camelContextMap == null) {
>>>               Set<Bean<?>> beans =
>>> beanManager.getBeans(CamelContextMap.class, new AnyLiteral()); // 
>>> return
>>> null
>>>               Bean<?> bean = beanManager.resolve(beans); // return null
>>>               CreationalContext<?> creationalContext =
>>> beanManager.createCreationalContext(bean);
>>>               camelContextMap = (CamelContextMap)
>>> beanManager.getReference(bean, bean.getBeanClass(), creationalContext);
>>>               ObjectHelper.notNull(camelContextMap, "Could not resolve
>>> CamelContextMap");
>>>           }
>>>           return camelContextMap.getCamelContext(context);
>>>       }
>>>
>>> Question : How does WeldContainer loads the class when we use getBeans
>>> as I suspect that we have a problem with the classloader used ?
>>>
>>> Regards,
>>>
>>> Charles
>>> _______________________________________________
>>> weld-dev mailing list
>>> weld-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/weld-dev
>>
>



More information about the weld-dev mailing list