This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 139680

Summary: I cannot copy files from the Projects and Files window to a place out of Netbeans
Product: platform Reporter: mojtaba3000 <mojtaba3000>
Component: -- Other --Assignee: Stanislav Aubrecht <saubrecht>
Status: RESOLVED WONTFIX    
Severity: blocker CC: anebuzelsky, bht, brutzman, jtulach, matthies
Priority: P2    
Version: 6.x   
Hardware: PC   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: plain java application with custom SecurityManager and broken copy/paste

Description mojtaba3000 2008-07-11 09:14:19 UTC
I copied a file from Projects or Files window of Netbeans (RightClick->copy) , when I tried to paste it to a folder in
one of my computer drives I got this error :

Cannot copy file: the file name you specified is not valid or too long.
Specify a different file name.

the problem is also exists in Netbeans 6.5, but in 6.0 does not exist.
Comment 1 Milan Kubec 2008-07-14 13:14:55 UTC
Stando, please take a look at this issue. Thanks.
Comment 2 Stanislav Aubrecht 2008-07-15 12:45:40 UTC
for some reason the List that should hold the name of the copied/dragged file is empty when dropped into an external
application.
i have no idea why though...
Comment 3 Stanislav Aubrecht 2008-11-11 14:39:16 UTC
*** Issue 125952 has been marked as a duplicate of this issue. ***
Comment 4 Jiri Skrivanek 2009-02-16 09:25:15 UTC
*** Issue 155807 has been marked as a duplicate of this issue. ***
Comment 5 Jiri Skrivanek 2009-02-16 09:33:01 UTC
While investigating 155807 I found out minimal test case which doesn't work. If ExTransferable is returned from
org.openide.loaders.DataNode.clipboardCopy(), it fails when you drag&drop a file from IDE to external application on
Windows.

    public Transferable clipboardCopy () throws IOException {
        Transferable t = null;
        FileObject fo = getDataObject().getPrimaryFile();
        final File file = FileUtil.toFile(fo);
        if (null != file) {
            // this doesn't work
            t = ExTransferable.create(new ExTransferable.Single(DataFlavor.javaFileListFlavor) {
                public Object getData() {
                    return Collections.singletonList(file);
                }
            });
            // this works
            //t = new ExTransferable.Single(DataFlavor.javaFileListFlavor) {
            //    public Object getData() {
            //        return Collections.singletonList(file);
            //    }
            //};
        }
        return t;
    }
Comment 6 Jiri Skrivanek 2009-03-18 10:08:25 UTC
*** Issue 159589 has been marked as a duplicate of this issue. ***
Comment 7 elishae 2009-03-25 08:24:59 UTC
We are expecting this to be fixed in 6.7... would this be done in 6.7.
Comment 8 Stanislav Aubrecht 2009-03-25 10:13:54 UTC
i found out that after disabling netbeans TopSecurityManager drag and drop of files to other applications works as expected.
cc'ing jarda and jesse who made changes in that class in the past.
please note that this is broken in nb 6.5 but it used to work before.
Comment 9 Stanislav Aubrecht 2009-03-25 12:06:41 UTC
as far as i can tell there's no SecurityException being thrown during drag'n'drop so it's complete mystery to me...
Comment 10 Jesse Glick 2009-03-25 15:03:01 UTC
I don't see any interesting changes to this class since 6.5:

diff -r f4e13fba708a -r 68c2cae99705 o.n.bootstrap/src/org/netbeans/TopSecurityManager.java
--- a/o.n.bootstrap/src/org/netbeans/TopSecurityManager.java	Mon Oct 13 20:24:51 2008 -0700
+++ b/o.n.bootstrap/src/org/netbeans/TopSecurityManager.java	Tue Mar 24 17:58:36 2009 -0400
@@ -274,6 +274,7 @@
         warnedClassesNH.add ("org.netbeans.updater.UpdateTracking"); // NOI18N
         warnedClassesNH.add("org.netbeans.core.ui.ProductInformationPanel"); // #47429; NOI18N
         warnedClassesNH.add("org.netbeans.lib.uihandler.LogFormatter");
+        warnedClassesNH.add("org.netbeans.modules.j2ee.sun.ide.j2ee.PluginProperties"); // AS bundle is not in any cluster
     }
 
     /* ----------------- private methods ------------- */
@@ -551,7 +552,10 @@
     public static void makeSwingUseSpecialClipboard (java.awt.datatransfer.Clipboard clip) {
         try {
             synchronized (TopSecurityManager.class) {
-                assert System.getSecurityManager() instanceof TopSecurityManager : "Our manager has to be active: " +
System.getSecurityManager(); // NOI18N
+                if (! (System.getSecurityManager() instanceof TopSecurityManager)) {
+                    LOG.warning("Our manager has to be active: " + System.getSecurityManager());
+                    return;
+                } // NOI18N
                 if (CLIPBOARD_FORBIDDEN != null) {
                     return;
                 }
Comment 11 Stanislav Aubrecht 2009-04-09 21:47:03 UTC
i've spent a couple of days trying to find a fix for this bug but with no results. the only known workaround is
disabling netbeans TopSecurityManager in bootstrap module
Comment 12 Jesse Glick 2009-05-01 17:41:06 UTC
*** Issue 161826 has been marked as a duplicate of this issue. ***
Comment 13 Stanislav Aubrecht 2009-09-17 16:22:26 UTC
Created attachment 87869 [details]
plain java application with custom SecurityManager and broken copy/paste
Comment 14 Stanislav Aubrecht 2009-09-17 16:26:36 UTC
copy/paste of a file to other application isn't working in a plain java application when custom SecurityManager is set
which allows all permissions, see the attached sample app. 
not sure whether this is a jdk bug or whether some permission types need special handling in the SecurityManager
Comment 15 t_h 2009-10-05 10:56:57 UTC
*** Issue 173213 has been marked as a duplicate of this issue. ***
Comment 16 ejvyas 2009-10-05 13:22:16 UTC
Please escalate this issue. It has been open for more than a year. This is very important for copying files eg. war file
for which Netbeans does not provide a path that can be modified. User has to go through the complete file system to get
to the file.
Comment 17 Stanislav Aubrecht 2009-10-05 16:32:15 UTC
it's a bug in jdk tracked under id 6888182
Comment 18 ejvyas 2009-10-05 18:10:06 UTC
Please confirm the link to the bug. I search thru the DB but could not find any bug # 6888182. 

Also, can we not fix this issue in Netbeans itself?
Comment 19 Stanislav Aubrecht 2009-10-06 08:12:58 UTC
it's a security issue so it's not available to the public
i've asked jdk team for a workaround but didn't get any:(
Comment 20 ejvyas 2009-10-06 13:35:17 UTC
Oh you mean the Netbeans JDK team. I was thrown off into believing that it is a Sun Java bug!

Anyways, if this cannot be resolved it seems this totally undermines the Files View Window. Most of my developers use it
for copying packaged files like war out of a project.
Comment 21 Stanislav Aubrecht 2009-10-06 14:08:36 UTC
no, it is a sun jdk bug
Comment 22 Antonin Nebuzelsky 2009-10-06 14:55:39 UTC
> this totally undermines the Files View Window
> Most of my developers use it for copying packaged files like war out of a project

You can do such copying in Favorites view or between Files view (the project folder content) and Favorites view (any
other folder on disk)...
Comment 23 ejvyas 2009-10-06 15:32:20 UTC
Again - you don't allow network shares to be added to Favorites !! Anyways thanks for the explanation!
Comment 24 Stanislav Aubrecht 2009-11-10 06:49:06 UTC
*** Bug 176303 has been marked as a duplicate of this bug. ***
Comment 25 rmichalsky 2009-11-12 07:37:55 UTC
*** Bug 128670 has been marked as a duplicate of this bug. ***
Comment 26 Stanislav Aubrecht 2010-08-23 11:17:42 UTC
*** Bug 188109 has been marked as a duplicate of this bug. ***
Comment 27 bht 2010-08-23 19:25:27 UTC
Works in Eclipse
Comment 28 mojtaba3000 2010-09-01 05:34:16 UTC
the bug still exists in 6.9.1
Is there any possibility to solve the problem?
It's 2 years from the time of bug report!
Comment 29 mojtaba3000 2010-09-01 05:39:28 UTC
excuse me
I forget that the bug is from JDK.
where is the link to the bug number 6888182 ?
Comment 30 Stanislav Aubrecht 2010-09-01 15:01:35 UTC
i was told it was a security issue in jdk so the bug report is not visible to the public
Comment 31 bht 2010-09-01 19:47:39 UTC
It would help to copy the file location to the clipboard so it can be used to locate the file. I have seen this in KDE under Linux.
Comment 32 bht 2011-03-13 00:41:59 UTC
Why is it acceptable that such a bug won't fix while the Eclipse IDE has no problem with this?
Comment 33 Stanislav Aubrecht 2011-03-14 09:38:04 UTC
i happily integrate any working patch