Not able to connect to internet/repo through proxy

We access internet via a proxy server. I have set the http.proxyHost parameter in the studio.bat as below. But still am not able to access the cuba repo through the proxy internet.

IN studio.bat
set JAVA_OPTS=%JAVA_OPTS% "-Dhttp.proxyHost=proxy.domain.com"
set JAVA_OPTS=%JAVA_OPTS% “-Dhttp.proxyPort=8080”

After some code inspection, I found that there is no System.getProperty(“http.proxyHost”) to get the proxy host and port and connect to the internet.

localObject1 = new URL(str1 + “com/haulmont/cuba/cuba-global”);
localURLConnection = ((URL)localObject1).openConnection();

Can you please check?

Thanks in advance.

1 Like

Please try to set proxy settings system-wide in the JAVA_OPTS environment variable. They are required for both Studio and Gradle.
See https://doc.cuba-platform.com/manual-6.1/cubaStudio_install.html

1 Like

We are already doing it as said earlier

In studio-2.1.4\bin\studio.bat
set JAVA_OPTS=%JAVA_OPTS% "-Dhttp.proxyHost=proxy.domain.com"
set JAVA_OPTS=%JAVA_OPTS% “-Dhttp.proxyPort=8080”

Somehow the proxy is not picked up by the com.haulmont.studio.server.EntryPoint

1 Like

Why do you think that Studio cannot access the repository? What exception do you have?
As I said, Gradle needs access too. That is why I suggest to set the proxy options in system-wide environment variables.

Am getting the UnknownHostException while accessing the repo. Screenshot attached. I have set gradle home and added the JAVA_OPTS to gradle.bat too.

studio

1 Like

OK, now I see that Studio cannot connect.
We rely on default JVM proxy selection mechanism which uses system properties, so Studio does not contain any proxy-specific code.
Can you ensure that you are able to access the internet from a simple Java program using your proxy settings?

Yes I am able to connect to the internet from a sample java program.

Here’s the log stack trace:



2016-06-07 16:09:41,325 INFO  [com.haulmont.studio.server.a] CUBA Studio v.2.1.4 built on 2016-05-24 11:11:06
2016-06-07 16:09:41,843 WARN  [com.haulmont.studio.server.launcher.AppStartWindow] javaHomeTextField=TextField[id=javaHomeTextField, styleClass=text-input text-field]
2016-06-07 16:09:41,843 WARN  [com.haulmont.studio.server.launcher.AppStartWindow] main=com.haulmont.studio.server.a@25dc6456
2016-06-07 16:09:41,843 WARN  [com.haulmont.studio.server.launcher.AppStartWindow] main.getConfig()=com.haulmont.studio.server.m@3d2492f4
2016-06-07 16:09:45,242 DEBUG [org.gradle.tooling.GradleConnector] Connecting from tooling API consumer version 2.6
2016-06-07 16:09:45,312 DEBUG [org.gradle.tooling.internal.consumer.loader.DefaultToolingImplementationLoader] Using tooling provider from Gradle installation 'D:\gradle-2.13'
2016-06-07 16:09:45,315 DEBUG [org.gradle.tooling.internal.consumer.loader.DefaultToolingImplementationLoader] Using tooling provider classpath: [D:\gradle-2.13\lib\ant-1.9.6.jar, D:\gradle-2.13\lib\ant-launcher-1.9.6.jar, D:\gradle-2.13\lib\asm-all-5.0.3.jar, D:\gradle-2.13\lib\commons-collections-3.2.2.jar, D:\gradle-2.13\lib\commons-io-2.2.jar, D:\gradle-2.13\lib\commons-lang-2.6.jar, D:\gradle-2.13\lib\dom4j-1.6.1.jar, D:\gradle-2.13\lib\gradle-base-services-2.13.jar, D:\gradle-2.13\lib\gradle-base-services-groovy-2.13.jar, D:\gradle-2.13\lib\gradle-cli-2.13.jar, D:\gradle-2.13\lib\gradle-core-2.13.jar, D:\gradle-2.13\lib\gradle-docs-2.13.jar, D:\gradle-2.13\lib\gradle-installation-beacon-2.13.jar, D:\gradle-2.13\lib\gradle-launcher-2.13.jar, D:\gradle-2.13\lib\gradle-messaging-2.13.jar, D:\gradle-2.13\lib\gradle-model-core-2.13.jar, D:\gradle-2.13\lib\gradle-model-groovy-2.13.jar, D:\gradle-2.13\lib\gradle-native-2.13.jar, D:\gradle-2.13\lib\gradle-open-api-2.13.jar, D:\gradle-2.13\lib\gradle-resources-2.13.jar, D:\gradle-2.13\lib\gradle-tooling-api-2.13.jar, D:\gradle-2.13\lib\gradle-ui-2.13.jar, D:\gradle-2.13\lib\gradle-wrapper-2.13.jar, D:\gradle-2.13\lib\groovy-all-2.4.4.jar, D:\gradle-2.13\lib\guava-jdk5-17.0.jar, D:\gradle-2.13\lib\jansi-1.2.1.jar, D:\gradle-2.13\lib\jarjar-1.3.jar, D:\gradle-2.13\lib\javax.inject-1.jar, D:\gradle-2.13\lib\jaxen-1.1.jar, D:\gradle-2.13\lib\jcip-annotations-1.0.jar, D:\gradle-2.13\lib\jcl-over-slf4j-1.7.10.jar, D:\gradle-2.13\lib\jna-3.2.7.jar, D:\gradle-2.13\lib\jul-to-slf4j-1.7.10.jar, D:\gradle-2.13\lib\kryo-2.20.jar, D:\gradle-2.13\lib\log4j-over-slf4j-1.7.10.jar, D:\gradle-2.13\lib\minlog-1.2.jar, D:\gradle-2.13\lib\native-platform-0.10.jar, D:\gradle-2.13\lib\native-platform-freebsd-amd64-0.10.jar, D:\gradle-2.13\lib\native-platform-freebsd-i386-0.10.jar, D:\gradle-2.13\lib\native-platform-linux-amd64-0.10.jar, D:\gradle-2.13\lib\native-platform-linux-i386-0.10.jar, D:\gradle-2.13\lib\native-platform-osx-amd64-0.10.jar, D:\gradle-2.13\lib\native-platform-osx-i386-0.10.jar, D:\gradle-2.13\lib\native-platform-windows-amd64-0.10.jar, D:\gradle-2.13\lib\native-platform-windows-i386-0.10.jar, D:\gradle-2.13\lib\objenesis-1.2.jar, D:\gradle-2.13\lib\reflectasm-1.07-shaded.jar, D:\gradle-2.13\lib\slf4j-api-1.7.10.jar]
2016-06-07 16:09:47,090 INFO  [java.lang.Class] plugins folder not found
2016-06-07 16:09:47,296 INFO  [org.atmosphere.util.IOUtils] META-INF/services/org.atmosphere.cpr.AtmosphereFramework not found in class loader
2016-06-07 16:09:47,486 INFO  [org.atmosphere.util.IOUtils] META-INF/services/org.atmosphere.cpr.AtmosphereFramework not found in class loader
2016-06-07 16:09:57,742 ERROR [com.haulmont.studio.server.a] Repository access error
java.net.UnknownHostException: repo.cuba-platform.com
	at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
	at java.net.PlainSocketImpl.connect(Unknown Source)
	at java.net.SocksSocketImpl.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
	at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
	at sun.net.NetworkClient.doConnect(Unknown Source)
	at sun.net.www.http.HttpClient.openServer(Unknown Source)
	at sun.net.www.http.HttpClient.openServer(Unknown Source)
	at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
	at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
	at com.haulmont.studio.server.f.run(SourceFile:296)
	at java.lang.Thread.run(Unknown Source)

Thanks for the help,but now I get a certificate error
With below JAVA_OPTS:
set JAVA_OPTS=%JAVA_OPTS% "-Dhttp.proxyHost=proxy.domain.com"
set JAVA_OPTS=%JAVA_OPTS% "-Dhttp.proxyPort=8080"
set JAVA_OPTS=%JAVA_OPTS% "-Dhttps.proxyHost=proxy.domain.com"
set JAVA_OPTS=%JAVA_OPTS% "-Dhttps.proxyPort=8080"
this error:


2016-06-07 18:50:55,460 INFO  [com.haulmont.studio.server.a] CUBA Studio v.2.1.4 built on 2016-05-24 11:11:06
2016-06-07 18:50:56,877 WARN  [com.haulmont.studio.server.launcher.AppStartWindow] javaHomeTextField=TextField[id=javaHomeTextField, styleClass=text-input text-field]
2016-06-07 18:50:56,877 WARN  [com.haulmont.studio.server.launcher.AppStartWindow] main=com.haulmont.studio.server.a@2ad76737
2016-06-07 18:50:56,877 WARN  [com.haulmont.studio.server.launcher.AppStartWindow] main.getConfig()=com.haulmont.studio.server.m@33aa868f
2016-06-07 18:51:05,216 DEBUG [org.gradle.tooling.GradleConnector] Connecting from tooling API consumer version 2.6
2016-06-07 18:51:05,368 DEBUG [org.gradle.tooling.internal.consumer.loader.DefaultToolingImplementationLoader] Using tooling provider from Gradle installation 'D:\gradle-2.13'
2016-06-07 18:51:05,369 DEBUG [org.gradle.tooling.internal.consumer.loader.DefaultToolingImplementationLoader] Using tooling provider classpath: [D:\gradle-2.13\lib\ant-1.9.6.jar, D:\gradle-2.13\lib\ant-launcher-1.9.6.jar, D:\gradle-2.13\lib\asm-all-5.0.3.jar, D:\gradle-2.13\lib\commons-collections-3.2.2.jar, D:\gradle-2.13\lib\commons-io-2.2.jar, D:\gradle-2.13\lib\commons-lang-2.6.jar, D:\gradle-2.13\lib\dom4j-1.6.1.jar, D:\gradle-2.13\lib\gradle-base-services-2.13.jar, D:\gradle-2.13\lib\gradle-base-services-groovy-2.13.jar, D:\gradle-2.13\lib\gradle-cli-2.13.jar, D:\gradle-2.13\lib\gradle-core-2.13.jar, D:\gradle-2.13\lib\gradle-docs-2.13.jar, D:\gradle-2.13\lib\gradle-installation-beacon-2.13.jar, D:\gradle-2.13\lib\gradle-launcher-2.13.jar, D:\gradle-2.13\lib\gradle-messaging-2.13.jar, D:\gradle-2.13\lib\gradle-model-core-2.13.jar, D:\gradle-2.13\lib\gradle-model-groovy-2.13.jar, D:\gradle-2.13\lib\gradle-native-2.13.jar, D:\gradle-2.13\lib\gradle-open-api-2.13.jar, D:\gradle-2.13\lib\gradle-resources-2.13.jar, D:\gradle-2.13\lib\gradle-tooling-api-2.13.jar, D:\gradle-2.13\lib\gradle-ui-2.13.jar, D:\gradle-2.13\lib\gradle-wrapper-2.13.jar, D:\gradle-2.13\lib\groovy-all-2.4.4.jar, D:\gradle-2.13\lib\guava-jdk5-17.0.jar, D:\gradle-2.13\lib\jansi-1.2.1.jar, D:\gradle-2.13\lib\jarjar-1.3.jar, D:\gradle-2.13\lib\javax.inject-1.jar, D:\gradle-2.13\lib\jaxen-1.1.jar, D:\gradle-2.13\lib\jcip-annotations-1.0.jar, D:\gradle-2.13\lib\jcl-over-slf4j-1.7.10.jar, D:\gradle-2.13\lib\jna-3.2.7.jar, D:\gradle-2.13\lib\jul-to-slf4j-1.7.10.jar, D:\gradle-2.13\lib\kryo-2.20.jar, D:\gradle-2.13\lib\log4j-over-slf4j-1.7.10.jar, D:\gradle-2.13\lib\minlog-1.2.jar, D:\gradle-2.13\lib\native-platform-0.10.jar, D:\gradle-2.13\lib\native-platform-freebsd-amd64-0.10.jar, D:\gradle-2.13\lib\native-platform-freebsd-i386-0.10.jar, D:\gradle-2.13\lib\native-platform-linux-amd64-0.10.jar, D:\gradle-2.13\lib\native-platform-linux-i386-0.10.jar, D:\gradle-2.13\lib\native-platform-osx-amd64-0.10.jar, D:\gradle-2.13\lib\native-platform-osx-i386-0.10.jar, D:\gradle-2.13\lib\native-platform-windows-amd64-0.10.jar, D:\gradle-2.13\lib\native-platform-windows-i386-0.10.jar, D:\gradle-2.13\lib\objenesis-1.2.jar, D:\gradle-2.13\lib\reflectasm-1.07-shaded.jar, D:\gradle-2.13\lib\slf4j-api-1.7.10.jar]
2016-06-07 18:51:09,636 ERROR [com.haulmont.studio.server.a] Repository access error
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at sun.security.ssl.Alerts.getSSLException(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
	at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
	at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
	at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
	at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
	at sun.security.ssl.Handshaker.processLoop(Unknown Source)
	at sun.security.ssl.Handshaker.process_record(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
	at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
	at com.haulmont.studio.server.f.run(SourceFile:296)
	at java.lang.Thread.run(Unknown Source)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
	at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
	at sun.security.validator.Validator.validate(Unknown Source)
	at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
	at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
	at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
	... 15 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
	at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
	at java.security.cert.CertPathBuilder.build(Unknown Source)
	... 21 more
1 Like

Can you try https.proxyHost, https.proxyPort?
The repository works through HTTPS, so it may require a different set of properties, see http://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html

We have tested the work behind proxy and it works fine with the properties you provided, on the latest JDK 1.8.0_91.
Can you try to connect to a HTTPS resource from another Java program?

I got the same proxy issue and also ended up with the proxy error. I solved it by importing the certificates of the CUBA website into the Java CA Certificates KeyStore.
I found this tool very helpful: http://www.keystore-explorer.org/
With this tool you can easily download the certificates (Examine -> Examine SSL -> SSL Host = repo.cuba-platform.com) and just press “Import” to import the into them to the KeyStore.

2 Likes