Skip to main content



      Home
Home » Modeling » UML2 » Unable to create 'ResourceSetImpl' instance in Eclipse 3.4.1
Unable to create 'ResourceSetImpl' instance in Eclipse 3.4.1 [message #478105] Tue, 06 January 2009 03:30 Go to next message
Eclipse UserFriend
I have just started working on an UML project after studying the article
"Getting Started with UML2" from the following URL:

http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Getti ng_Started_with_UML2/article.html

I have followed all steps given in this article, and its working except
these lines:

------------------------------------------------------------ ----------------
URI uri =
URI.createURI("file:///C:").appendSegment("Try-ExtendedPO2-Activity").appendFileExtension(UMLResource.FILE_EXTENSION);

save(model, uri);
------------------------------------------------------------ ----------------

protected static void save(org.eclipse.uml2.uml.Package package_, URI uri)
{
Resource resource = new ResourceSetImpl().createResource(uri);
resource.getContents().add(package_);
----------------
----------------
----------------
}
------------------------------------------------------------ ----------------


But the line "new ResourceSetImpl().createResource(uri);"
always returns a null object, even if the uri object is proper.

I am unable to understand the problem b'coz I have installed all required
plugins as given in article. (Also ResourceSetImpl class is also present
into workspace of eclipse 3.4.1)

Please tell me the cause of my problem.

Thanks in advance.
Kishore
Re: Unable to create 'ResourceSetImpl' instance in Eclipse 3.4.1 [message #478106 is a reply to message #478105] Tue, 06 January 2009 04:26 Go to previous messageGo to next message
Eclipse UserFriend
Kishore,

Keep in mind that if you aren't running as an Eclipse application, which
I suppose the getting started guide assumes you are, then plugin.xml
registration of resource factories won't happen (nor any other
plugin.xml registrations). I don't really see where the required setup
for stand alone execution is documented...


kishore wrote:
> I have just started working on an UML project after studying the
> article "Getting Started with UML2" from the following URL:
>
> http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Getti ng_Started_with_UML2/article.html
>
>
> I have followed all steps given in this article, and its working
> except these lines:
>
> ------------------------------------------------------------ ----------------
>
> URI uri =
> URI.createURI("file:///C:").appendSegment("Try-ExtendedPO2-Activity").appendFileExtension(UMLResource.FILE_EXTENSION);
>
>
> save(model, uri);
> ------------------------------------------------------------ ----------------
>
>
> protected static void save(org.eclipse.uml2.uml.Package package_, URI
> uri)
> {
> Resource resource = new ResourceSetImpl().createResource(uri);
> resource.getContents().add(package_);
> ----------------
> ----------------
> ----------------
> }
> ------------------------------------------------------------ ----------------
>
>
>
> But the line "new ResourceSetImpl().createResource(uri);"
> always returns a null object, even if the uri object is proper.
>
> I am unable to understand the problem b'coz I have installed all
> required plugins as given in article. (Also ResourceSetImpl class is
> also present into workspace of eclipse 3.4.1)
>
> Please tell me the cause of my problem.
>
> Thanks in advance.
> Kishore
Re: Unable to create 'ResourceSetImpl' instance in Eclipse 3.4.1 [message #478107 is a reply to message #478106] Tue, 06 January 2009 05:14 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Ed Merks.

Yes I was running it as a Eclipse Application. After your reply, I
understand my silly mistake. Now its working fine.

Thanks again.

Regards
Kishore
Re: Unable to create 'ResourceSetImpl' instance in Eclipse 3.4.1 [message #627313 is a reply to message #478105] Tue, 06 January 2009 04:26 Go to previous messageGo to next message
Eclipse UserFriend
Kishore,

Keep in mind that if you aren't running as an Eclipse application, which
I suppose the getting started guide assumes you are, then plugin.xml
registration of resource factories won't happen (nor any other
plugin.xml registrations). I don't really see where the required setup
for stand alone execution is documented...


kishore wrote:
> I have just started working on an UML project after studying the
> article "Getting Started with UML2" from the following URL:
>
> http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Getti ng_Started_with_UML2/article.html
>
>
> I have followed all steps given in this article, and its working
> except these lines:
>
> ------------------------------------------------------------ ----------------
>
> URI uri =
> URI.createURI("file:///C:").appendSegment("Try-ExtendedPO2-Activity").appendFileExtension(UMLResource.FILE_EXTENSION);
>
>
> save(model, uri);
> ------------------------------------------------------------ ----------------
>
>
> protected static void save(org.eclipse.uml2.uml.Package package_, URI
> uri)
> {
> Resource resource = new ResourceSetImpl().createResource(uri);
> resource.getContents().add(package_);
> ----------------
> ----------------
> ----------------
> }
> ------------------------------------------------------------ ----------------
>
>
>
> But the line "new ResourceSetImpl().createResource(uri);"
> always returns a null object, even if the uri object is proper.
>
> I am unable to understand the problem b'coz I have installed all
> required plugins as given in article. (Also ResourceSetImpl class is
> also present into workspace of eclipse 3.4.1)
>
> Please tell me the cause of my problem.
>
> Thanks in advance.
> Kishore
Re: Unable to create 'ResourceSetImpl' instance in Eclipse 3.4.1 [message #627314 is a reply to message #478106] Tue, 06 January 2009 05:14 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Ed Merks.

Yes I was running it as a Eclipse Application. After your reply, I
understand my silly mistake. Now its working fine.

Thanks again.

Regards
Kishore
Re: Unable to create 'ResourceSetImpl' instance in Eclipse 3.4.1 [message #643060 is a reply to message #478105] Fri, 03 December 2010 14:21 Go to previous message
Eclipse UserFriend

Try this:

		Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
		Map<String, Object> m = reg.getExtensionToFactoryMap();
		m.put(UMLResource.FILE_EXTENSION, new XMIResourceFactoryImpl());

		Resource resource = new ResourceSetImpl().createResource(uri);

Previous Topic:load correctly an UML profile
Next Topic:Problem in set property value
Goto Forum:
  


Current Time: Tue Jul 22 19:34:50 EDT 2025

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

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

Back to the top