Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 134745 - JDBC connection does not interpret proxy exceptions correctly
JDBC connection does not interpret proxy exceptions correctly
Status: RESOLVED WONTFIX
Product: guibuilder
Classification: Unclassified
Component: Binding
6.x
PC Windows XP
: P2 with 2 votes (vote)
: TBD
Assigned To: issues@guibuilder
issues@guibuilder
:
: 149698 150057 163565 165181 166947 170437 200590 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-05-08 19:14 UTC by fatbuttlarry
Modified: 2011-08-04 12:44 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fatbuttlarry 2008-05-08 19:14:39 UTC
Scenario:
  DB server is on LAN. Workstation connects through a SQUID proxy to access the internet.  Proxy Exception list is
deployed to stations in the format of 10.* or *.company.com.

Expected Behavior:
  Database connections should bypass proxy for local addresses and connect to resources.

Observed Behavior:
  Database connections time out while connecting to proxy.

This Does Occur:
  When using the Netbeans IDE with a "Java Desktop Application (Basic Application)" (GUI) AND
    - When using Tools --> Options --> General --> Proxy Settings --> System Proxy OR
    - When using Tools --> Options --> General --> Proxy Settings --> No Proxy OR
    - When using Tools --> Options --> General --> Proxy Settings --> Manual Proxy

This Does Not Occur:
  When using the Netbeans IDE with a "Java Application" (No GUI) OR
  When using the Netbeans IDE with a "Java Desktop Application (Basic Application)" (GUI) AND
    - When host is added explicitely WITHOUT wildcard to: Control Panel --> Internet Options --> Connections --> LAN
Settings --> Advanced --> Exceptions

Additional Notes:
  The following returns true, suggesting the proxy settings may not be the culprit:
    - System.out.println(InetAddress.getByName(IP_ADDRESS).isReachable(3000));

This behavior exists with the following drivers:
  jTDS: net.sourceforge.jtds.jdbc.Driver (latest)
    - SQLException: Network error IOException: Malformed reply from SOCKS server
  AS400: com.ibm.as400.access.AS400JDBCDriver (latest)
    - SQLException: The application requester cannot establish the connection. (Malformed reply from SOCKS server)
  MYSQL: com.mysql.jdbc.Driver (latest)
    - CommunicationsException: Communications link failure

Links to other bugs/posts with this same behavior:
  http://www.netbeans.org/issues/show_bug.cgi?id=125588 (Search "oracle")
  http://www.netbeans.org/issues/show_bug.cgi?id=131164
  http://forum.java.sun.com/thread.jspa?threadID=5278678
  
This behavior has been found to occur on two workstations in our company, both running Windows XP SP2, in Netbeans
versions 6.0, 6.0.1, 6.1.

This behavior does not occur during creation of a "Java Desktop Application (Datababase Application)" but does occur
during Run.

-Tres
Comment 1 fatbuttlarry 2008-05-29 21:26:10 UTC
I would like to add a confirmation that this issue carries over to Ubuntu 8.04, however, the proxy exception work-around
does not fix it.  Disabling the proxy altogether however is a temporary work-around.

For our organization this seems to break a major component of applications developed with NetBeans 6.x.

-Tres
Comment 2 David Vancouvering 2008-05-29 22:12:27 UTC
Given that now you can't even configure the OS to work around this issue, raising to a P2. I'm not sure yet how to fix
it, but we'll give it the ol' college try as part of the bugfix phase of this release.
Comment 3 David Vancouvering 2008-05-29 22:13:01 UTC
By the way, thanks for the *excellent* description.  Top notch.
Comment 4 Andrei Badea 2008-06-17 12:43:16 UTC
Are you getting all these exceptions when connecting to a database in the Services tab in NetBeans, or are they thrown
by your Java application which you are running from NetBeans?
Comment 5 Andrei Badea 2008-06-17 12:43:40 UTC
Are you getting all these exceptions when connecting to a database in the Services tab in NetBeans, or are they thrown
by your Java application which you are running from NetBeans?
Comment 6 fatbuttlarry 2008-06-17 22:58:14 UTC
>> Are you getting all these exceptions when connecting to a database in the 
>> Services tab in NetBeans, or are they thrown by your Java application 
>> which you are running from NetBeans?

Java Application.  I'm not familiar with Services tab method.

The only GUI method I've tried is "Java Desktop Application --> Database Application" with similar results.

No GUI, no error.

>> This behavior does not occur during creation of a "Java Desktop Application
>> Datababase Application)" but does occur during Run.

Thanks,

-Tres
Comment 7 Andrei Badea 2008-06-18 12:53:29 UTC
Not an issue in the database support then. Looks the Java SE project type isn't setting the proxy when running the
application, but was it ever supposed to do that?
Comment 8 fatbuttlarry 2008-06-18 13:38:51 UTC
Java SE 5.0 is fine, and so is Java SE 6.0. 

This bug only occurs when using the GUI builder.  If I make a GUI from scratch, this bug does not occur.

-Tres
Comment 9 fatbuttlarry 2008-06-25 16:06:44 UTC
>> If I make a GUI from scratch, this bug does not occur.

Rephrased:
"If I make a GUI/Form from strictly code, this bug does not occur, it only occurs when using the NetBeans IDE to create
my GUI/Form"

-Tres
Comment 10 edugnani 2008-06-25 16:06:56 UTC
Same bug (but database is oracle in my case). That's exactly how Tres described.
Comment 11 fatbuttlarry 2008-07-09 16:10:57 UTC
Update:

Made some more ground work.

I noticed on a Mac that this bug didn't carry over.  So I checked:
Apple --> System Preferences --> Network --> Advanced --> Proxies

Since Mac has no check box to "Use this proxy for all protocols", the SOCKS proxy section is left blank.

WORKAROUND #2:
Leave SOCKS proxy connections BLANK in Network Connections and "Use this proxy for all protocols" is NOT checked.  This
works for Windows too.  Will test Ubuntu shortly.

-Tres
Comment 12 Jan Stola 2008-07-24 17:30:41 UTC
If I understand correctly then the problem occurs during execution of Java Desktop Applications applications only. I am 
not able to reproduce it. So, I have to ask you to do some experiments to help us localize the problem.

You wrote already that your testConnection() method works correctly when it is invoked from main() method directly 
(e.g. with no GUI). You also mentioned that exactly the same method fails when it is executed as a part of some Task 
that is invoked when some button is pressed. Could you, please, try the following scenarios and let us know whether the 
connection can be established or not? Thank you in advance.

1. Ordinary event handler in Java Desktop Appplication
   a) Create new Java Desktop Application based on Basic (not Database!) application shell.
   b) Add new JButton
   c) Select the JButton and invoke Events > Action > actionPerformed menu item from the contextual menu of this JButton
   d) Put invocation of your testConnection() method into the generated jButton1ActionPerformed() method.
   e) Clean, Build and Execute the project and try to press the button.
   f) Was the connection established successfully?

2. Ordinary action in Java Desktop Application
   a) Create new Java Desktop Application based on Basic (not Database!) application shell.
   b) Add new JButton
   c) Select JButton and invoke Set Action ... from the contextual menu of this JButton
   d) Select Create New Action ... from the combo-box at the top of the dialog.
   e) Specify 'myMethod' in Action's Method: text-field.
   f) Specify 'MyButton' in Text: text-field.
   g) Press OK.
   h) Put invocation of your testConnection() method into the generated myMethod() method.
   i) Clean, Build and Execute the project and try to press the button.
   j) Was the connection established successfully?

3. Background task in Java Desktop Application
   (I assume that this is one of the scenarios you already mentioned, but I want to make sure that it is covered)
   a) Create new Java Desktop Application based on Basic (not Database!) application shell.
   b) Add new JButton
   c) Select JButton and invoke Set Action ... from the contextual menu of this JButton
   d) Select Create New Action ... from the combo-box at the top of the dialog.
   e) Specify 'myAnotherMethod' in Action's Method: text-field.
   f) Specify 'MyAnotherButton' in Text: text-field.
   g) Check Background Task: check-box.
   h) Press OK.
   i) Put invocation of your testConnection() method into the doInBackground()
      method of the generated MyAnotherMethodTask.
   j) Clean, Build and Execute the project and try to press the button.
   k) Was the connection established successfully?  

4. DB connection in a project using Java Persistence, but outside Java Desktop Application
   a) Create new (ordinary) Java Application (not Java Desktop Application!)
   b) Create new Master/Detail Sample Form (in File > New File > Swing GUI Forms) in some package.
      Use some DB table from the problematic DB connection.
   c) Add new JButton (next to other buttons) into the generated form.
   d) Select the JButton and invoke Events > Action > actionPerformed menu item from the contextual menu of this JButton
   e) Put invocation of your testConnection() method into the generated jButton1ActionPerformed() method.
   f) Clean, Build and Execute the generated Master/Detail form and try to press the button.
   g) Was the connection established successfully?

You wrote that it sometimes takes several minutes before the exception (signaling unsuccessful attempt to establish the 
connection) is thrown. Could you, please, attach a thread dump taken during this wait-period. Thank you in advance.

See http://wiki.netbeans.org/GenerateThreadDump if you don't know how to generate a thread dump.
Comment 13 fatbuttlarry 2008-07-24 22:57:26 UTC
Option #1, #2, and #3, bug occurs, yes.

I have not tried option #4.  I have not obtained a "thread dump".

I will perform option #4 and I will attempt to deliver a thread dump.

I will attach the thread dump as a file if supported.

-Tres
Comment 14 fatbuttlarry 2008-07-24 23:09:44 UTC
P.S.

jstola -

Thank you for the detailed follow-up.  I'm eager to deliver requested results.

-Tres
Comment 15 Jan Stola 2008-07-28 14:10:10 UTC
Thank you very much for your additional information. It clearly shows that the problem is somewhere in Swing 
Application Framework (that is used to build Java Desktop Application).

Finally, I (hopefully) found the problematic line in Swing Application Framework. It is located in 
org.jdesktop.application.Application.create() method. This method sets "java.net.useSystemProxies" system property 
to "true". This property is used by default ProxySelector to determine correct proxies.

The workaround is to invoke ProxySelector.getDefault() in main() method - this will force initialization of the 
ProxySelector before the problematic change in the system property is made. Another workaround is to set the mentioned 
property back to "false" in startup() method of your application e.g. invoke System.setProperty
("java.net.useSystemProxies", "false");

Please, let me know whether this workaround works for you. I would like to make sure that we identified the root of 
this issue correctly before I will move this issue into bug-tracking system of Swing Application Framework. Thank you 
in advance.
Comment 16 Tomas Pavek 2008-07-28 14:28:28 UTC
More people complained about this on appframework users list. There's also 
https://appframework.dev.java.net/issues/show_bug.cgi?id=69
Comment 17 edugnani 2008-07-29 14:55:14 UTC
Hi jstola,

  I had same bug as Tres described. Both workarounds you suggested worked fine. :-)
  Thanks a lot.
  Regards,

Evandro
Comment 18 Jan Stola 2008-07-29 15:40:01 UTC
Thank you for testing the workarounds. I will close this issue as "will not fix" because it is caused by suspicious 
feature of Swing Application Framework and it doesn't seem to be correct to switch this feature off (e.g. use one of 
the mentioned workarounds) automatically because it could break other use-cases.
Comment 19 edugnani 2008-07-29 15:44:36 UTC
Hi jstola,

  Will be it open another issue concerning this subject in Swing Application Framework area?

  Regards,

Evandro
Comment 20 Jan Stola 2008-07-29 16:01:35 UTC
> Will be it open another issue concerning this subject in Swing Application Framework area?

There already is an issue about this problem, but it is not very verbose:
https://appframework.dev.java.net/issues/show_bug.cgi?id=69
Feel free to add your comments/suggestions there or just monitor it by putting yourself on CC of that issue.
Comment 21 edugnani 2008-07-29 16:14:37 UTC
  Thanks jstola.
  Best regards.
Comment 22 fatbuttlarry 2008-07-29 21:27:17 UTC
This news made my week.  Thanks all that were involved.  This will certainly increase my productivity with the Netbeans IDE!

-Tres
Comment 23 Jan Stola 2008-10-24 10:10:46 UTC
*** Issue 150057 has been marked as a duplicate of this issue. ***
Comment 24 Jan Stola 2008-11-10 17:14:16 UTC
*** Issue 149698 has been marked as a duplicate of this issue. ***
Comment 25 soynegativo 2009-04-24 12:21:51 UTC
*** Issue 163565 has been marked as a duplicate of this issue. ***
Comment 26 Tomas Pavek 2009-06-16 16:11:04 UTC
*** Issue 166947 has been marked as a duplicate of this issue. ***
Comment 27 Tomas Pavek 2009-07-15 18:27:43 UTC
*** Issue 165181 has been marked as a duplicate of this issue. ***
Comment 28 neil_hawkes 2009-09-17 00:52:02 UTC
*** Issue 170437 has been marked as a duplicate of this issue. ***
Comment 29 Jan Stola 2011-08-04 12:44:15 UTC
*** Bug 200590 has been marked as a duplicate of this bug. ***


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo