Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Resource.load error: ">" is not legal(Strange error when loading an XMI model)
Resource.load error: ">" is not legal [message #1777500] Wed, 29 November 2017 17:41 Go to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 67
Registered: November 2015
Location: York, UK
Member
So I have the MoDisco Java metamodel and some test model file. When I load this, I get the following stack trace:

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '>' is not legal. (file:///D:/GDrive/PhD/Experiments/org.eclipse.ocl.examples.project.oclinecoretutorial/src/javaMM/launch/test.xmi, 1106, 119)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:77)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:185)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
	at org.eclipse.epsilon.evl.engine.test.acceptance.equivalence.StandaloneOCL.run(StandaloneOCL.java:187)
	at javaMM.launch.JavaMMLauncher.main(JavaMMLauncher.java:25)
Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '>' is not legal. (file:///D:/GDrive/PhD/Experiments/org.eclipse.ocl.examples.project.oclinecoretutorial/src/javaMM/launch/test.xmi, 1106, 119)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2697)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XMLHandler.java:2751)
	at org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAttribs(SAXXMIHandler.java:79)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFactory(XMLHandler.java:2229)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTypeName(XMLHandler.java:2132)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2067)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHandler.java:151)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1876)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1030)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:82)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:190)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1359)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
	... 5 more
Caused by: java.lang.IllegalArgumentException: The value '>' is not a valid enumerator of 'InfixExpressionKind'
	at org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(EFactoryImpl.java:307)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1615)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1156)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2692)
	... 29 more



But the thing is, I've loaded this file before and it works in another context, but not this one. I'm trying to figure out the cause of the error and I'm certain it's nothing to do with the XML file (I looked at the text and it's simply a character inside a string, not an invalid XML file). So what could be causing this behaviour?

Thanks.
Re: Resource.load error: ">" is not legal [message #1777539 is a reply to message #1777500] Thu, 30 November 2017 06:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6037
Registered: July 2009
Senior Member
Hi

Use of > in XML is unwise although not illegal. Some tooling assumes that both < and > are encoded as &lt;, &gt; although > is not absolutely necessary. Usage within a string makes no difference.

EMF generally encodes awkward characters, but not always. For instance xmi:id's are expected to have a compatible allocation algorithm; a validity check would be a waste of time.

EMF is closely associated with generation of Java and so characters that are not legal in Java are generally subject to a correction, but perhaps not always.

So long as you avoid Java generation you can use >. Thus GIT\org.eclipse.ocl\plugins\org.eclipse.ocl.ecore\model\oclstdlib.ecore has an Integer:: ">" operation. However you must now ignore validation errors. Such operations are often converted to perhaps _ge_ for Java.

Without a repro it is difficult to know which of the many traps you have fallen in to. Have you put your not-invalid XML through an XML validator?

Regards

Ed Willink
Re: Resource.load error: ">" is not legal [message #1777556 is a reply to message #1777539] Thu, 30 November 2017 10:15 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29538
Registered: July 2009
Senior Member
It seems to me that this part of the stack trace pretty clearly indicates the problem:
Caused by: java.lang.IllegalArgumentException: The value '>' is not a valid enumerator of 'InfixExpressionKind'
	at org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(EFactoryImpl.java:307)
I.e., at line 1106 column 119 of the file, the value is '>' (presumably properly encoded, otherwise there would be a SAX error for the invalid XML which is not the case) and that value isn't one of the enumerators of InfixExpressionKind, whatever type that is and whatever the literals for it's enumerators are supposed to be.

Re: Resource.load error: ">" is not legal [message #1777563 is a reply to message #1777556] Thu, 30 November 2017 11:22 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 67
Registered: November 2015
Location: York, UK
Member
Hi Ed(s),

Thanks for pointing that out, I must've missed that part. As you say it seems that it's not an XML parsing issue but an exception from EMF. I am using this in the context of OCLInEcore, with generated Java code. Perhaps the model is being eagerly validated on load, or the OCL Java code generator has done something wrong?
Re: Resource.load error: ">" is not legal [message #1777566 is a reply to message #1777563] Thu, 30 November 2017 11:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29538
Registered: July 2009
Senior Member
It's hard to say, but if you have a feature in your/the model of type InfixExpressionKind then the serializer will use org.eclipse.emf.ecore.impl.EEnumLiteralImpl.toString()
  public String toString()
  {
    return getLiteral();
  }
and the deserializer in org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(EDataType, String) will do use
    if (eDataType instanceof EEnum)
    {
      Object result = ((EEnum)eDataType).getEEnumLiteralByLiteral(stringValue);
      if (result == null)
      {
        throw new IllegalArgumentException("The value '" + stringValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
      }
      return result;
    }
to convert it back to a value. This is not validation, this is basic deserialization logic that is absolutely needed to produce a proper representation. If the InfixExpressionKind came from a generated model, I would have expected the generated XyzFactoryImpl for that generated model's factory be be used. But apparently there isn't a generated model for it. Still it should work properly for an EEnum, i.e., it serializes the literal value of the EEnumLiteral and looks it up (by literal value) in the EEnum when deserializing. I can't say what has gone wrong except that perhaps you serialized with one version of the model for InfixExpressionKind and are deserializing with another version.
Re: Resource.load error: ">" is not legal [message #1777568 is a reply to message #1777566] Thu, 30 November 2017 11:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6037
Registered: July 2009
Senior Member
Hi

You may well have an OCL2Java tooling issue, but until you provide a repro, you will be lucky if I can guess at what your snippets indicate is the problem.

Regards

Ed Willink
Re: Resource.load error: ">" is not legal [message #1777571 is a reply to message #1777566] Thu, 30 November 2017 11:58 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 67
Registered: November 2015
Location: York, UK
Member
Hi Ed,

Thanks for the clarification. I tried regenerating the code an ensuring the application was pointing to the right metamodel and even tried with other models, but I still get the same issue. I suspect the issue is therefore not with the generated code because this error occurs before any of the generated code is invoked. Yet when I try to load the exact same model with a plain Ecore metamodel (i.e. without OCL constraints) where there are no issues there. So the only possibility is that there are some unreported errors in the OCLinEcore version of the metamodel, even though the generated code has no errors.
Re: Resource.load error: ">" is not legal [message #1777573 is a reply to message #1777568] Thu, 30 November 2017 12:06 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 67
Registered: November 2015
Location: York, UK
Member
Hi,

I have attached the relevant files if that's helpful. Thanks again for the replies.
  • Attachment: issue.zip
    (Size: 32.68KB, Downloaded 38 times)
Re: Resource.load error: ">" is not legal [message #1777575 is a reply to message #1777573] Thu, 30 November 2017 12:53 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6037
Registered: July 2009
Senior Member
Hi

It would be easier if you hadn't flattemed the folder hierarchies .... Zipped projects are much better since we see immediately see what you see without having to waste time guessing what you hide.

<expression xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.32" operator=">">

shows that you are requesting an InfixExpressionKind named ">" and there is none. There is one spelled GREATER.

Regards

Ed Willink



Re: Resource.load error: ">" is not legal [message #1777577 is a reply to message #1777575] Thu, 30 November 2017 13:03 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 67
Registered: November 2015
Location: York, UK
Member
Hi Ed,

Sorry for the inconvenience.
I'm not sure how this could have happened, looking at the OCLinEcore metamodel I don't see anything like that, since I copy-pasted from the CompleteOCL document and changed the syntax to fit the OCLInEcore one, and the CompleteOCL document worked fine. Perhaps OCLInEcore handles EEnums differently (or the code generation doesn't play well with literals)?
Re: Resource.load error: ">" is not legal [message #1777662 is a reply to message #1777577] Fri, 01 December 2017 10:27 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 67
Registered: November 2015
Location: York, UK
Member
I think I understand what's happening now. The MoDisco generator uses the EEnum literals rather than the names when writing the XMI files, and the OCLinEcore version of the metamodel and/or generated code uses the EEnum name instead, so basically I cannot use MoDisco models and compiled OCL together.

Once again thanks for your help.
Re: Resource.load error: ">" is not legal [message #1777665 is a reply to message #1777662] Fri, 01 December 2017 10:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6037
Registered: July 2009
Senior Member
Hi

I'm trying to make sense of this. I don't make much use of EEnumLiteral::literal, so I was puzzled that an EEnumLiteral could be all of:

name = GREATER
value = 5
literal = >

I find that https://bugs.eclipse.org/bugs/show_bug.cgi?id=382956 complains that OCLinEcore doesn't support the literal field at all; it is stripped so it is difficult to believe that this can be an OCL copy paste problem.

I find no reference to EEnumLiteral.getLiteral anywhere in the main OCL code so I see no prospect that InfixExpressionKind::_'>' could have been anything other than an unresolved name.

I'm surprised to see the EEnumLiteral.getLiteral specifies that the literal is the preferred serialization; name is the fallback. Playing around in the Sample Ecore Editor, I find that the literal is the consistent visual choice. All looks good and consistent.

If I have a model with EQ, LT, GT names and corresponding =, <, > literals I find the literals consistently used in menus and consistently serialized and loaded.

However if you allowed OCLinEcore to strip the enum literals after you created test.xmi but before your load failure, Bug 382956 may explain how your Ecore got corrupted inhibiting the load.

Bug 382956 is now major. Apologies for the trouble. Workaround: Use Sample Ecore Editor/Text editor to restore the literal values.

Regards

Ed Willink

Re: Resource.load error: ">" is not legal [message #1777765 is a reply to message #1777665] Mon, 04 December 2017 12:08 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 67
Registered: November 2015
Location: York, UK
Member
Hi Ed,

Thanks for the reply. Bug 382956 certainly seems the cause of the issue, since I noticed that when opening the java_findbugs.ecore file with the OCLinEcore editor, the enum literals are not there; only names and numbers. I tried generating another Java model from the generated OCL code and re-running the program. Again I got an error that '+' is not legal. However when I opened the original java.ecore (without any embedded OCL) I see the literals are there, but when opening java_findbugs.ecore I see that the literal value is the same as the name. So, I made a copy of the original metamodel (java.ecore), opened that with OCLinEcore editor, copy-pasted the contents of the java_findbugs.ecore as shown in OCLinEcore editor and saved. Even without running the program, opening this with the sample Ecore editor shows that the EEnum literals have been replaced by the names instead.
Re: Resource.load error: ">" is not legal [message #1777768 is a reply to message #1777765] Mon, 04 December 2017 12:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6037
Registered: July 2009
Senior Member
Hi

The fix should be available in

http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/ocl/downloads/drops/6.4.0/I201711170651/mdt-ocl-Update-I201711170651.zip

If installation gives trouble, you may need to wait till next week when a coherent EMF build is available as part of Photon M4; EMF added APIs at M2, but didn't release them.

Regards

Ed Willink
Re: Resource.load error: ">" is not legal [message #1777770 is a reply to message #1777768] Mon, 04 December 2017 14:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29538
Registered: July 2009
Senior Member
Note that the update site http://download.eclipse.org/modeling/emf/emf/updates/2.14milestones contains the build that will be contributed to Photon M4.
Re: Resource.load error: ">" is not legal [message #1777864 is a reply to message #1777770] Tue, 05 December 2017 13:08 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 67
Registered: November 2015
Location: York, UK
Member
Hi Ed,

Thanks for the update. I managed to install from the zip file successfully (at least I think I did) but the issue still persists. Would you happen to know what the name of the specific plug-in which has been patched is so I can check the version number?
Re: Resource.load error: ">" is not legal [message #1777877 is a reply to message #1777864] Tue, 05 December 2017 14:30 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6037
Registered: July 2009
Senior Member
Hi

https://hudson.eclipse.org/ocl/job/ocl-photon-master/changes clearly shows that the three [382956] commits went into
https://hudson.eclipse.org/ocl/job/ocl-photon-master/70/ which corresponds to
http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/ocl/downloads/drops/6.4.0/N201712012043/mdt-ocl-Update-N201712012043.zip

(But oddly build 72 should have also been promoted but wasn't. Perhaps this is a Tycho cleverness at reusing timestamps for no-change.)

org.eclipse.ocl.pivot is an affected plugin. It should be 1.4.0.v20171201-2043

When I install it in my workspace my test file shows.

package Bug382956 : Bug382956 = 'http://Bug382956'
{
enum ComparisonKind { serializable }
{
literal EQ : '=';
literal GT : '>' = 1;
literal LT : '<' = 2;
}
class MyClass
{
attribute comparison : ComparisonKind[?] = '=';
}
}

In "literal GT = 1" you can see the new ": '>'" clause that supports the literal property.

Regards

Ed Willink
Re: Resource.load error: ">" is not legal [message #1777896 is a reply to message #1777877] Tue, 05 December 2017 17:24 Go to previous message
Sina Madani is currently offline Sina MadaniFriend
Messages: 67
Registered: November 2015
Location: York, UK
Member
Hi Ed,

Thanks for the clarification. It seems the zip file you linked earlier wasn't the right one - the new one has done the trick! Once again thank you very much for your persistence and help regarding this issue.

Best Wishes,
Sina Madani
Previous Topic:Ecore2GenModel with refGenModel
Next Topic:Platform:/plugin uri could not be resolved
Goto Forum:
  


Current Time: Wed Sep 19 22:52:30 GMT 2018

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

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

Back to the top