Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Unable to Load resource from the jar(Resource Loading from jar is showing FileNotFoundException)
Unable to Load resource from the jar [message #632062] Mon, 11 October 2010 12:31 Go to next message
Animesh Kumar is currently offline Animesh KumarFriend
Messages: 79
Registered: September 2010
Location: Bangalore
Member
I wanted to load files from the jar but i am getting a FileNotFoundException.

I have used the following code:-

There is IPath path which gives the Full path of the jar file ,
for eg. C:/Eclipse/plugins/com.animesh.pluginproject/lib/core.jar

try {
JarFile jarFile = new JarFile(path.toOSString());
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry ze = (JarEntry) entries.nextElement();
String entryName = ze.toString();
String appendedPath = path + "!/" + ze.toString();
URI uri = URI.createFileURI(appendedPath);
URI jarUri = URI.createURI("jar:" + uri.toString());
ResourceSet rs = new ResourceSetImpl();
Resource resource = rs.createResource(jarUri, null);
resource.load(null);

}

} catch (IOException e) {
ErrorLoggingService.logError(ClassPathJarLoader.class, "getControlsFromClassPath", e.getMessage(), e, PhoenixServicesPlugin.getDefault()); //$NON-NLS-1$
}

When i am trying to load the resource using resource.load(null) , I get a FileNotFoundException.



Regards,
Animesh
Re: Unable to Load resource from the jar [message #632152 is a reply to message #632062] Mon, 11 October 2010 18:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Animesh,

Comments below.
Animesh,

At which point in the code below do you get the FileNotFoundException?


Animesh Kumar wrote:
> I wanted to load files from the jar but i am getting a
> FileNotFoundException.
>
> I have used the following code:-
>
> There is IPath path which gives the Full path of the jar file ,
> for eg. C:/Eclipse/plugins/com.animesh.pluginproject/lib/core.jar
>
> try {
> JarFile jarFile = new JarFile(path.toOSString());
> Enumeration<JarEntry> entries = jarFile.entries();
> while (entries.hasMoreElements()) {
> JarEntry ze = (JarEntry) entries.nextElement();
> String entryName = ze.toString();
> String appendedPath = path + "!/" + ze.toString();
> URI uri = URI.createFileURI(appendedPath);
> URI jarUri = URI.createURI("jar:" + uri.toString());
> ResourceSet rs = new ResourceSetImpl();
> Resource resource = rs.createResource(jarUri, null);
> resource.load(null);
>
> }
>
> } catch (IOException e) {
> ErrorLoggingService.logError(ClassPathJarLoader.class,
> "getControlsFromClassPath", e.getMessage(), e,
> PhoenixServicesPlugin.getDefault()); //$NON-NLS-1$
> }
>
> When i am trying to load the resource using resource.load(null) , I
> get a FileNotFoundException.
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Unable to Load resource from the jar [message #632156 is a reply to message #632152] Mon, 11 October 2010 18:47 Go to previous messageGo to next message
Animesh Kumar is currently offline Animesh KumarFriend
Messages: 79
Registered: September 2010
Location: Bangalore
Member
When I try doing, resource.load(null) then i get a file not found exception

Regards,
Animesh
Re: Unable to Load resource from the jar [message #632161 is a reply to message #632156] Mon, 11 October 2010 19:12 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
What does the URI you're trying to load from look like?

Animesh Kumar wrote:
> When I try doing, resource.load(null) then i get a file not found
> exception


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:XMI Serialization - Multiple Ecore Models with cross-references
Next Topic:Fwd: Re: RCP & EMF Compare
Goto Forum:
  


Current Time: Thu Apr 18 23:27:46 GMT 2024

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

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

Back to the top