How to solve the error: Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract!
Mostrar comentarios más antiguos
Hello,
I started receiving an error in matlab, which prevents me to see the command window but does not prevent the code from executing. I attached all the error message below. I do not know why this is happening but I guess it started after I used "save" commands in the editor. I basically load data into the editor and then preprocess the data so that I can use them later, and I save the new data for future computations. Since when I started saving data, this problem has been initiated. Now, I can't stop matlab to produce this error every time I run any code. Can you please help me with this? I really appreciate that, thank you.
Original error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(Unknown Source)
at java.util.TimSort.mergeAt(Unknown Source)
at java.util.TimSort.mergeCollapse(Unknown Source)
at java.util.TimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at java.util.ArrayList.sort(Unknown Source)
at java.util.Collections.sort(Unknown Source)
at com.mathworks.widgets.grouptable.GroupingTableUtils.sortNonRecursively(GroupingTableUtils.java:296)
at com.mathworks.widgets.grouptable.RowListTransactionTarget.finishTransaction(RowListTransactionTarget.java:115)
at com.mathworks.widgets.grouptable.GroupingTableTransaction$1.run(GroupingTableTransaction.java:112)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
>>
Sincerely,
Irem Velibeyoglu
4 comentarios
Walter Roberson
el 29 de Mzo. de 2016
Which operating system are you using, and which MATLAB version?
Irem Velibeyoglu
el 2 de Abr. de 2016
Jaroslav Kautsky
el 7 de En. de 2019
Interestingly, I started to get same messages, many, many lines. However, I am using version '9.4.0.813654 (R2018a)' on a Linux-Mint notebook, with the -nodesktop option (command window only). I have no files with '0' in the filename in the current directory (as suggested below here). May be I should stop using java? Thank you ..
Omkar Tulankar
el 23 de Nov. de 2021
I was working on simscape multibody to define the motion of a .stp file imported into simulink.
Similar to above java related error , I am recieving following error:
Exception in thread "AWT-EventQueue-0": com.mathworks.physmod.sm.gui.core.exceptions.PmfException: Invalid camera position. The camera position and center are coincident.
at com.mathworks.physmod.sm.gui.gfx.viewer.OsgSceneViewer.fitView(Native Method)
at com.mathworks.physmod.sm.gui.gfx.viewer.OsgSceneViewer.fitView(OsgSceneViewer.java:498)
at com.mathworks.physmod.sm.gui.app.editor.MechEditorPanel.loadGfxInTiledPane_(MechEditorPanel.java:1667)
at com.mathworks.physmod.sm.gui.app.editor.MechEditorPanel.loadModelInternal_(MechEditorPanel.java:965)
at com.mathworks.physmod.sm.gui.app.editor.MechEditorPanel.loadModel(MechEditorPanel.java:880)
at com.mathworks.physmod.sm.gui.app.editor.MechEditorDTClient.openModel(MechEditorDTClient.java:956)
at com.mathworks.physmod.sm.gui.app.editor.MechEditorDTClient.processDTClientCmdLineArgs(MechEditorDTClient.java:1547)
at com.mathworks.physmod.sm.gui.app.editor.MechEditorDTClient.open(MechEditorDTClient.java:1416)
at com.mathworks.physmod.sm.gui.app.editor.MechEditorDTClient.open(MechEditorDTClient.java:1060)
at com.mathworks.physmod.sm.gui.app.editor.NativeMechEditorDTClient$1.run(NativeMechEditorDTClient.java:47)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Suprisingly my other models are working fine ,I am not able to figure out why the above error is being generated
Respuesta aceptada
Más respuestas (5)
I just started getting this error when switching to a specific folder within Matlab. I tracked it down to having added a file with a similar name to a file that already existed in the folder. The file names were "TFH114H.TST" and "TFH0114H.TST". Windows treats them as separate files, but it seems Java is somehow comparing them, treating the numeric characters in the middle as a combined number, ignoring the leading zero in the one file name, and somehow concluding they are the same file and so throwing the error? Adding an extra zero to the second name to make it "TFH00114H.TST" keeps the error, so I think my theory is correct. Renaming the files so the numeric characters do not resolve to the same number cures the problem.
4 comentarios
Walter Roberson
el 11 de Mayo de 2016
Amazing!
Janice
el 5 de Ag. de 2016
This worked for me, too! Thanks!
James Bell
el 20 de Oct. de 2016
This fixed the same problem for me, too, using R2014b. It seems this version of Matlab doesn't recognise leading zeros in filenames. Great find Jim!
Yubin Zhao
el 9 de Ag. de 2021
Thanks Jim!
Vahab Youssofzadeh
el 3 de Abr. de 2018
0 votos
restoredefaultpath is the solution
3 comentarios
Walter Roberson
el 7 de Abr. de 2018
This particular problem, with that traceback, was a Java problem, for which restoredefaultpath would not have been sufficient.
Ben Mills
el 12 de Feb. de 2020
If anything that made my issue worse.
Michael McDermott
el 1 de Mayo de 2020
Thank you! This totally worked after I ran it once... Then I could take it out and still run the code, with the Java problem gone seemingly for now.
Pablo Morcillo Pallarés
el 19 de Sept. de 2018
0 votos
I was also having the same issue, but i solved it in a different way:
i was extracting the maximum value from a table, and the output of that "max" function was giving me a "single" value that later i would use in the axis of a figure. By changing it to "double" the error does not appears again:
from this:
max_=max(Y);
To this:
max_=double(max(Y));
micholeodon
el 9 de En. de 2021
0 votos
My answer is not a universal solution but it might be a case for somebody.
I also started to have this error when I accidentally opened a nii.gz (file with the MRI data) file in the Editor. I closed MATLAB and run again - the problem persisted.
Finally problem was solved when I closed a tab in the editor with that nii.gz file.
1 comentario
Walter Roberson
el 9 de En. de 2021
Ah, that makes some sense. The editor needs java memory for open files, so if you open a large enough file you can run into java problems. Adjusting the java memory preference can postpone this kind of issue, but there will always be files large enough to trigger the problem.
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!