Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem loading model as a resource
Problem loading model as a resource [message #425941] Fri, 12 December 2008 17:07 Go to next message
Andy Carpenter is currently offline Andy CarpenterFriend
Messages: 145
Registered: July 2009
Senior Member
I'm loading an ecore resource (attached) indirectly through a class
provided by TCS. From one use of this class the resource is
correctly loaded, while from a different use an exception is thrown
(stack trace attached). Several levels below my use of the TCS
class, the resource is loaded by a call on getResource method
provided by a ResourceSet.

My debugging shows an attempt to load the same file is made in both
cases. Thus, despite the exception, I do not believe that the model being
loaded is corrupt.

As a result, I believe that a setting in the environment may be affecting
the way in which EcoreResourceImpl is loading the resource. I've checked
the load options on the ResourceSet and they are the same in both
cases. The package registry of the ResourceSet shows that the Ecore
package is registered.

Any ideas on what can affect the way that a resource is loaded would
be appreciated.

thanks
Andy.


--
-- ------------------------------------------------------------ -------------
Dr Andy Carpenter
School of Computer Science,
University of Manchester, Manchester M13 9PL, UK
Email: Andy.Carpenter@manchester.ac.uk
Tel: +44 161 275 6168
Fax: +44 161 275 6280



  • Attachment: stackTrace.txt
    (Size: 5.46KB, Downloaded 208 times)
  • Attachment: TCS.ecore
    (Size: 29.24KB, Downloaded 148 times)
Re: Problem loading model as a resource [message #425947 is a reply to message #425941] Fri, 12 December 2008 22:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30892
Registered: July 2009
Senior Member
Andy,

Comments below.

Andy Carpenter wrote:
> I'm loading an ecore resource (attached) indirectly through a class
> provided by TCS. From one use of this class the resource is
> correctly loaded, while from a different use an exception is thrown
> (stack trace attached). Several levels below my use of the TCS
> class, the resource is loaded by a call on getResource method
> provided by a ResourceSet.
>
> My debugging shows an attempt to load the same file is made in both
> cases. Thus, despite the exception, I do not believe that the model being
> loaded is corrupt.
>
> As a result, I believe that a setting in the environment may be affecting
> the way in which EcoreResourceImpl is loading the resource. I've checked
> the load options on the ResourceSet and they are the same in both
> cases. The package registry of the ResourceSet shows that the Ecore
> package is registered.
>
> Any ideas on what can affect the way that a resource is loaded would
> be appreciated.
>
It's really hard to say given all the things I see on the stack. Can
you tell what full string is being passed to ResourceImpl.getEObject? I
imagine it ought to be "/1/String" but that should find the class named
String in the second package, but instead it's ending up with "tring"
but I can't imagine why...
> thanks
> Andy.
>
>
>
Re: Problem loading model as a resource [message #426073 is a reply to message #425947] Mon, 15 December 2008 16:31 Go to previous messageGo to next message
Andy Carpenter is currently offline Andy CarpenterFriend
Messages: 145
Registered: July 2009
Senior Member
Ed, thanks for your comments. Further information is
given below.

Andy.

"Ed Merks" <Ed.Merks@gmail.com> wrote in message
news:ghun6h$pih$1@build.eclipse.org...
> Andy,
>
> Comments below.
>
> Andy Carpenter wrote:
>> I'm loading an ecore resource (attached) indirectly through a class
>> provided by TCS. From one use of this class the resource is
>> correctly loaded, while from a different use an exception is thrown
>> (stack trace attached). Several levels below my use of the TCS
>> class, the resource is loaded by a call on getResource method
>> provided by a ResourceSet.
>>
>> My debugging shows an attempt to load the same file is made in both
>> cases. Thus, despite the exception, I do not believe that the model being
>> loaded is corrupt.
>>
>> As a result, I believe that a setting in the environment may be affecting
>> the way in which EcoreResourceImpl is loading the resource. I've checked
>> the load options on the ResourceSet and they are the same in both
>> cases. The package registry of the ResourceSet shows that the Ecore
>> package is registered.
>>
>> Any ideas on what can affect the way that a resource is loaded would
>> be appreciated.
>>
> It's really hard to say given all the things I see on the stack. Can you
> tell what full string is being passed to ResourceImpl.getEObject? I
> imagine it ought to be "/1/String" but that should find the class named
> String in the second package, but instead it's ending up with "tring" but
> I can't imagine why...

Okay, I've checked and "/1/String" is being passed to
ResourceImpl.getEObject. The processing of this appears to find the
second package in the resource and then called
eObjectForURIFragmentSegment on the package. In this case
the method called is the one present on BasicEObjectImpl. Looking at
the code here, it does not seem to consider that the object might be
an EPackage and that a contained declaration rather than a structural
feature should be found. So, that explains the why the exception is
thrown.

However, given that the TCS model being loaded is an Ecore model,
I can't explain why the TCS model is being loaded as a dynamic model
rather than using the classes generated from the ecore.ecore model.
Re: Problem loading model as a resource [message #426212 is a reply to message #425941] Fri, 19 December 2008 15:39 Go to previous message
Andy Carpenter is currently offline Andy CarpenterFriend
Messages: 145
Registered: July 2009
Senior Member
Okay, I've now determined what was going wrong. So for
completeness, I'll document it here.

The main cause of the problem was that I was trying to
process a copy of the ecore model; treating it as a model
not as a meta-model.

This then caused an issue because of the way in which ATL
handles models. ATL has a static resource set that it uses for
all models that it loads, with the package registry of this
resource set keeping details of the models.

As part of generating some Emfatic syntax the TCS model was
needed. To load this model, it's meta-model (ecore) was required.
Unfortunately, my copy of the ecore model was found in the
ATL resource set not the one from the global package registry.
For some reason the factory for my copy was an instance of
EFactoryImpl not EcoreFactoryImpl. The effect of this was that
the TCS model was loaded as a dynamic ecore model which
then generated an exception when attempting to resolve some
forward references.

Quite a tricky one to find.

Andy.

"Andy Carpenter" <Andy.Carpenter@manchester.ac.uk> wrote in message
news:ghu670$6rc$1@build.eclipse.org...
> I'm loading an ecore resource (attached) indirectly through a class
> provided by TCS. From one use of this class the resource is
> correctly loaded, while from a different use an exception is thrown
> (stack trace attached). Several levels below my use of the TCS
> class, the resource is loaded by a call on getResource method
> provided by a ResourceSet.
>
> My debugging shows an attempt to load the same file is made in both
> cases. Thus, despite the exception, I do not believe that the model being
> loaded is corrupt.
>
> As a result, I believe that a setting in the environment may be affecting
> the way in which EcoreResourceImpl is loading the resource. I've checked
> the load options on the ResourceSet and they are the same in both
> cases. The package registry of the ResourceSet shows that the Ecore
> package is registered.
>
> Any ideas on what can affect the way that a resource is loaded would
> be appreciated.
>
> thanks
> Andy.
>
>
> --
> -- ------------------------------------------------------------ -------------
> Dr Andy Carpenter
> School of Computer Science,
> University of Manchester, Manchester M13 9PL, UK
> Email: Andy.Carpenter@manchester.ac.uk
> Tel: +44 161 275 6168
> Fax: +44 161 275 6280
>
>
Previous Topic:Add IProgressMonitor to DeleteCommand
Next Topic:[CDO] CDO 2.0.0 installation under Eclipse 3.5M4
Goto Forum:
  


Current Time: Thu Feb 20 13:55:31 GMT 2020

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

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

Back to the top