Directory Studio
  1. Directory Studio
  2. DIRSTUDIO-301

Intermittant ClassCastException from dom4j.DocumentFactory.getInstance()

    Details

      Description

      We've integrated Directory Studio 1.1 0 into our Eclipse application and we occasionally see the following stack trace when we select the Finish button while defining a new connection via the New LDAP Connection wizard. The stack trace display each time the Finish button is displayed and the wizard never completes. You always have to cancel the wizard. Most of the time the wizard works fine but occasionally it has this problem.

      We see a similar stack trace with ClassCastException from DocumentFactory.getInstance() when we launch our application and we have previously defined LDAP connections. It appears as though Directory Studio is trying to read the persisted connection definitions but cannot due to the exception. The appearance is that your previously defined connections do not appear in the Connections view but if you try to define a connection with a previously defined (but now invisible) connection name you will get a message about a duplicate name. This problem is also intermittant and sometimes it seems to depend on what perspective is loaded during the launch.

      After researching this problem I found the following link that seems to be related to just this issue with dom4j-1.6.1.jar which Directory Studio bundles in org.apache.directory.studio.jars_1.1.0.v20080303.jar.

      http://www.mail-archive.com/dom4j-dev@lists.sourceforge.net/msg01282.html
      [dom4j-dev] [ dom4j-Bugs-1618750 ] ClassCastException while creating org.dom4j.DocumentFactory

      It's not clear what the fix should be after reading this thread. We use dom4j-1.5.2.jar in our application have never seen an issue like this. I was tempted to replace the dom4j-1.6.1.jar with dom4j-1.5.2.jar in org.apache.directory.studio.jars_1.1.0.v20080303.jar to see if it would fix the problem but I wasn't sure what other impacts, if any, that might cause.

      These issues, especially the invisible connections, are a real annoyance for our users so I'm marking this issue as critical. We would really like to see this addressed before Directory Studio reaches GA.

      !STACK 0
      java.lang.ClassCastException: org.dom4j.DocumentFactory
      at org.dom4j.DocumentFactory.getInstance(DocumentFactory.java:97)
      at org.dom4j.DocumentHelper.getDocumentFactory(DocumentHelper.java:36)
      at org.dom4j.DocumentHelper.createDocument(DocumentHelper.java:41)
      at org.apache.directory.studio.connection.core.io.ConnectionIO.saveConnectionFolders(ConnectionIO.java:444)
      at org.apache.directory.studio.connection.core.ConnectionFolderManager.saveConnectionFolders(ConnectionFolderManager.java:339)
      at org.apache.directory.studio.connection.core.ConnectionFolderManager.connectionAdded(ConnectionFolderManager.java:284)
      at org.apache.directory.studio.connection.core.event.ConnectionEventRegistry$4.run(ConnectionEventRegistry.java:250)
      at org.apache.directory.studio.connection.core.event.CoreEventRunner.execute(CoreEventRunner.java:41)
      at org.apache.directory.studio.connection.core.event.ConnectionEventRegistry.fireConnectionAdded(ConnectionEventRegistry.java:257)
      at org.apache.directory.studio.connection.core.ConnectionManager.addConnection(ConnectionManager.java:119)
      at org.apache.directory.studio.connection.ui.wizards.NewConnectionWizard.performFinish(NewConnectionWizard.java:165)
      at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:742)
      at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:373)
      at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:616)
      at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
      at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
      at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
      at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
      at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
      at org.eclipse.jface.window.Window.open(Window.java:796)
      at org.apache.directory.studio.connection.ui.actions.NewConnectionAction.run(NewConnectionAction.java:68)
      at org.apache.directory.studio.connection.ui.actions.StudioActionProxy.run(StudioActionProxy.java:238)
      at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
      at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:545)
      at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
      at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:443)
      at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
      at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
      at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
      at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
      at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
      at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
      at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
      at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
      at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
      at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
      at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
      at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:504)
      at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443)
      at org.eclipse.equinox.launcher.Main.run(Main.java:1169)
      at org.eclipse.equinox.launcher.Main.main(Main.java:1144)

        Activity

        John Buslawski created issue -
        Hide
        Pierre-Arnaud Marcelot added a comment -

        This really looks like a ClassLoader issue.

        The Eclipse documentation indicates that each plugin has its own ClassLoader but it seems like Apache Directory Studio plugins and your Application plugins share the same ClassLoader (which could explain the ClassCastException).

        You can try to edit the Studio jars plugin to use the same dom4j dependency you use, but I'm really not sure it will work. The API must changed between 1.5.2 and 1.6.1 versions.

        Show
        Pierre-Arnaud Marcelot added a comment - This really looks like a ClassLoader issue. The Eclipse documentation indicates that each plugin has its own ClassLoader but it seems like Apache Directory Studio plugins and your Application plugins share the same ClassLoader (which could explain the ClassCastException). You can try to edit the Studio jars plugin to use the same dom4j dependency you use, but I'm really not sure it will work. The API must changed between 1.5.2 and 1.6.1 versions.
        Hide
        Stefan Seelmann added a comment -

        Postponed to 1.1.1

        Show
        Stefan Seelmann added a comment - Postponed to 1.1.1
        Stefan Seelmann made changes -
        Field Original Value New Value
        Fix Version/s 1.1.0 [ 12312701 ]
        Fix Version/s 1.1.1 [ 12313071 ]
        Pierre-Arnaud Marcelot made changes -
        Fix Version/s 1.2.0 [ 12312851 ]
        Fix Version/s 1.1.1 [ 12313071 ]
        Assignee Pierre-Arnaud Marcelot [ pamarcelot ]
        Hide
        Pierre-Arnaud Marcelot added a comment -

        Postponed.

        Show
        Pierre-Arnaud Marcelot added a comment - Postponed.
        Pierre-Arnaud Marcelot made changes -
        Fix Version/s 1.3.0 [ 12313309 ]
        Fix Version/s 1.2.0 [ 12312851 ]
        Pierre-Arnaud Marcelot made changes -
        Fix Version/s 1.3.0 [ 12313309 ]
        Hide
        Stefan Seelmann added a comment -

        John, do you still have issues with that?

        One cause I could imagine is that the jars plugin exports all packages (via Export-Package in MANIFEST.MF) of all included libraries, including org.dom4j.*. So all those packages are available for all other plugins and if they just import an package (via Import-Package in MANIFEST.MF) may be the problem.

        I think we should consider another way on how to bundle shared libraries. Maybe a better approach would be to create an OSGi bundle for each required jar. I think most Apache Commons jars include a valid Manifest these days. I'd appreciate feedback from Eclipse and OSGi experts.

        Show
        Stefan Seelmann added a comment - John, do you still have issues with that? One cause I could imagine is that the jars plugin exports all packages (via Export-Package in MANIFEST.MF) of all included libraries, including org.dom4j.*. So all those packages are available for all other plugins and if they just import an package (via Import-Package in MANIFEST.MF) may be the problem. I think we should consider another way on how to bundle shared libraries. Maybe a better approach would be to create an OSGi bundle for each required jar. I think most Apache Commons jars include a valid Manifest these days. I'd appreciate feedback from Eclipse and OSGi experts.
        Hide
        Pierre-Arnaud Marcelot added a comment -

        FYI, I created and resolved issue DIRSTUDIO-688 (Remove the 'jars' plugins and create one specific plugin per external library dependency).

        It should fix the issue.

        Any confirmation from your side, John, is very welcomed.

        Show
        Pierre-Arnaud Marcelot added a comment - FYI, I created and resolved issue DIRSTUDIO-688 (Remove the 'jars' plugins and create one specific plugin per external library dependency). It should fix the issue. Any confirmation from your side, John, is very welcomed.
        Pierre-Arnaud Marcelot made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.0 [ 12314306 ]
        Pierre-Arnaud Marcelot made changes -
        Fix Version/s 2.0.0-M1 [ 12319458 ]
        Hide
        Pierre-Arnaud Marcelot added a comment -

        Version 2.0.0 M1 has been released.

        Closing the issue.

        Show
        Pierre-Arnaud Marcelot added a comment - Version 2.0.0 M1 has been released. Closing the issue.
        Pierre-Arnaud Marcelot made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Pierre-Arnaud Marcelot
            Reporter:
            John Buslawski
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development