Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » about loadResource issue
about loadResource issue [message #388713] Wed, 20 October 2004 11:12 Go to next message
Eclipse UserFriend
Originally posted by: tranfy.hotmail.com

We have a project developed in eclipse 2.1 and background model
generated by emf 1.1. Now we migrate the project to eclipse 3.0
environment and still use the inital model. But in our development
environment, there are eclipse 3.0 ,gef 3.0 and emf 2.0. That is to say,
we use emf 2.0 to access our model generated by emf 1.1 and get the model
properties.
In our program ,there is a statement

Resource resource =
editingDomain.loadResource(
URI
.createPlatformResourceURI(
modelFile.getFile().getFullPath().toString())
.toString());
In eclipse 2.1 ,emf 1.1 and gef 2.1 environment ,the above code can
successfully run and get the correct resource. But in eclipse 3.0 ,emf 2.0
and gef3.0 environment , the resource got from above code is null.
I can get little docs about resource modification of emf1.1 migrated to
emf2.0.
Can you show me how to get the resource correctly ?
Thank you advance!
Re: about loadResource issue [message #388717 is a reply to message #388713] Wed, 20 October 2004 12:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050803020508050308080804
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Demi,

The loadResource method is implemented like this:

public Resource loadResource(String fileNameURI)
{
try
{
Resource resource =
resourceSet.getResource(URI.createURI(fileNameURI), true);
return resource;
}
catch (Exception exception)
{
EMFEditPlugin.INSTANCE.log(exception);
}

return null;
}

So if you are seeing null, there will be a logged exception. Without
seeing what that exception is, I can't offer any useful advice (because
it should just continue to work as before).

Demi wrote:

> We have a project developed in eclipse 2.1 and background model
>generated by emf 1.1. Now we migrate the project to eclipse 3.0
>environment and still use the inital model. But in our development
>environment, there are eclipse 3.0 ,gef 3.0 and emf 2.0. That is to say,
>we use emf 2.0 to access our model generated by emf 1.1 and get the model
>properties.
> In our program ,there is a statement
>
> Resource resource =
> editingDomain.loadResource(
> URI
> .createPlatformResourceURI(
> modelFile.getFile().getFullPath().toString())
> .toString());
> In eclipse 2.1 ,emf 1.1 and gef 2.1 environment ,the above code can
>successfully run and get the correct resource. But in eclipse 3.0 ,emf 2.0
>and gef3.0 environment , the resource got from above code is null.
> I can get little docs about resource modification of emf1.1 migrated to
>emf2.0.
> Can you show me how to get the resource correctly ?
> Thank you advance!
>
>
>


--------------050803020508050308080804
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Demi,<br>
<br>
The loadResource method is implemented like this:<br>
<blockquote>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: about loadResource issue [message #388736 is a reply to message #388717] Thu, 21 October 2004 01:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tranfy.hotmail.com

Hi Ed,

In our com.viador.datatype.impl package ,which extends EFactoryImpl, there
is a method named createColorFromString as follows:

public Color createColorFromString(EDataType eDataType, String
initialValue) {

return (Color)super.createFromString(eDataType, initialValue);

}


The exception is like that:
java.lang.NullPointerException
at
org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(EFa ctoryImpl.java:369)
at
com.viador.datatype.impl.DatatypeFactoryImpl.createColorFrom String(DatatypeFactoryImpl.java:130)
at
com.viador.datatype.impl.DatatypeFactoryImpl.createFromStrin g(DatatypeFactoryImpl.java:64)
at
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromStrin g(XMLHelperImpl.java:1090)
at
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:768)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:1695)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XML Handler.java:1754)
at
org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAtt ribs(SAXXMIHandler.java:147)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:1339)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:1265)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:1202)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1041)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:441)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:65)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:424)
at
org.eclipse.emf.ecore.xmi.impl.SAXWrapper.startElement(SAXWr apper.java:75)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java: 1674)







Ed Merks wrote:

> Demi,

> The loadResource method is implemented like this:

> public Resource loadResource(String fileNameURI)
> {
> try
> {
> Resource resource =
> resourceSet.getResource(URI.createURI(fileNameURI), true);
> return resource;
> }
> catch (Exception exception)
> {
> EMFEditPlugin.INSTANCE.log(exception);
> }

> return null;
> }

> So if you are seeing null, there will be a logged exception. Without
> seeing what that exception is, I can't offer any useful advice (because
> it should just continue to work as before).

> Demi wrote:

> > We have a project developed in eclipse 2.1 and background model
> >generated by emf 1.1. Now we migrate the project to eclipse 3.0
> >environment and still use the inital model. But in our development
> >environment, there are eclipse 3.0 ,gef 3.0 and emf 2.0. That is to say,
> >we use emf 2.0 to access our model generated by emf 1.1 and get the model
> >properties.
> > In our program ,there is a statement
> >
> > Resource resource =
> > editingDomain.loadResource(
> > URI
> > .createPlatformResourceURI(
> > modelFile.getFile().getFullPath().toString())
> > .toString());
> > In eclipse 2.1 ,emf 1.1 and gef 2.1 environment ,the above code can
> >successfully run and get the correct resource. But in eclipse 3.0 ,emf 2.0
> >and gef3.0 environment , the resource got from above code is null.
> > I can get little docs about resource modification of emf1.1 migrated to
> >emf2.0.
> > Can you show me how to get the resource correctly ?
> > Thank you advance!
> >
> >
> >
Re: about loadResource issue [message #388743 is a reply to message #388736] Thu, 21 October 2004 10:52 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080302020808050103030302
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Demi,

I would have expected you to have an override for creating a Color from
a String. It doesn't look like any of the reflective algorithms can be
successful, and there is a (new) bug in the code when it tries to throw
an exception at the end of the method (because it just can't do it
reflectively). It would be far more efficient to write the explicit
code to do the conversion.

Please open a bugzilla showing this stack trace, and we'll fix the null
pointer problem, but note that I don't think that will actually fix your
problem it will just fail more gracefully.


Demi wrote:

>Hi Ed,
>
>In our com.viador.datatype.impl package ,which extends EFactoryImpl, there
>is a method named createColorFromString as follows:
>
>public Color createColorFromString(EDataType eDataType, String
>initialValue) {
>
> return (Color)super.createFromString(eDataType, initialValue);
>
>}
>
>
>The exception is like that:
>java.lang.NullPointerException
> at
> org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(EFa ctoryImpl.java:369)
> at
> com.viador.datatype.impl.DatatypeFactoryImpl.createColorFrom String(DatatypeFactoryImpl.java:130)
> at
> com.viador.datatype.impl.DatatypeFactoryImpl.createFromStrin g(DatatypeFactoryImpl.java:64)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromStrin g(XMLHelperImpl.java:1090)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:768)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:1695)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XML Handler.java:1754)
> at
> org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAtt ribs(SAXXMIHandler.java:147)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:1339)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:1265)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:1202)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1041)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:441)
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:65)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:424)
> at
> org.eclipse.emf.ecore.xmi.impl.SAXWrapper.startElement(SAXWr apper.java:75)
> at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java: 1674)
>
>
>
>
>
>
>
>Ed Merks wrote:
>
>
>
>>Demi,
>>
>>
>
>
>
>>The loadResource method is implemented like this:
>>
>>
>
>
>
>> public Resource loadResource(String fileNameURI)
>> {
>> try
>> {
>> Resource resource =
>> resourceSet.getResource(URI.createURI(fileNameURI), true);
>> return resource;
>> }
>> catch (Exception exception)
>> {
>> EMFEditPlugin.INSTANCE.log(exception);
>> }
>>
>>
>
>
>
>> return null;
>> }
>>
>>
>
>
>
>>So if you are seeing null, there will be a logged exception. Without
>>seeing what that exception is, I can't offer any useful advice (because
>>it should just continue to work as before).
>>
>>
>
>
>
>>Demi wrote:
>>
>>
>
>
>
>>> We have a project developed in eclipse 2.1 and background model
>>>generated by emf 1.1. Now we migrate the project to eclipse 3.0
>>>environment and still use the inital model. But in our development
>>>environment, there are eclipse 3.0 ,gef 3.0 and emf 2.0. That is to say,
>>>we use emf 2.0 to access our model generated by emf 1.1 and get the model
>>>properties.
>>> In our program ,there is a statement
>>>
>>> Resource resource =
>>> editingDomain.loadResource(
>>> URI
>>> .createPlatformResourceURI(
>>> modelFile.getFile().getFullPath().toString())
>>> .toString());
>>>In eclipse 2.1 ,emf 1.1 and gef 2.1 environment ,the above code can
>>>successfully run and get the correct resource. But in eclipse 3.0 ,emf 2.0
>>>and gef3.0 environment , the resource got from above code is null.
>>>I can get little docs about resource modification of emf1.1 migrated to
>>>emf2.0.
>>>Can you show me how to get the resource correctly ?
>>>Thank you advance!
>>>
>>>
>>>
>>>
>>>
>
>
>
>


--------------080302020808050103030302
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Demi,<br>
<br>
I would have expected you to have an override for creating a Color from
a String.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[SDO] ChangeSummary.getChangedDataObjects() returns a `Property' list?
Next Topic:Can't unzip download?
Goto Forum:
  


Current Time: Thu Apr 25 15:59:56 GMT 2024

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

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

Back to the top