Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » TEXO - ModelEMFConverter - IllegalStateException
TEXO - ModelEMFConverter - IllegalStateException [message #768168] Mon, 19 December 2011 17:29 Go to next message
jpfse   is currently offline jpfse Friend
Messages: 18
Registered: December 2011
Junior Member
Hello!

I have two questions:

1- I have a legacy system that contains hand-built pojos. I´m trying to conver those pojos to EMF "EObjects", and I´m not shure if the the ModelEMFConverter and EMFModelConverter classes are capable of converting a pojo not created by EMF or Texo. Are they?

2- I´m having a problem in the convertion process, it returns IllegalStateException. I´ve seen (in the eclipse wiki) that it is recomended to "touch" the model package in order to solve a problem with the same exception, but i don´t understand wath that means. I use the code "WebpagePackage.eINSTANCE.eClass();" before anything else, but it still doesn´t work.

here is the exception text:
Exception in thread "main" java.lang.IllegalStateException: The class class pt.nsn.jsequeir.tutorial.webpage.webpage.impl.WebImpl is not managed by this ModelResolver
at org.eclipse.emf.texo.utils.Check.isNotNull(Check.java:66)
at org.eclipse.emf.texo.model.ModelResolver.getModelDescriptor(ModelResolver.java:290)
at org.eclipse.emf.texo.model.ModelResolver.getModelObject(ModelResolver.java:233)
at org.eclipse.emf.texo.xml.ModelEMFConverter.traverseEReferencesForProxyDetermination(ModelEMFConverter.java:154)
at org.eclipse.emf.texo.xml.ModelEMFConverter.computeProxyObjects(ModelEMFConverter.java:147)
at org.eclipse.emf.texo.xml.ModelEMFConverter.convert(ModelEMFConverter.java:101)
at pt.jsequeir.emfConvertersTest.WebpageTest.main(WebpageTest.java:32)


here is the code from my application:
WebpagePackage.eINSTANCE.eClass();
WebpageFactory factory = WebpageFactory.eINSTANCE;
Web web = factory.createWeb();
web.setName("the web");
WebPage webpage = factory.createWebPage();
webpage.setName("facebook");
web.getPages().add(webpage);

ModelEMFConverter converter = new ModelEMFConverter();
List<Object> pojos = Collections.singletonList((Object) web);

List<EObject> eObjects = converter.convert(pojos);
Object converted = eObjects.get(0);

In this code, I´m using pojos generated from EMF, with the purpose of testing the functionality, as I said before the main objective is to convert legacy pojos.

Thanks in advance!
Re: TEXO - ModelEMFConverter - IllegalStateException [message #768177 is a reply to message #768168] Mon, 19 December 2011 17:43 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
The texo model converters can only be used with Texo generated pojos. When Texo generates pojos it also generates
separate model classes which map the pojos to the emf model (and back). The Texo model converters need this extra model
mapping code (which is generated in separate classes from the pojos).

This also explains the exception as it seems that you are trying to convert non-texo generated code.

gr. Martin

On 12/19/2011 06:29 PM, joaopauloseq wrote:
> Hello!
>
> I have two questions:
>
> 1- I have a legacy system that contains hand-built pojos. I´m trying to conver those pojos to EMF "EObjects", and I´m
> not shure if the the ModelEMFConverter and EMFModelConverter classes are capable of converting a pojo not created by EMF
> or Texo. Are they?
>
> 2- I´m having a problem in the convertion process, it returns IllegalStateException. I´ve seen (in the eclipse wiki)
> that it is recomended to "touch" the model package in order to solve a problem with the same exception, but i don´t
> understand wath that means. I use the code "WebpagePackage.eINSTANCE.eClass();" before anything else, but it still
> doesn´t work.
> here is the exception text:
> Exception in thread "main" java.lang.IllegalStateException: The class class
> pt.nsn.jsequeir.tutorial.webpage.webpage.impl.WebImpl is not managed by this ModelResolver
> at org.eclipse.emf.texo.utils.Check.isNotNull(Check.java:66)
> at org.eclipse.emf.texo.model.ModelResolver.getModelDescriptor(ModelResolver.java:290)
> at org.eclipse.emf.texo.model.ModelResolver.getModelObject(ModelResolver.java:233)
> at org.eclipse.emf.texo.xml.ModelEMFConverter.traverseEReferencesForProxyDetermination(ModelEMFConverter.java:154)
> at org.eclipse.emf.texo.xml.ModelEMFConverter.computeProxyObjects(ModelEMFConverter.java:147)
> at org.eclipse.emf.texo.xml.ModelEMFConverter.convert(ModelEMFConverter.java:101)
> at pt.jsequeir.emfConvertersTest.WebpageTest.main(WebpageTest.java:32)
>
>
> here is the code from my application:
> WebpagePackage.eINSTANCE.eClass();
> WebpageFactory factory = WebpageFactory.eINSTANCE;
> Web web = factory.createWeb();
> web.setName("the web");
> WebPage webpage = factory.createWebPage();
> webpage.setName("facebook");
> web.getPages().add(webpage);
>
> ModelEMFConverter converter = new ModelEMFConverter();
> List<Object> pojos = Collections.singletonList((Object) web);
>
> List<EObject> eObjects = converter.convert(pojos);
> Object converted = eObjects.get(0);
>
> In this code, I´m using pojos generated from EMF, with the purpose of testing the functionality, as I said before the
> main objective is to convert legacy pojos.
>
> Thanks in advance!
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:[Teneo] elver.org Teneo update site not responding
Next Topic:How to generate an additional Factory class
Goto Forum:
  


Current Time: Thu Sep 26 07:09:58 GMT 2024

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

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

Back to the top