I have succesfully completed an Java gateway to a DLL so that the functions within the DLL can be invoked. Everything works fine when running the application from the command line. However, now I have developed a Swing GUI to enhance the usability, but when invoking the DLL from the GUI as a result of a butten click event, I get an exception starting with "Exception in thread "AWT-EventQueue-0" (...)". I guess it has something to do with a multithreading issue? Does anyone know how to solve this?
Currently, I can't get to the application, so I can't post the exception stack trace, yet, but I'm absolutely sure it is not caused by the library not being found. In fact, the exception output contains a messsage that is given by the DLL itself, saying that it fails at some stage during initialization. So, the loading of the DLL is succesfully established, but it fails to initialize (more specifically: it fails loading the book keeping administration that will be manipulated by our Java application). And this error only comes up, when the class that takes care of the DLL communication is instantiated and instructed to set up the connection from the GUI (after clicking a button). It does, however, run completely succesful, when the DLL communicating class is instantiated and instructed to set up the connection directly in the public static void main(String args) method:
[ February 28, 2007: Message edited by: Jeroen Oosterlaar ]
Joined: Feb 11, 2007
Ok, I have the output of the exception that is thrown, when the DLL is invoked from my Swing GUI:
Exception in thread "AWT-EventQueue-0" com.ibm.bridge2java.ComException: Er is een fout opgetreden tijdens het openen van de administratie.
Fase 9: controle demo. Object variable or With block variable not set at com.ibm.bridge2java.Dispatch.IDispatch_Invoke(Native Method) at com.ibm.bridge2java.Dispatch.invoke_method_void(Dispatch.java:132) at nl.viab.snelstart.dll._clsGWaySnelStart.mtdGWayAdmiOpenen(_clsGWaySnelStart.java:73) at nl.viab.snelstart.Executor.<init>(Executor.java:21) at nl.viab.snelstart.GUI.jButton1ActionPerformed(GUI.java:170) at nl.viab.snelstart.GUI.access$000(GUI.java:15) at nl.viab.snelstart.GUI$1.actionPerformed(GUI.java:106) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6038) at javax.swing.JComponent.processMouseEvent(JComponent.java:3260) at java.awt.Component.processEvent(Component.java:5803) at java.awt.Container.processEvent(Container.java:2058) at java.awt.Component.dispatchEventImpl(Component.java:4410) at java.awt.Container.dispatchEventImpl(Container.java:2116) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916) at java.awt.Container.dispatchEventImpl(Container.java:2102) at java.awt.Window.dispatchEventImpl(Window.java:2429) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Some relevant code regarding invoking the DLL from the GUI:
However, when new Executor() is called from the command line...