org.eclipse.emf.ecore.xmi.IllegalValueException

I hate exceptions. Yes, I really hate exceptions.

I’ve defined a EDataType EPoint that uses the java class org.eclipse.draw2d.geometry.Point.

Ecore model

In the code I set the start and end point of the ElementView by the corresponding setter that I pass instances of the class Point ( and not EPoint! ).


ElementView view = factory.createElementView();
view.setStartPoint(new Point(20, 20));
view.setEndPoint(new Point(100, 100));

Saving the model produces the following file content:

  
...

    
      
    
  
...

The instances are serialized by the method toString() of the class Point which outputs Point(xx, yy) but these values lead the loading process fail while this message appears:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'Point(20, 20)' is not legal. (file:/.../test1/model.pe, 7, 76)
18:28:12 zprototype.model.impl.ModelManagerImpl::load   Model could not be loaded (org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'Point(20, 20)' is not legal. (file:/.../test1/model.pe, 7, 76))
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:315)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
	at zprototype.model.impl.ModelManagerImpl.load(ModelManagerImpl.java:63)

I tried to replace the Point class by another one but it’s the same problem with that. Now my question is why the value is not legal? Does the deserializer not know how to create the objects from the string?

2 Comments

  1. slopjong

    Ok it’s quite simple. In the factory implementation there is a method createEPointFromString(EDataType, String) that one has to change. But don’t forget to remove the @generated tag to not override it next time the model code is regenerated.

  2. A number of the suppliers conjointly provide a refund guarantee if the businesses don’t seem to be glad with their performance. The correct Ecommerce hosting solutions can maximize your site to make your money last long while yielding the best possible return. That is why you should focus on having social media success in your business.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>