How to use API keys for Google cloud Translate API - java

I am trying to use Google cloud translate API in Java. I have signed up free trial version and enable translate API project from google cloud console. Also I have API key with me.
I referred to API usage reference created java maven project included dependency of google-cloud-translate. Its downloaded also as a dependency. In java class file I am using same code as given the link but its giving me below error.
I have not used API keys anywhere as I don't know where to use it. I think that's the problem but don't know how to pass API keys for authentication?
So I missed step "gcloud beta auth application-default login" in the link
as running it on command line doesn't work.
I have java project in eclipse and I am using "Run As"-> "Java application" to run it.
Exception in thread "main" com.google.cloud.translate.TranslateException: connect timed out
at com.google.cloud.translate.spi.DefaultTranslateRpc.translate(DefaultTranslateRpc.java:63)
at com.google.cloud.translate.spi.DefaultTranslateRpc.translate(DefaultTranslateRpc.java:145)
at com.google.cloud.translate.TranslateImpl$4.call(TranslateImpl.java:113)
at com.google.cloud.translate.TranslateImpl$4.call(TranslateImpl.java:110)
at com.google.cloud.RetryHelper.doRetry(RetryHelper.java:179)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:244)
at com.google.cloud.translate.TranslateImpl.translate(TranslateImpl.java:110)
at com.google.cloud.translate.TranslateImpl.translate(TranslateImpl.java:124)
at com.translate.main.Translator.main(Translator.java:83)
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:656)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:275)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1104)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:998)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:93)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:972)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at com.google.cloud.translate.spi.DefaultTranslateRpc.translate(DefaultTranslateRpc.java:125)
... 7 more

Couple of things that helped me out:
Used my api key as below:
Translate translate = TranslateOptions.newBuilder().
setApiKey((String)PropertyLoader.prop.get("GOOGLE_API_KEY")).
build().getService();
I was running the code behind corporate proxy(silly me). I added below lines(a static initializer) to my java code and bingo !!!
static {
System.setProperty("http.proxyHost", HTTP_PROXY_HOST);
System.setProperty("http.proxyPort", HTTP_PROXY_PORT);
System.setProperty("https.proxyHost", HTTPS_PROXY_HOST);
System.setProperty("https.proxyPort", HTTPS_PROXY_PORT);
}
where HTTP_PROXY_HOST and others are defined constants for my company...

Related

AWS Java: com.amazonaws.SdkClientException: Bad file descriptor

I am trying to follow SQS example from this repo https://github.com/jonyfs/spring-boot-jms-sqs.
I have upgraded Spring boot to 2.1.0-RELEASE and cloud dependency to Greenwich.M1. The code is working fine, producing messages and consuming it
But I keep getting below exception. I have tried with different dependencies combinations and adding clientconfiguration also.
com.amazonaws.SdkClientException: Unable to execute HTTP request: Connect to sqs.us-west-2.amazonaws.com:443 [sqs.us-west-2.amazonaws.com/52.119.165.100] failed: Bad file descriptor (connect failed)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1116)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1066)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:743)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:717)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
at com.amazonaws.services.sqs.AmazonSQSClient.doInvoke(AmazonSQSClient.java:2033)
at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:2009)
at com.amazonaws.services.sqs.AmazonSQSClient.executeGetQueueUrl(AmazonSQSClient.java:1084)
at com.amazonaws.services.sqs.AmazonSQSClient.getQueueUrl(AmazonSQSClient.java:1060)
at com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper.getQueueUrl(AmazonSQSMessagingClientWrapper.java:280)
at com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper.getQueueUrl(AmazonSQSMessagingClientWrapper.java:251)
at com.amazon.sqs.javamessaging.SQSSession.createQueue(SQSSession.java:622)
at org.springframework.jms.support.destination.DynamicDestinationResolver.resolveQueue(DynamicDestinationResolver.java:85)
at org.springframework.jms.support.destination.DynamicDestinationResolver.resolveDestinationName(DynamicDestinationResolver.java:59)
at org.springframework.jms.support.destination.JmsDestinationAccessor.resolveDestinationName(JmsDestinationAccessor.java:115)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createListenerConsumer(AbstractPollingMessageListenerContainer.java:222)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.initResourcesIfNecessary(DefaultMessageListenerContainer.java:1216)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1188)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1179)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1076)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to sqs.us-west-2.amazonaws.com:443 [sqs.us-west-2.amazonaws.com/52.119.165.100] failed: Bad file descriptor (connect failed)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:76)
at com.amazonaws.http.conn.$Proxy77.connect(Unknown Source)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at com.amazonaws.http.apache.client.impl.SdkHttpClient.execute(SdkHttpClient.java:72)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1238)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1058)
... 22 common frames omitted
Caused by: java.net.ConnectException: Bad file descriptor (connect failed)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:339)
at com.amazonaws.http.conn.ssl.SdkTLSSocketFactory.connectSocket(SdkTLSSocketFactory.java:142)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 38 common frames omitted
Bad file descriptor are usually thrown when you use a closed socket. Typically AWS SDK will automatically retry connection errors like this, which is why you're not seeing any actual impact - on the retry it uses a fresh connection.
If they're happening once in a while, just ignore them. If they happen frequently, try playing with your connection settings in the ClientConfiguration to see what reduces them.
I also strongly suggest validating that you don't have some sort of classpath conflict where there are multiple versions of the same classes on your classpath - "interesting" things can happen at runtime due to how the classloader chooses which one to use.

JVM and SocksProxy Settings do not work on Ubuntu 16.04

Basic information:
I am trying to get a Java application to connect to a target via SOCKS Proxy. I found this on finding out how to configure proxy settings, which is important, as I cannot change the source code to configure Proxy usage. However, the application did not connect via the proxy.
Details
I am using a small custom class for testing this, which has exactly one main method and does this:
public static void main(String... strings) throws URISyntaxException, IOException {
URL url = new URI("http", null, "localhost", 9998, null, null, null).toURL();
System.out.println("opening connection to " + url.toString());
URLConnection c = url.openConnection();
System.out.println("connecting");
c.connect();
System.out.println(c.getContentLength());
System.out.println(c.getContentType());
}
Then, I start that class using java <properties> <classname>.
Properties I have tried so far (single and combined):
socksPropertyHost=localhost
socksPropertyPort=9999
http.proxySet=true
http.proxyHost=localhost
http.proxyPort=9999
https.proxySet=true
https.proxyHost=localhost
https.proxyPort=9999
proxySet=true
proxyHost=localhost
proxyPort=9999
java.net.useSystemProxies=true
Likewise, I added these on the command line, added then to my environment, set the values in jre/lib/net.properties and pout them into a comma-separated list which was then passed as -D$JAVA_OPTS in a bash script.
All of the connections were refused with
Exception in thread "main" java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:357)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1202)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:966)
at sandbox.Sandbox.main(Example.java:16)
Basically, the question(s) here is/are this/these:
Am I doing something wrong here? Is that a bug? Is it just my System?
Any answer would be greatly appreciated.
Please notice the line
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
in the stack trace. You have configured your JVM to try a SOCKS5 proxy, but the proxy is not responding where the JVM tries to connect. Typically SOCKS proxies live on port 1080.

Error in build on device Android

I want to run my app on my real device Android but I receive this error:
Running command: D:\WebStorm\Path\platforms\android\cordova\run.bat ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk JAVA_HOME=C:\Program Files\Java\jdk1.8.0_40 WARNING : No target specified, deploying to device '02c5cabed02456d5'. Running: D:\WebStorm\Path\platforms\android\gradlew cdvBuildDebug -b D: \WebStorm\Path\platforms\android\build.gradle
-PcdvBuildArch=arm -Dorg. gradle.daemon=true Downloading http://services.gradle.org/distributions/gradle-2.2.1-all.zip
Exception in thread "main" java.lang.RuntimeException: java.net.ConnectException : Connection refused: connect
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc essManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48) Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketI mpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.ja va:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocket Impl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java :188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLC onnection.java:1168)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConn ection.java:1104)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne ction.java:998)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection .java:932)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLCo nnection.java:1512)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon nection.java:1440)
at org.gradle.wrapper.Download.downloadInternal(Download.java:59)
at org.gradle.wrapper.Download.download(Download.java:45)
at org.gradle.wrapper.Install$1.call(Install.java:60)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc essManager.java:65)
... 3 more
D:\WebStorm\Path\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^ Error code 1 for command: cmd with args: /s /c "D:\WebStorm\Path\platfo rms\android\gradlew cdvBuildDebug -b D:\WebStorm\Path\platforms\android \build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true" ERROR running one or more of the platforms: Error: D:\WebStorm\Path\pla tforms\android\cordova\run.bat: Command failed with exit code 8 You may not have the required environment or OS to run this project
I installed the Android sdk and I added to my Path in Windows7 this:
C:\Development\android-sdk\platform-tools;
C:\Development\android-sdk\tools;
C:\Development\android-sdk\android-sdk
Where is the problem???
It is seems be issue with proxy only.
You can set proxy in two ways.
Create/Edit gradle.properties # c:\Users\<username>\.gradle\
OR
Goto your project location and do the same as above
Example : platforms/android/gradle.properities
Write below content in file
systemProp.http.proxyHost=proxyhost
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=pwd
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
systemProp.https.proxyHost=proxyhost
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=pwd
systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost
This link helped me: http://forum.ionicframework.com/t/proxy-error-when-downloading-gradle-zip-during-ionic-emulate-android/31701
To find .gradle, go to your user folder (default is c:\Users\<your login>). In case gradle.properties is not existing, simply create one
Looking at your stacktrace it seems to be some kind of connectivity problem. Is your computer is using any proxy to connect to network? if yes then that have to be configured for your build tool as well. As i can see it is just trying to download gradle-2.2.1-all.zip and it is failing due to connection problem.
Solution: Steps to configure proxy in nodejs
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
Hope that information helps you.
Regards
Himanshu

DocumentDB Java SDK behind a proxy

I'm trying to create a simple web application from the todo tutorial.
As I'm behind a corporate proxy, I used the following common java system properties :
-Dhttp.proxyHost=myproxy Dhttp.proxyPort=3128
-Dhttps.proxyHost=myproxy -Dhttps.proxyPort=3128
I also try the following parameter:
-Djava.net.useSystemProxies=true
I still have a client exception
java.lang.IllegalStateException: Http client execution failed.
at com.microsoft.azure.documentdb.GatewayProxy.performPostRequest(GatewayProxy.java:350)
at com.microsoft.azure.documentdb.GatewayProxy.doSQLQuery(GatewayProxy.java:135)
at com.microsoft.azure.documentdb.DocumentClient.doQuery(DocumentClient.java:2013)
(...)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:625)
I would like to know if the azure documentdb sdk enable this proxy settings ? Maybe there is another way to set https proxy for this SDK ?
Following pull request merge, if you want to use a proxy you need to get a release version greater than 1.0.1.
As the release is not available at this moment, you could build github source and use the sdk snapshot version.
Then you just need to setup your proxy through configuration:
-Dhttp.proxyHost=myproxy Dhttp.proxyPort=3128
-Dhttps.proxyHost=myproxy -Dhttps.proxyPort=3128

Caused by: java.net.ConnectException: Connection refused Cloudify CLI

I have just downloaded cloudify2.6.2. When running the CLI of the cloudify i can not run the REST API as i get this error
Starting Non-Interactive Shell
>>> connect http://$localhost:8100
http://$localhost:8100/service/testrest Rest api error: Operation failed. org.apache.http.conn.HttpHostConnectException: Connection to http://$localhost:8100 refused
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:190)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
at org.cloudifysource.restclient.GSRestClient.executeHttpMethod(GSRestClient.java:371)
at org.cloudifysource.restclient.GSRestClient.get(GSRestClient.java:278)
at org.cloudifysource.restclient.GSRestClient.get(GSRestClient.java:265)
at org.cloudifysource.shell.rest.RestAdminFacade.doConnect(RestAdminFacade.java:87)
at org.cloudifysource.shell.AbstractAdminFacade.connect(AbstractAdminFacade.java:55)
at org.cloudifysource.shell.commands.Connect.doExecute(Connect.java:62)
at org.cloudifysource.shell.commands.AbstractGSCommand.execute(AbstractGSCommand.java:99)
at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.karaf.shell.console.jline.Console.run(Console.java:172)
at org.apache.karaf.shell.console.Main.run(Main.java:191)
at org.apache.karaf.shell.console.Main.run(Main.java:89)
at org.cloudifysource.shell.GigaShellMain.main(GigaShellMain.java:126)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:127)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
... 24 more
Communication Error accessing http://$localhost:8100/service/testrest. Reason: Connection to http://$localhost:8100 refused
I do not have any firewall and i also use jdk7.
I need some explanation on this.
Have you bootstrapped Cloudify on your machine by using bootstrap-localcloud? Also, it seems you're using $localhost instead of just localhost.
There are some things to note here.
First for the REST service to work it has to be up, so a bootstrapping procedure has to be done, THEN do the connect action.
In my situation it was something wrong in the setenv.sh located at ~/gigaspaces/bin/setenv.sh.
There were two declarations that was not supposed to be there.
One for the NIC and one for the LOOKUPLOCATOR, so i comment out them and i finally did bootstrap the cloud.
Cloudify Version 2.6.0
Danos

Categories