Announcement Announcement Module
Collapse
No announcement yet.
LocalDataSourceConnectionProvider hangs if I use a proxy server to connect. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LocalDataSourceConnectionProvider hangs if I use a proxy server to connect.

    Hi,

    I tried to search but have not found anything of value.
    I connect to the Internet through a proxy server.
    My application stops at the start of the line ... Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSource ConnectionProvider
    There is no exception, nothing.

    If excluding the proxy everything works properly.

    Has anyone already solved a similar problem?

    I use Spring2.5.6 + Hibernate3.5.5.

    Best reg,
    Karol.

  • #2
    I try:
    -Dhttp.proxyHost=webcache.mydomain.com -Dhttp.proxyPort=8080
    Or
    System.setProperty("http.proxyHost", "webcache.mydomain.com");
    System.setPropery("http.proxyPort", "8080");
    Or
    System.setProperty("java.net.useSystemProxies", "true");

    but it's still hangs up

    Comment


    • #3
      As I understand, you want to connect a non local db? (strange idea...)

      As you cannot acces DB through http (except some nosql DB...), setting a http proxy will not help you.
      The easiest way is to create a VPN tunel between your servers

      Comment


      • #4
        Initially you should check your proxy, then there must problem between ODBC or JDBC.
        I recommend you to first check the ODBC.

        Comment


        • #5
          19 maj 2011 09:03:57,458 INFO [JCLLoggerAdapter.info(265)] - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSource ConnectionProvider
          After that line my application hangs, but only if i set poxy server* in internet connection.

          As I understand, you want to connect a non local db? (strange idea...)
          I have a database in local network.
          Only I meant here is that if I set the internet connection proxy application hangs on a line that I mentioned above. No exception, nothing. Just hangs.

          *Set proxy server:
          On the Tools menu in Internet Explorer, click Internet Options, click the Connections tab, and then click LAN Settings.
          Under Proxy server, click to select the Use a proxy server for your LAN check box.
          In the Address box, type the IP address of the proxy server.
          In the Port box, type the port number that is used by the proxy server for client connections (by default, 8080).
          Click OK to close the LAN Settings dialog box.
          Click OK again to close the Internet Options dialog box.

          I even try select and unselect the Bypass proxy server for local addresses check box but it doesn't metter.

          Comment


          • #6
            After 5minutes waiting i have got this exception:
            Code:
            org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (JZ006: Caught IOException: java.net.SocketException: Malformed reply from SOCKS server)
            	at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
            	at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
            	at info.kkrzyzak.sunfire.dao.utils.DecryptingDataSource.getConnection(DecryptingDataSource.java:36)
            	at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
            	at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:114)
            	at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
            	at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
            	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
            	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
            	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
            	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
            	at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
            	at java.security.AccessController.doPrivileged(Native Method)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
            	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
            	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
            	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
            	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
            	at java.security.AccessController.doPrivileged(Native Method)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
            	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
            	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
            	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:671)
            	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610)
            	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
            	at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
            	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
            	at java.security.AccessController.doPrivileged(Native Method)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
            	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
            	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
            	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:671)
            	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610)
            	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
            	at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
            	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
            	at java.security.AccessController.doPrivileged(Native Method)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
            	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
            	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
            	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:671)
            	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610)
            	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
            	at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
            	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
            	at java.security.AccessController.doPrivileged(Native Method)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
            	at ......

            Comment


            • #7
              You can set the "http.nonProxyHosts" but it's strange that when you define a Http proxy it is also act as a sock proxy (it should be set through socksProxyHost properties).
              So I hopes it's not a dbcp bug...

              Comment


              • #8
                I try following without any result:
                1.
                Code:
                System.getProperties().put("proxySet", "false");
                System.getProperties().put("http.proxyHost", "");
                System.getProperties().put("http.proxyPort", "");
                System.getProperties().put("socksProxyHost", "");
                System.getProperties().put("socksProxyPort", "");
                2.
                Code:
                System.setProperty("java.net.useSystemProxies","false");
                3.
                Code:
                System.setProperty("http.nonProxyHosts","localhost|kkrzyzak");
                4.
                Code:
                System.getProperties().remove("http.proxyHost");
                System.getProperties().remove("http.proxyPort");
                System.getProperties().remove("socksProxyHost");
                System.getProperties().remove("socksProxyPort");
                5.
                Code:
                System.setProperty("proxySet", "false");
                System.setProperty("http.proxyHost", "");
                System.setProperty("http.proxyPort", "");
                System.setProperty("socksProxyHost", "");
                System.setProperty("socksProxyPort", "");
                6.
                Code:
                -Dhttp.proxyHost="" -Dhttp.proxyPort="" -DsocksProxyHost="" -DsocksProxyPort=""
                I was based on the information contained in article "Java Networking and Proxies" (javase/6/docs/technotes/guides/net)

                I think for some reason the JRE tries to talk SOCKS protocol to a host, which is not a SOCKS proxy.
                For clearly, I haven't SOCKS proxy server.

                Even created a little piece of code that shows me I am using a proxy or not.

                Code:
                public static void listaUstawienProxy(boolean useProxy){
                        try {
                
                            System.setProperty("java.net.useSystemProxies",useProxy?"true":"false");
                            List l = ProxySelector.getDefault().select(
                                    new URI("http://www.yahoo.com/"));
                
                            for (Iterator iter = l.iterator(); iter.hasNext(); ) {
                
                                Proxy proxy = (Proxy) iter.next();
                
                                System.out.println("proxy hostname : " + proxy.type());
                
                                InetSocketAddress addr = (InetSocketAddress)
                                        proxy.address();
                
                                if(addr == null) {
                
                                    System.out.println("No Proxy");
                
                                } else {
                
                                    System.out.println("proxy hostname : " +
                                            addr.getHostName());
                
                                    System.out.println("proxy port : " +
                                            addr.getPort());
                
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                When i pass false the result is :
                Code:
                proxy hostname : DIRECT
                No Proxy
                When i pass true the result is:
                Code:
                proxy hostname : HTTP
                proxy hostname : 192.168.100.1
                proxy port : 3128

                Comment


                • #9
                  (BasicDataSource)
                  It hangs in method protected static void validateConnectionFactory(PoolableConnectionFactor y connectionFactory) when try to call conn = (Connection) connectionFactory.makeObject();

                  Comment


                  • #10
                    If you set the systemproxy, look into the java network configuration in the configuration panel to set your network connection.

                    Comment


                    • #11
                      The problem stemmed from the use of SAF (Simple Application Framework). Spring initialization has been performed in method initialize a proxy definition in the method main. After the transfer the following line of code to the initialize method, application start normally.
                      Code:
                      System.setProperty("java.net.useSystemProxies","false");
                      Thread can be closed.

                      Thank you for your time.

                      Best,
                      Karol.

                      SOLVED.

                      Comment

                      Working...
                      X