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.
Hi! I just wrote my first NB plugin. It open file in eternal editor (Emacs). But when I try get cursor position by EditorCookie ec = nodes[0].getCookie(EditorCookie.class); if (ec == null) return; JEditorPane[] panes = ec.getOpenedPanes(); if (panes.length <= 0) return; int cursor = panes[0].getCaretPosition(); as this suggest http://wiki.netbeans.org/DevFaqFindCaretPositionInEditor I get error in message.log (OpenInEmacs.java:49 point to "int cursor = panes[0].getCaretPosition();" line): INFO [org.netbeans.core.startup.NbEvents]: Turning on modules: org.emacs.nbemacs [1.0 130123] SEVERE [global] java.lang.ClassNotFoundException: javax.swing.JEditorPane at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) Caused: java.lang.NoClassDefFoundError: javax/swing/JEditorPane at org.emacs.nbemacs.OpenInEmacs.actionPerformed(OpenInEmacs.java:49) at org.openide.awt.AlwaysEnabledAction$1.run(AlwaysEnabledAction.java:198) at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:95) at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116) at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99)
I forget add full trace: java.lang.ClassNotFoundException: javax.swing.JEditorPane at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) Caused: java.lang.NoClassDefFoundError: javax/swing/JEditorPane at org.emacs.nbemacs.OpenInEmacs.actionPerformed(OpenInEmacs.java:49) at org.openide.awt.AlwaysEnabledAction$1.run(AlwaysEnabledAction.java:198) at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:95) at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116) at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99) at org.openide.awt.AlwaysEnabledAction.actionPerformed(AlwaysEnabledAction.java:201) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289) at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3312) at java.awt.Component.processEvent(Component.java:6270) 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.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) 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:158) [catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139) at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Who writes org.emacs.nbemacs.OpenInEmacs?
Created attachment 130551 [details] Ready to build NB project of very simple NS plugin which fail...
I add my project. I reproduce fail (100% repeat rate) at home. See attachment with project. To reproduce: build/deploy select real file in editor and press on Emacs icon (or use hot key "Alt+E"). You get trace same as I post before...
If comment lines below: EditorCookie ec = nodes[0].getCookie(EditorCookie.class); except I have functional plug-in (it open file from selected tab in Emacs): Utils.open(current.getAbsolutePath(), -1); But I want to open file in same position that in NB so need of: EditorCookie ec = nodes[0].getCookie(EditorCookie.class); JEditorPane[] panes = ec.getOpenedPanes(); int cursor = panes[0].getCaretPosition(); which fail with "java.lang.NoClassDefFoundError: javax/swing/JEditorPane"
After 3 years of living with that error I figure out what happen. In order to develop own simple NetBeans plugin I have created NB project via IDE UI and added my .java file. When I run project I always get errors about java.lang.NoClassDefFoundError for different classes from javax.swing.*.* depending what part of code I use in .java file). I ever ran VisualVM and made heapdump where I saw javax.swing.* loaded. After a lot of digging around I found answer http://stackoverflow.com/questions/27020609/netbeans-exception-class-not-found-for-javax-swing-joptionpane which give me hint that problem in class loading. Next searches put me to https://blogs.oracle.com/gridbag/entry/classloading_netbeans_modules_read_this and next to http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/classpath.html That info too broad to me. I search for some keywords in Netbeans mercurial source tree and look for manifest.mf files. So I replace project manifest.mf with basic staff like: Manifest-Version: 1.0 OpenIDE-Module: org.emacs.nbemacs OpenIDE-Module-Name: Open file in Emacs OpenIDE-Module-Short-Description: Open file in Emacs OpenIDE-Module-Specification-Version: 1.0 and try add any dependencies until I get no error: OpenIDE-Module-Module-Dependencies: org.openide.windows, org.openide.nodes, org.openide.loaders, org.openide.filesystems, org.netbeans.modules.editor.lib2/1 Auto generated 'manifest.mf' have lines with Bundle* keywords. Now Netbeans create project with OpenIDE-Module-* keywords. What is wrong is that IDE doesn't help with direct answer why I constantly get java.lang.NoClassDefFoundError Netbeans main and contrib sources also have very few uses of OpenIDE-Module-Module-Dependencies in OpenIDE-Module-Module-Dependencies That man say truth about complications: https://blogs.oracle.com/gridbag/entry/classloading_netbeans_modules_read_this Now issue may be closed.