2013-05-11 31 views
3

我有一個編輯器TopComponent實現。出於某種原因,當我保存文檔時,會引發錯誤。下面列出的是錯誤。我不確定從這個例外開始。你能分享你所知道的嗎?感謝Netbeans保存掛起

java.lang.IllegalArgumentException: Self-causation not permitted 
    at java.lang.Throwable.initCause(Throwable.java:458) 
    at org.netbeans.modules.masterfs.filebasedfs.fileobjects.MutualExclusionSupport.addStack(MutualExclusionSupport.java:122) 
    at org.netbeans.modules.masterfs.filebasedfs.fileobjects.MutualExclusionSupport.addStack(MutualExclusionSupport.java:109) 
    at org.netbeans.modules.masterfs.filebasedfs.fileobjects.MutualExclusionSupport.addResource(MutualExclusionSupport.java:98) 
    at org.netbeans.modules.masterfs.filebasedfs.fileobjects.FileObj.getOutputStream(FileObj.java:127) 
    at org.netbeans.modules.masterfs.filebasedfs.fileobjects.FileObj.getOutputStream(FileObj.java:102) 
    at org.openide.text.DataEditorSupport$Env.outputStream(DataEditorSupport.java:891) 
    at org.openide.text.CloneableEditorSupport.saveDocument(CloneableEditorSupport.java:1172) 
    at org.openide.text.DataEditorSupport.superSaveDoc(DataEditorSupport.java:602) 
    at org.openide.text.DataEditorSupport$SaveImpl.run(DataEditorSupport.java:1315) 
    at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:127) 
    at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:609) 
    at org.openide.filesystems.FileUtil.runAtomicAction(FileUtil.java:415) 
    at org.openide.text.DataEditorSupport.saveDocument(DataEditorSupport.java:598) 
    at org.netbeans.modules.openide.loaders.SimpleES$SaveCookieImpl.save(SimpleES.java:226) 
    at org.openide.actions.SaveAction.performAction(SaveAction.java:132) 
    at org.openide.actions.SaveAction.performAction(SaveAction.java:102) 
    at org.openide.actions.SaveAction$Delegate.actionPerformed(SaveAction.java:249) 
    at org.openide.awt.ContextAction$Performer.actionPerformed(ContextAction.java:231) 
    at org.openide.awt.ContextManager.actionPerformed(ContextManager.java:257) 
    at org.openide.awt.ContextAction.actionPerformed(ContextAction.java:109) 
    at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:93) 
    at org.openide.util.actions.ActionInvoker$ActionRunnable.actionPerformed(ActionInvoker.java:162) 
    at org.netbeans.core.ModuleActions.invokeAction(ModuleActions.java:109) 
    at org.netbeans.modules.openide.actions.ActionsBridgeImpl.invokeAction(ActionsBridgeImpl.java:60) 
    at org.openide.util.actions.ActionInvoker$ActionRunnable.doRun(ActionInvoker.java:153) 
    at org.openide.util.actions.ActionInvoker$2.run(ActionInvoker.java:110) 
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432) 
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2044) 
Caused: org.openide.util.RequestProcessor$SlowItem: task failed due to 
    at org.openide.util.RequestProcessor.post(RequestProcessor.java:424) 
    at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:114) 
    at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99) 
    at org.openide.awt.GeneralAction$BaseDelAction.actionPerformed(GeneralAction.java:234) 
    at org.openide.windows.TopComponent.processKeyBinding(TopComponent.java:1176) 
    at javax.swing.JComponent.processKeyBindings(JComponent.java:2940) 
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2842) 
    at java.awt.Component.processEvent(Component.java:6282) 
    at java.awt.Container.processEvent(Container.java:2229) 
    at java.awt.Component.dispatchEventImpl(Component.java:4861) 
    at java.awt.Container.dispatchEventImpl(Container.java:2287) 
    at java.awt.Component.dispatchEvent(Component.java:4687) 
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895) 
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762) 
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027) 
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899) 
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727) 
    at java.awt.Component.dispatchEventImpl(Component.java:4731) 
    at java.awt.Container.dispatchEventImpl(Container.java:2287) 
    at java.awt.Window.dispatchEventImpl(Window.java:2719) 
    at java.awt.Component.dispatchEvent(Component.java:4687) 
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723) 
    at java.awt.EventQueue.access$200(EventQueue.java:103) 
    at java.awt.EventQueue$3.run(EventQueue.java:682) 
    at java.awt.EventQueue$3.run(EventQueue.java:680) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) 
    at java.awt.EventQueue$4.run(EventQueue.java:696) 
    at java.awt.EventQueue$4.run(EventQueue.java:694) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:693) 
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) 
[catch] at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) 

EDIT 1

我有DataObject中且具有構造成一個新的MIME類型text/x-puml一個VisualElement子類。一旦我將這些改回text/plain,事情就開始奏效。我搜索了text/plain,看看我是否錯過了更改text/x-puml的任何內容,但找不到任何內容。有沒有其他的事情我應該改變MIME類型爲text/x-puml

EDIT 2

似乎現在零星發生,但往往不是發生。如果我有自定義MIME類型,是否需要實現自己的SaveCookie或Savable?

+0

stacktrace中的哪一行包含您編寫或編輯的類? – 2013-05-11 21:55:47

+0

這是有趣的部分,沒有一行提到我的代碼。但是我剛纔確實發現了什麼導致了這個問題。我有一個新的MIME類型的註冊'text/x-puml',一旦我將它改爲'text/plain',問題就消失了。你會碰巧知道我是否缺少任何配置。 – ShaggyInjun 2013-05-11 22:04:36

+0

我還沒有在NetBeans中使用自定義MIME類型,所以我無法在那裏幫你。 – 2013-05-13 00:06:39

回答

1

它看起來像一個信號燈問題。

系統無法保存文件,因爲該文件上存在排他鎖。另一個獨佔鎖(根據保存需要)是不可能的。

試着看文件處理。某處必須是鎖。

0

我有一個類似的錯誤,由於重命名,這是因爲該文件的鎖。所以我用了file's鎖定與primaryFile.lock()在:

WindowManager.getDefault().invokeWhenUIReady(new Runnable() 
{ 
    @Override 
    public void run() 
    { 
     if (obj.getDomainModel() != null) 
     { 
      String newName = obj.getDomainModel().getName(); 
      FileObject primaryFile = obj.getPrimaryFile(); 
      try 
      { 
       primaryFile.rename(primaryFile.lock(), newName, primaryFile.getExt()); 
       callback.updateTitle(newName); 
      } 
      catch (IOException ex) 
      { 
       String message = String.format("The model couldn´t be renamed to \"%s\"", newName); 

       LOG.warning(message); 
      } 
     } 
    } 
}); 

用它來保存文件或相似任何情況下。

+1

我的例子我有同樣的問題,但重命名,而不是保存。但同樣的問題:先前打開的文件的鎖定。 – EliuX 2015-08-27 22:40:19

+0

對不起 - 我誤解了你的回答。刪除downvote,謝謝澄清 – user2290362 2015-08-29 17:30:30

+0

感謝您糾正。 – EliuX 2015-08-31 17:15:15