Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Resource Manager getResource problem
Resource Manager getResource problem [message #71032] Tue, 22 January 2008 16:19 Go to next message
Valer Roman is currently offline Valer RomanFriend
Messages: 36
Registered: July 2009
Member
Hi

I am trying to get a resource froim the application packages. I use
this :

RWT.getResourceManager().getResource("ro/val/resource.txt")

this returns null

if I try to register the resource with

RWT.getResourceManager().register("ro/val/resource.txt")

I get exception :

Caused by: java.io.IOException: Resource to read not found:
ro/val/resource.txt
at
org.eclipse.rwt.internal.resources.ResourceUtil.openStream(R esourceUtil.java:228)
at
org.eclipse.rwt.internal.resources.ResourceUtil.readBinary(R esourceUtil.java:177)
at
org.eclipse.rwt.internal.resources.ResourceUtil.read(Resourc eUtil.java:46)


the resource.txt file is in the source path in the ro.val package

Thanks for any help,
Val
Re: Resource Manager getResource problem [message #71058 is a reply to message #71032] Tue, 22 January 2008 16:57 Go to previous messageGo to next message
Valer Roman is currently offline Valer RomanFriend
Messages: 36
Registered: July 2009
Member
Another thing, if I use
this.getClass().getResource("/ro/val/resource.txt") it works

Val wrote:
> Hi
>
> I am trying to get a resource froim the application packages. I use
> this :
>
> RWT.getResourceManager().getResource("ro/val/resource.txt")
>
> this returns null
>
> if I try to register the resource with
>
> RWT.getResourceManager().register("ro/val/resource.txt")
>
> I get exception :
>
> Caused by: java.io.IOException: Resource to read not found:
> ro/val/resource.txt
> at
> org.eclipse.rwt.internal.resources.ResourceUtil.openStream(R esourceUtil.java:228)
>
> at
> org.eclipse.rwt.internal.resources.ResourceUtil.readBinary(R esourceUtil.java:177)
>
> at
> org.eclipse.rwt.internal.resources.ResourceUtil.read(Resourc eUtil.java:46)
>
>
> the resource.txt file is in the source path in the ro.val package
>
> Thanks for any help,
> Val
Re: Resource Manager getResource problem [message #71274 is a reply to message #71058] Wed, 23 January 2008 23:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Val,

you need to specify the class-loader that has access to the resources in
your plug-in (see
org.eclipse.rwt.resources.IResourceManager#setContextLoader) .

Cheers,
Rüdiger

Val wrote:
> Another thing, if I use
> this.getClass().getResource("/ro/val/resource.txt") it works
>
> Val wrote:
>> Hi
>>
>> I am trying to get a resource froim the application packages. I use
>> this :
>>
>> RWT.getResourceManager().getResource("ro/val/resource.txt")
>>
>> this returns null
>>
>> if I try to register the resource with
>>
>> RWT.getResourceManager().register("ro/val/resource.txt")
>>
>> I get exception :
>>
>> Caused by: java.io.IOException: Resource to read not found:
>> ro/val/resource.txt
>> at
>> org.eclipse.rwt.internal.resources.ResourceUtil.openStream(R esourceUtil.java:228)
>>
>> at
>> org.eclipse.rwt.internal.resources.ResourceUtil.readBinary(R esourceUtil.java:177)
>>
>> at
>> org.eclipse.rwt.internal.resources.ResourceUtil.read(Resourc eUtil.java:46)
>>
>>
>>
>> the resource.txt file is in the source path in the ro.val package
>>
>> Thanks for any help,
>> Val
Re: Resource Manager getResource problem [message #71613 is a reply to message #71274] Thu, 24 January 2008 17:53 Go to previous messageGo to next message
Valer Roman is currently offline Valer RomanFriend
Messages: 36
Registered: July 2009
Member
Thanks for the info, it works now :)

Rüdiger Herrmann wrote:
> Val,
>
> you need to specify the class-loader that has access to the resources in
> your plug-in (see
> org.eclipse.rwt.resources.IResourceManager#setContextLoader) .
>
> Cheers,
> Rüdiger
>
> Val wrote:
>> Another thing, if I use
>> this.getClass().getResource("/ro/val/resource.txt") it works
>>
>> Val wrote:
>>> Hi
>>>
>>> I am trying to get a resource froim the application packages. I
>>> use this :
>>>
>>> RWT.getResourceManager().getResource("ro/val/resource.txt")
>>>
>>> this returns null
>>>
>>> if I try to register the resource with
>>>
>>> RWT.getResourceManager().register("ro/val/resource.txt")
>>>
>>> I get exception :
>>>
>>> Caused by: java.io.IOException: Resource to read not found:
>>> ro/val/resource.txt
>>> at
>>> org.eclipse.rwt.internal.resources.ResourceUtil.openStream(R esourceUtil.java:228)
>>>
>>> at
>>> org.eclipse.rwt.internal.resources.ResourceUtil.readBinary(R esourceUtil.java:177)
>>>
>>> at
>>> org.eclipse.rwt.internal.resources.ResourceUtil.read(Resourc eUtil.java:46)
>>>
>>>
>>>
>>> the resource.txt file is in the source path in the ro.val package
>>>
>>> Thanks for any help,
>>> Val
Re: Resource Manager getResource problem [message #71839 is a reply to message #71274] Mon, 28 January 2008 08:40 Go to previous messageGo to next message
Valer Roman is currently offline Valer RomanFriend
Messages: 36
Registered: July 2009
Member
Unfortunately I still have some problems,
I do not know which ContextClassLoader to set on the ResourceManager

I have tried with calling

RWT.getResourceManager().setContextLoader(Thread.currentThre ad().getContextClassLoader());

in the start method of the plugin activator

I still get the error : failed to register, Caused by:
java.io.IOException: Resource to read not found: ro/val/resource.txt

Thanks

Rüdiger Herrmann wrote:
> Val,
>
> you need to specify the class-loader that has access to the resources in
> your plug-in (see
> org.eclipse.rwt.resources.IResourceManager#setContextLoader) .
>
> Cheers,
> Rüdiger
>
> Val wrote:
>> Another thing, if I use
>> this.getClass().getResource("/ro/val/resource.txt") it works
>>
>> Val wrote:
>>> Hi
>>>
>>> I am trying to get a resource froim the application packages. I
>>> use this :
>>>
>>> RWT.getResourceManager().getResource("ro/val/resource.txt")
>>>
>>> this returns null
>>>
>>> if I try to register the resource with
>>>
>>> RWT.getResourceManager().register("ro/val/resource.txt")
>>>
>>> I get exception :
>>>
>>> Caused by: java.io.IOException: Resource to read not found:
>>> ro/val/resource.txt
>>> at
>>> org.eclipse.rwt.internal.resources.ResourceUtil.openStream(R esourceUtil.java:228)
>>>
>>> at
>>> org.eclipse.rwt.internal.resources.ResourceUtil.readBinary(R esourceUtil.java:177)
>>>
>>> at
>>> org.eclipse.rwt.internal.resources.ResourceUtil.read(Resourc eUtil.java:46)
>>>
>>>
>>>
>>> the resource.txt file is in the source path in the ro.val package
>>>
>>> Thanks for any help,
>>> Val
Re: Resource Manager getResource problem [message #72558 is a reply to message #71839] Fri, 01 February 2008 10:05 Go to previous message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Val,

you need to set the ResourceManagers' context-classloader just before
you register the resource and reset it to its previous value afterwards.
If there is a class that resides in the same package as the resource to
load, its classloader would be a good candidate. Usually, any class that
resides in the same bundle should do (special cases left aside, they all
share the same classloader).
Typical code could look like this:

IResourceManager manager = ResourceManager.getInstance();
ClassLoader buffer = manager.getContextLoader();
manager.setContextLoader( <YourClass>.class.getClassLoader() );
try {
// register resource
} finally {
manager.setContextLoader( buffer );
}

HTH
Rüdiger


Val wrote:
> Unfortunately I still have some problems,
> I do not know which ContextClassLoader to set on the ResourceManager
>
> I have tried with calling
>
> RWT.getResourceManager().setContextLoader(Thread.currentThre ad().getContextClassLoader());
>
>
> in the start method of the plugin activator
>
> I still get the error : failed to register, Caused by:
> java.io.IOException: Resource to read not found: ro/val/resource.txt
>
> Thanks
>
> Rüdiger Herrmann wrote:
>> Val,
>>
>> you need to specify the class-loader that has access to the resources
>> in your plug-in (see
>> org.eclipse.rwt.resources.IResourceManager#setContextLoader) .
>>
>> Cheers,
>> Rüdiger
>>
>> Val wrote:
>>> Another thing, if I use
>>> this.getClass().getResource("/ro/val/resource.txt") it works
>>>
>>> Val wrote:
>>>> Hi
>>>>
>>>> I am trying to get a resource froim the application packages. I
>>>> use this :
>>>>
>>>> RWT.getResourceManager().getResource("ro/val/resource.txt")
>>>>
>>>> this returns null
>>>>
>>>> if I try to register the resource with
>>>>
>>>> RWT.getResourceManager().register("ro/val/resource.txt")
>>>>
>>>> I get exception :
>>>>
>>>> Caused by: java.io.IOException: Resource to read not found:
>>>> ro/val/resource.txt
>>>> at
>>>> org.eclipse.rwt.internal.resources.ResourceUtil.openStream(R esourceUtil.java:228)
>>>>
>>>> at
>>>> org.eclipse.rwt.internal.resources.ResourceUtil.readBinary(R esourceUtil.java:177)
>>>>
>>>> at
>>>> org.eclipse.rwt.internal.resources.ResourceUtil.read(Resourc eUtil.java:46)
>>>>
>>>>
>>>>
>>>> the resource.txt file is in the source path in the ro.val package
>>>>
>>>> Thanks for any help,
>>>> Val
Previous Topic:Problem with patch fragments
Next Topic:Do you replace Classes in rt.jar?
Goto Forum:
  


Current Time: Thu Sep 26 03:18:38 GMT 2024

Powered by FUDForum. Page generated in 0.03966 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top