Value of Enumeration is not legal [message #1016897] |
Fri, 08 March 2013 07:06 |
Al B Messages: 47 Registered: June 2012 |
Member |
|
|
I'm getting several IllegalValueExceptions for enumeration values. However, I don't see anything unusual in the enumeration so I am not sure why resource.getErrors() is reporting them.
Any suggestion will be appreciated!
------
Value 'com.acme.ThrusterSetImpl@30ea3e3c (attitudeControl: Roll, SM: X, p_AftMR: X, p_AftRD: X, p_NadirMR: X, p_NadirRD: X, a_Aft: X)' is not legal. (platform:/resource/T/schedule.plan, 130, 115)
-------
<rsMaster>
<thrusterSet attitudeControl="Yaw" SM="X" p_AftMR="X" p_AftRD="X" p_NadirMR="X" p_NadirRD="X" a_Aft="X"/>
<thrusterSet attitudeControl="Pitch" SM="X" p_AftMR="X" p_AftRD="X" p_NadirMR="X" p_NadirRD="X" a_Aft="X"/>
<thrusterSet attitudeControl="Roll" SM="X" p_AftMR="X" p_AftRD="X" p_NadirMR="X" p_NadirRD="X" a_Aft="X"/>
</rsMaster>
|
|
|
Re: Value of Enumeration is not legal [message #1016921 is a reply to message #1016897] |
Fri, 08 March 2013 08:34 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
AJ,
Set a breakpoint where the exception is being created and look at the
context there to see what's wrong with the value. Mostly this is a case
of an attempt to set a single valued feature or to add to a multi-valued
feature throwing an exception because the value is not of the correct
type. I.e., its a fail-fast type safety error, but I can say nothing
about this from the information you've provided. These things are
exceptions and they wrap the causing exception so printing the stack
trace should pinpoint the exact cause (point of failure).
On 08/03/2013 8:06 AM, AJ Ben wrote:
> I'm getting several IllegalValueExceptions for enumeration values.
> However, I don't see anything unusual in the enumeration so I am not
> sure why resource.getErrors() is reporting them.
> Any suggestion will be appreciated!
>
> ------
> Value mailto:'com.acme.ThrusterSetImpl@30ea3e3c (attitudeControl:
> Roll, SM: X, p_AftMR: X, p_AftRD: X, p_NadirMR: X, p_NadirRD: X,
> a_Aft: X)' is not legal. (platform:/resource/T/schedule.plan, 130, 115)
> -------
>
> <rsMaster>
> <thrusterSet attitudeControl="Yaw" SM="X" p_AftMR="X"
> p_AftRD="X" p_NadirMR="X" p_NadirRD="X" a_Aft="X"/>
> <thrusterSet attitudeControl="Pitch" SM="X" p_AftMR="X"
> p_AftRD="X" p_NadirMR="X" p_NadirRD="X" a_Aft="X"/>
> <thrusterSet attitudeControl="Roll" SM="X" p_AftMR="X"
> p_AftRD="X" p_NadirMR="X" p_NadirRD="X" a_Aft="X"/>
> </rsMaster>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Value of Enumeration is not legal [message #1017018 is a reply to message #1016921] |
Fri, 08 March 2013 16:28 |
Al B Messages: 47 Registered: June 2012 |
Member |
|
|
Ed,
The stack trace seems to indicate that the root cause is a ConcurrentModificationException:
Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'com.acme.model.impl.ThrusterSetImpl@440f4d93 (attitudeControl: Yaw, SM: X, p_AftMR: X, p_AftRD: X, p_NadirMR: X, p_NadirRD: X, a_Aft: X)' is not legal. (platform:/resource/T/schedule.plan, 22, 114)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2663)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2648)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFeatureType(XMLHandler.java:2167)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2035)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHandler.java:134)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1840)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1023)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:87)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:712)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:169)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:181)
... 89 more
Caused by: java.util.ConcurrentModificationException
at org.eclipse.emf.common.util.AbstractEList$EIterator.checkModCount(AbstractEList.java:762)
at org.eclipse.emf.common.util.AbstractEList$EIterator.doNext(AbstractEList.java:710)
at org.eclipse.emf.common.util.AbstractEList$EIterator.next(AbstractEList.java:696)
at com.acme.model.impl.RSMasterImpl$1.notifyChanged(RSMasterImpl.java:65)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:255)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:300)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1179)
at com.acme.model.plan.util.PlanResourceXMLHelper.setValue(PlanResourceXMLHelper.java:69)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2658)
|
|
|
|
|
Re: Value of Enumeration is not legal [message #1017038 is a reply to message #1017034] |
Fri, 08 March 2013 17:45 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
AJ,
Again there is no question in your post. Doesn't it seem glaringly
obvious to you that this will definitely cause your exception?
for (ThrusterSet thruster : thrusters) {
if (thruster != newThruster &&
thruster.getAttitudeControl().equals(newThruster.getAttitudeControl())) {
thrusters.remove(thruster); <---
You're modifying the collection you're iterating over, that's just wrong...
}
}
Also, I'm very sure this will produce highly undesirable results. Keep
in mind that while deserializing the value of an attribute of some
object won't be populated until after the object has been added to its
container. So once one truster is in the collection with a default
value of attitude control, no other thruster can be added. Also, this
kind of logic won't prevent there being more than one thruster with the
same attitude control because you can change that attribute later and
still end up with a bad model.
You should define constraints on your model and validate those, not try
to edit such a state out of your model in the way you show above.
On 08/03/2013 6:25 PM, AJ Ben wrote:
> Ed,
>
> Sorry for missing the question, my bad.
>
> This is what happens in the RSMasterImpl.java:65
>
> /**
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated NOT
> */
> protected RSMasterImpl() {
> super();
> this.eAdapters().add(new AdapterImpl() {
> @Override
> public void notifyChanged(Notification msg) {
> if (msg.getEventType() == Notification.ADD) {
> EReferenceImpl feature = (EReferenceImpl)
> msg.getFeature();
> if (feature.getFeatureID() ==
> TRTLPackage.RS_MASTER__THRUSTER_SET) {
> EList<ThrusterSet> thrusters = getThrusterSet();
> ThrusterSet newThruster = (ThrusterSet)
> msg.getNewValue();
> for (ThrusterSet thruster : thrusters) {
> if (thruster != newThruster &&
> thruster.getAttitudeControl().equals(newThruster.getAttitudeControl())) {
> thrusters.remove(thruster);
> }
> }
> }
> }
> }
> });
> }
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03514 seconds