Hi,
I am new to blueprint and encountered this problem while trying to
update a spring bean configuration into its equivalent blueprint
version. The problem is that I cannot set a bean property of URL type
with a classpath URL value.

This bean has a URL attribute "location" and has method
setLocation(URL location).

In spring, I can simply pass a classpath URL value to this attribute as in

 <bean ...>
   <property name="location" value="classpath:path/file.txt" />
   ...
 </bean>

In this case, I can see this value gets converted into
"bundle://146.0:1/path/file.txt" (on karaf) and the location attribute
of my bean gets set with this URL value.

In blueprint, this value conversion is not taking place and it is
resulting in the following exception in the log:

Caused by: java.net.MalformedURLException: Unknown protocol: classpath
       at java.net.URL.<init>(URL.java:601)[:1.6.0_24]
       at java.net.URL.<init>(URL.java:464)[:1.6.0_24]
       at java.net.URL.<init>(URL.java:413)[:1.6.0_24]
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)[:1.6.0_24]
       at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)[:1.6.0_24]
       at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)[:1.6.0_24]
       at 
java.lang.reflect.Constructor.newInstance(Constructor.java:513)[:1.6.0_24]
       at 
org.apache.aries.blueprint.utils.ReflectionUtils.newInstance(ReflectionUtils.java:258)[9:org.apache.aries.blueprint:0.3.1]
       at 
org.apache.aries.blueprint.container.AggregateConverter.createObject(AggregateConverter.java:307)[9:org.apache.aries.blueprint:0.3.1]
       ... 24 more
2011-10-31 13:20:44,516 | DEBUG | rint Extender: 3 |
BlueprintEventDispatcher    | ntainer.BlueprintEventDispatcher  123 |
9 - org.apache.aries.blueprint - 0.3.1 | Sending blueprint container
event BlueprintEvent[type=FAILURE, exception=Error setting property:
PropertyDescriptor <name: location, getter: public java.net.URL
tmp.test.osgi.blueprint.Client01.getLocation(), setter: [public void
tmp.test.osgi.blueprint.Client01.setLocation(java.net.URL)]] for
bundle tmp.test-bp-01


Could someone tell me if I am missing something in my configuration or
if this is a known limitation?

Regards, Aki

Reply via email to