The reason I ask is, I have a web application written in Ruby (1.8.7-p357) with the Sinatra Framework (1.3.2). The interpreter is JRuby (1.6.7.2). I am connecting to an AS/400 (System i v6r1) and when I supply the app with an incorrect password for connecting to the database in the code I am prompted with a Java dialog box to supply the proper password.
This works swimmingly on my development machine (Ubuntu 11.10) using WEBrick. However when I deploy the application with the incorrect password the application hangs. Rummaging through the log files shows that the system is waiting for a response from the user with a call to the function: java.awt.Dialog.show().
Here is the relevant portion of the trace:
http-8080-2" daemon prio=6 tid=0x03d81400 nid=0x10c in Object.wait() [0x06278000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x24a022a8> (a java.awt.Component$AWTTreeLock)
at java.lang.Object.wait(Object.java:503)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
- locked <0x24a022a8> (a java.awt.Component$AWTTreeLock)
at java.awt.Dialog.show(Unknown Source)
at com.ibm.as400.access.PasswordDialog.prompt(PasswordDialog.java:284)
at com.ibm.as400.access.ToolboxSignonHandler.handleSignon(ToolboxSignonHandler.java:499)
at com.ibm.as400.access.ToolboxSignonHandler.connectionInitiated(ToolboxSignonHandler.java:50)
at com.ibm.as400.access.AS400.promptSignon(AS400.java:2153)
at com.ibm.as400.access.AS400.signon(AS400.java:3417)
- locked <0x23121378> (a com.ibm.as400.access.AS400)
at com.ibm.as400.access.AS400.connectService(AS400.java:869)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:3016)
at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1242)
at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1105)
at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:355)
Is it possible for a web application to launch a Java dialog on a client machine in this manner? If so, why is it failing in my deployment environment?
You need to set the IBM Toolbox for Java JDBC property
prompttofalseand catch the exception when the connection fails.Also it’s a good practice to set the Java system property
java.awt.headless=truewhen running a server application.See Using Headless Mode in the Java SE Platform
.