Bug or Feature: guiDesigner redist package SupportCode does not support external classloaders

Hi there,

i am developing a module-oriented application which incorporates modules
bei using a url classloader dynamically. While all module classes can be
loaded successfully, the forms designed by the gui designer claim missing
resources which - in fact - ARE present in the same jar as the classes of
the module (it is working, if I put it in the same classloader). Analyzing
the class SupportCode it seems as if getResourceString uses a classloader
determined at the beginning of the first use (static initializer). While
the first use is propably from within the external application (which loads
the modules), the getBundle-Method is using the wrong classloader and therefore
cannot find the resources.

Any help is appreciated.

Best Regards


Roland


6 comments
Comment actions Permalink

Hello Roland,

RK> i am developing a module-oriented application which incorporates
RK> modules bei using a url classloader dynamically. While all module
RK> classes can be loaded successfully, the forms designed by the gui
RK> designer claim missing resources which - in fact - ARE present in
RK> the same jar as the classes of the module (it is working, if I put
RK> it in the same classloader). Analyzing the class SupportCode it
RK> seems as if getResourceString uses a classloader determined at the
RK> beginning of the first use (static initializer). While the first use
RK> is propably from within the external application (which loads the
RK> modules), the getBundle-Method is using the wrong classloader and
RK> therefore cannot find the resources.

Which exactly version of IntelliJ IDEA are you using? The code generated
by the UI Designer in the Demetra EAP builds no longer references the SupportCode
class, so your forms should work correctly with that.

--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Hello Dmitry,

I use 5.1.2. But do you recommend switch to demetra now? - I need a solution
for that as quick as possible. :(

Best

Roland

Hello Roland,

RK>> i am developing a module-oriented application which incorporates
RK>> modules bei using a url classloader dynamically. While all module
RK>> classes can be loaded successfully, the forms designed by the gui
RK>> designer claim missing resources which - in fact - ARE present in
RK>> the same jar as the classes of the module (it is working, if I put
RK>> it in the same classloader). Analyzing the class SupportCode it
RK>> seems as if getResourceString uses a classloader determined at the
RK>> beginning of the first use (static initializer). While the first
RK>> use is propably from within the external application (which loads
RK>> the modules), the getBundle-Method is using the wrong classloader
RK>> and therefore cannot find the resources.
RK>>

Which exactly version of IntelliJ IDEA are you using? The code
generated by the UI Designer in the Demetra EAP builds no longer
references the SupportCode class, so your forms should work correctly
with that.



0
Comment actions Permalink

Hello Roland,

The other option is to edit and recompile the SupportCode class.

RK> I use 5.1.2. But do you recommend switch to demetra now? - I need a
RK> solution for that as quick as possible. :(
RK>
RK> Best
RK>
RK> Roland
RK>
>> Hello Roland,
>>
RK>>> i am developing a module-oriented application which incorporates
RK>>> modules bei using a url classloader dynamically. While all module
RK>>> classes can be loaded successfully, the forms designed by the gui
RK>>> designer claim missing resources which - in fact - ARE present in
RK>>> the same jar as the classes of the module (it is working, if I put
RK>>> it in the same classloader). Analyzing the class SupportCode it
RK>>> seems as if getResourceString uses a classloader determined at the
RK>>> beginning of the first use (static initializer). While the first
RK>>> use is propably from within the external application (which loads
RK>>> the modules), the getBundle-Method is using the wrong classloader
RK>>> and therefore cannot find the resources.
RK>>>
>> Which exactly version of IntelliJ IDEA are you using? The code
>> generated by the UI Designer in the Demetra EAP builds no longer
>> references the SupportCode class, so your forms should work correctly
>> with that.
>>
--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Hello Dmitry,

that's what I thought to do, but some of the code is written by the uiDesigner.
I don't see how this should work.

e.g. in the form class you can see something like

SupportCode.getResourceString(String bundleName, String key)...

should be

SupportCode.getResourceString(String bundleName, String key, getClass().getClassLoader())...

Another solution would be to not to use ITN in forms. Any other ideas?

Best

Roland

Hello Roland,

The other option is to edit and recompile the SupportCode class.

RK>> I use 5.1.2. But do you recommend switch to demetra now? - I need a
RK>> solution for that as quick as possible. :(
RK>>
RK>> Best
RK>>
RK>> Roland
RK>>
>>> Hello Roland,
>>>
RK>>>> i am developing a module-oriented application which incorporates
RK>>>> modules bei using a url classloader dynamically. While all module
RK>>>> classes can be loaded successfully, the forms designed by the gui
RK>>>> designer claim missing resources which - in fact - ARE present in
RK>>>> the same jar as the classes of the module (it is working, if I
RK>>>> put it in the same classloader). Analyzing the class SupportCode
RK>>>> it seems as if getResourceString uses a classloader determined at
RK>>>> the beginning of the first use (static initializer). While the
RK>>>> first use is propably from within the external application (which
RK>>>> loads the modules), the getBundle-Method is using the wrong
RK>>>> classloader and therefore cannot find the resources.
RK>>>>
>>> Which exactly version of IntelliJ IDEA are you using? The code
>>> generated by the UI Designer in the Demetra EAP builds no longer
>>> references the SupportCode class, so your forms should work
>>> correctly with that.
>>>


0
Comment actions Permalink

Hello Roland,

In fact, the code in SupportCode does not cache a classloader. Instead, it
tries to cache a reference to ClassLoader.getCallerClassLoader() method obtained
through reflection, and get the classloader of the calling class by invoking
this method. So, theoretically, this should work correctly in your case.

RK> that's what I thought to do, but some of the code is written by the
RK> uiDesigner. I don't see how this should work.
RK>
RK> e.g. in the form class you can see something like
RK>
RK> SupportCode.getResourceString(String bundleName, String key)...
RK>
RK> should be
RK>
RK> SupportCode.getResourceString(String bundleName, String key,
RK> getClass().getClassLoader())...
RK>
RK> Another solution would be to not to use ITN in forms. Any other
RK> ideas?
RK>
RK> Best
RK>
RK> Roland
RK>
>> Hello Roland,
>>
>> The other option is to edit and recompile the SupportCode class.
>>
RK>>> I use 5.1.2. But do you recommend switch to demetra now? - I need
RK>>> a solution for that as quick as possible. :(
RK>>>
RK>>> Best
RK>>>
RK>>> Roland
RK>>>
>>>> Hello Roland,
>>>>
RK>>>>> i am developing a module-oriented application which incorporates
RK>>>>> modules bei using a url classloader dynamically. While all
RK>>>>> module classes can be loaded successfully, the forms designed by
RK>>>>> the gui designer claim missing resources which - in fact - ARE
RK>>>>> present in the same jar as the classes of the module (it is
RK>>>>> working, if I put it in the same classloader). Analyzing the
RK>>>>> class SupportCode it seems as if getResourceString uses a
RK>>>>> classloader determined at the beginning of the first use (static
RK>>>>> initializer). While the first use is propably from within the
RK>>>>> external application (which loads the modules), the
RK>>>>> getBundle-Method is using the wrong classloader and therefore
RK>>>>> cannot find the resources.
RK>>>>>
>>>> Which exactly version of IntelliJ IDEA are you using? The code
>>>> generated by the UI Designer in the Demetra EAP builds no longer
>>>> references the SupportCode class, so your forms should work
>>>> correctly with that.
>>>>
--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Hello Dmitry,

ok. I will have a look at it again.

Best

Roland

Hello Roland,

In fact, the code in SupportCode does not cache a classloader.
Instead, it tries to cache a reference to
ClassLoader.getCallerClassLoader() method obtained through reflection,
and get the classloader of the calling class by invoking this method.
So, theoretically, this should work correctly in your case.

RK>> that's what I thought to do, but some of the code is written by the
RK>> uiDesigner. I don't see how this should work.
RK>>
RK>> e.g. in the form class you can see something like
RK>>
RK>> SupportCode.getResourceString(String bundleName, String key)...
RK>>
RK>> should be
RK>>
RK>> SupportCode.getResourceString(String bundleName, String key,
RK>> getClass().getClassLoader())...
RK>>
RK>> Another solution would be to not to use ITN in forms. Any other
RK>> ideas?
RK>>
RK>> Best
RK>>
RK>> Roland
RK>>
>>> Hello Roland,
>>>
>>> The other option is to edit and recompile the SupportCode class.
>>>
RK>>>> I use 5.1.2. But do you recommend switch to demetra now? - I need
RK>>>> a solution for that as quick as possible. :(
RK>>>>
RK>>>> Best
RK>>>>
RK>>>> Roland
RK>>>>
>>>>> Hello Roland,
>>>>>
RK>>>>>> i am developing a module-oriented application which
RK>>>>>> incorporates modules bei using a url classloader dynamically.
RK>>>>>> While all module classes can be loaded successfully, the forms
RK>>>>>> designed by the gui designer claim missing resources which - in
RK>>>>>> fact - ARE present in the same jar as the classes of the module
RK>>>>>> (it is working, if I put it in the same classloader). Analyzing
RK>>>>>> the class SupportCode it seems as if getResourceString uses a
RK>>>>>> classloader determined at the beginning of the first use
RK>>>>>> (static initializer). While the first use is propably from
RK>>>>>> within the external application (which loads the modules), the
RK>>>>>> getBundle-Method is using the wrong classloader and therefore
RK>>>>>> cannot find the resources.
RK>>>>>>
>>>>> Which exactly version of IntelliJ IDEA are you using? The code
>>>>> generated by the UI Designer in the Demetra EAP builds no longer
>>>>> references the SupportCode class, so your forms should work
>>>>> correctly with that.
>>>>>


0

Please sign in to leave a comment.