On Tue, Oct 13, 2009 at 11:30 AM, Marc-Andre Houle <[email protected]> wrote:
> Hello user list,
>
> I just wanted to aska quick question and know if I am going in the right
> direction. I am developping a Wicket application (obviously) that can be
> extended through module loaded in an OSGi framework.
>
> At the first attempt, I got this when using an Image with ResourceReference
> in Wicket 1.4.1 :
> java.lang.NullPointerException
> at
> org.apache.wicket.SharedResources.resourceKey(SharedResources.java:335)
> at org.apache.wicket.SharedResources.get(SharedResources.java:219)
> at org.apache.wicket.ResourceReference.bind(ResourceReference.java:137)
> at
> org.apache.wicket.markup.html.image.resource.LocalizedImageResource.bind(LocalizedImageResource.java:180)
> at
> org.apache.wicket.markup.html.image.resource.LocalizedImageResource.setResourceReference(LocalizedImageResource.java:246)
> at
> org.apache.wicket.markup.html.image.Image.setImageResourceReference(Image.java:178)
> at org.apache.wicket.markup.html.image.Image.<init>(Image.java:101)
> at org.apache.wicket.markup.html.image.Image.<init>(Image.java:77)
>
> From what I can see, this is because the scope passed in Resourcereference
> is transferred to a class name string and then it is taken back into a Class
> Object using the default ClassLoader.
>
> Because I am using an OSGi framework, the classloader is not quite natural
> and it can't be used the eaxct same way. I have found a post (
> http://markmail.org/message/zrauqq43hmbwjfvm) that is talking about this
> problem exactly in the Mailing list.
>
> However, I wanted to know how I can change the class resolver used by Wicket
> as sugggested in the post. I have seen tha tthe session object is using a
> class resolver or it can also be changed using the ApplicationSettings
> implementation. What is the best approach as to give the possibility to get
> ride of this problem?
MyApplication#init() { ...
getApplicationSettings().setClassResolver(myresolver); }
> Also, I wanted to know if it would not be a good thing for the framework to
> throw another type of exception then a NullPointer. It is not quite obvious
> what is going on in the framework when this is happening.
actually IClassResolver already specifies that a
ClassNotFoundException should be thrown, but looks like that got lost
at some point and null was returned instead. i fixed it in 1.5.x, best
not to change it in 1.4.x in case people depend on this in their
resolvers :|
> Does somebody got the same issue? Is the Classresolver the only possibility
> for me?
a class resolver is not the only possibility. osgi containers provide
implementation-specific ways of making a bundle into a "super bundle"
that can see all classes in the container. some of these techniques
are called "buddy class loading" and "dynamic imports". google can
help you further.
-igor
>
> Thanks in advance for the answer.
>
> Marc-Andre
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]