Generate Google Cloud Endpoint Lib Failure with SocketTimeoutException: Read timed out - google-app-engine

Google app engine sdk version is 1.8.9
Google Plugin for Eclipse with https://dl.google.com/eclipse/plugin/4.3
OS version is windows 7 x64
Language is English
Try to use the eclipse 4.3 to create the Guestbook sample as https://developers.google.com/appengine/docs/java/endpoints/getstarted/backend/
The sample project can be build/deploy successfully. And the API also is tested ok.
But when try to use the google->generate cloud endpoint client libary, it will prompt an error, the error trace is as below (PS: Also tried with command line, still failed.):
- Error Details --
Date: Mon Feb 10 20:47:49 CST 2014
Message: Unexpected Exception
Severity: Error
Product: Eclipse 2.0.0.20130613-0530 (org.eclipse.epp.package.mobile.product)
Plugin: com.google.gdt.eclipse.appengine.swarm
Exception Stack Trace:
java.lang.reflect.InvocationTargetException
at com.google.gdt.eclipse.appengine.swarm.wizards.GenerateSwarmApiAction$1.run(GenerateSwarmApiAction.java:82)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmGenerationException: java.net.SocketTimeoutException: Read timed out
at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createClientLibFromApiConfig(SwarmApiCreator.java:144)
at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createSwarmApi(SwarmApiCreator.java:258)
at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmServiceCreator.create(SwarmServiceCreator.java:444)
at com.google.gdt.eclipse.appengine.swarm.wizards.GenerateSwarmApiAction$1.run(GenerateSwarmApiAction.java:80)
... 1 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
at sun.security.ssl.InputRecord.read(InputRecord.java:480)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.net.www.MeteredStream.read(MeteredStream.java:134)
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3053)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3047)
at com.google.api.server.spi.IoUtil.copy(IoUtil.java:57)
at com.google.api.server.spi.tools.CloudClientLibGenerator.copyJar(CloudClientLibGenerator.java:88)
at com.google.api.server.spi.tools.CloudClientLibGenerator.generateClientLib(CloudClientLibGenerator.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createClientLibFromApiConfig(SwarmApiCreator.java:142)
... 4 more
Root exception:
com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmGenerationException: java.net.SocketTimeoutException: Read timed out
at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createClientLibFromApiConfig(SwarmApiCreator.java:144)
at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createSwarmApi(SwarmApiCreator.java:258)
at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmServiceCreator.create(SwarmServiceCreator.java:444)
at com.google.gdt.eclipse.appengine.swarm.wizards.GenerateSwarmApiAction$1.run(GenerateSwarmApiAction.java:80)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
at sun.security.ssl.InputRecord.read(InputRecord.java:480)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.net.www.MeteredStream.read(MeteredStream.java:134)
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3053)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3047)
at com.google.api.server.spi.IoUtil.copy(IoUtil.java:57)
at com.google.api.server.spi.tools.CloudClientLibGenerator.copyJar(CloudClientLibGenerator.java:88)
at com.google.api.server.spi.tools.CloudClientLibGenerator.generateClientLib(CloudClientLibGenerator.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createClientLibFromApiConfig(SwarmApiCreator.java:142)
... 4 more
The code is simple as below:
Greetings.java:
package com.test.guestbook;
import java.util.ArrayList;
import javax.inject.Named;
import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.appengine.api.users.User;
/**
* Defines v1 of a helloworld API, which provides simple "greeting" methods.
*/
#Api(name = "helloworld", version = "v1")
public class Greetings {
public static ArrayList<HelloGreeting> greetings = new ArrayList<HelloGreeting>();
static {
greetings.add(new HelloGreeting("hello world!"));
greetings.add(new HelloGreeting("goodbye world!"));
}
public HelloGreeting getGreeting(#Named("id") Integer id, User user) {
return greetings.get(id);
}
}
HelloGreeting.java
package com.test.guestbook;
public class HelloGreeting {
public String message;
public HelloGreeting() {};
public HelloGreeting(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

Related

How do I actually make Geb work with Grails 2.3.11?

Stumbled across Geb the other day. I'm on Grails 2.3.11. How do I actually install Geb correctly? I downloaded the jar files and included them but when I try to run my code I get ClassNotFoundException on org.openqa.selenium.WebDriverException
I'm using IntelliJ IDEA if that matters.
Libraries
Gebtest.groovy
package gebish
import geb.Browser
class Gebtest {
public static void main(String[] args) {
println "Hi!"
Browser.drive {
go "http://gebish.org"
assert title == "Geb - Very Groovy Browser Automation"
}
}
}
Errors
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriverException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:344)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:65)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:62)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:62)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:159)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at gebish.Gebtest.main(Gebtest.groovy:6)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriverException
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 11 more
I also use Grails 2.3.11 and got GEB running. It's been a while, so I'm not sure what exactly is needed but here are some parts of my BuildConfig.groovy that might be relevant:
def gebVersion = "0.13.1"
def webdriverVersion = "2.53.1"
dependencies {
compile "org.codehaus.groovy:groovy-backports-compat23:2.4.13"
test "org.gebish:geb-spock:${gebVersion}"
test "org.seleniumhq.selenium:selenium-support:${webdriverVersion}"
test "org.seleniumhq.selenium:selenium-chrome-driver:${webdriverVersion}"
test "org.seleniumhq.selenium:selenium-firefox-driver:${webdriverVersion}"
test "org.seleniumhq.selenium:selenium-ie-driver:${webdriverVersion}"
test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
}
plugins {
test(":spock:0.7") {
exclude "spock-grails-support"
}
test "org.grails.plugins:geb:${gebVersion}"
}

Google login gives error

I tried to implement google login in my project but it is giving me unknown host error after signing in with gmail username and password & then pressing the allow button. I have also kept android.playService.plus in build hint. Are other build hints necessary too? I didn't find proper documentation or blog to apply it as well.My code is as follow:
if (googleLogin.isNativeLoginSupported()) {
if (!googleLogin.isUserLoggedIn()) {
googleLogin.doLogin();
}
AccessToken at = googleLogin.getAccessToken();
System.out.println("token " + at.getToken()); // this value is null
} else {
if (!googleLogin.isUserLoggedIn()) {
googleLogin.doLogin();
System.out.println("not logged in : not native login");
}
}
googleLogin.setCallback(new LoginCallback() {
#Override
public void loginFailed(String errorMessage) {
Dialog.show("Login Faild", "Retry Login", "Retry", null);
google_signIn(res);
}
#Override
public void loginSuccessful() {
System.out.println("successfull");
new NewForm(res).show();
}
});
Error:
Received exception: Unknown host
java.lang.Throwable: Unknown host
at javafx.scene.web.WebEngine$LoadWorker.describeError(WebEngine.java:1402)
at javafx.scene.web.WebEngine$LoadWorker.dispatchLoadEvent(WebEngine.java:1341)
at javafx.scene.web.WebEngine$LoadWorker.access$1100(WebEngine.java:1219)
at javafx.scene.web.WebEngine$PageLoadListener.dispatchLoadEvent(WebEngine.java:1206)
at com.sun.webkit.WebPage.fireLoadEvent(WebPage.java:2387)
at com.sun.webkit.WebPage.fwkFireLoadEvent(WebPage.java:2231)
at com.sun.webkit.network.URLLoader.twkDidFail(Native Method)
at com.sun.webkit.network.URLLoader.notifyDidFail(URLLoader.java:843)
at com.sun.webkit.network.URLLoader.lambda$didFail$93(URLLoader.java:826)
at com.sun.webkit.network.URLLoader$$Lambda$197/728465605.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$63/2017575979.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$62/1811810557.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$54/5182121.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
On the simulator we need to use web login as there is no native login and it uses a web page which might not look great.
On the device native login is used and should feel seamless. It's important to check devices for this sort of functionality as they behave very differently.

GAE Datastore search not working on local development instance (Java)

My local instance of Java Google App Engine seems to index search documents just fine, but started throwing an exception when running a search. Code snippet and exception included. TIA!
Code for searching :
QueryOptions options = QueryOptions.newBuilder()
.setLimit(500)
.build();
String queryString = searchStr;
Query query = Query.newBuilder().setOptions(options).build(queryString);
IndexSpec indexSpec = IndexSpec.newBuilder().setName(projectName + "Search").build();
Index index = SearchServiceFactory.getSearchService().getIndex(indexSpec);
Results<ScoredDocument> results = null;
try {
results = index.search(query);
} catch (SearchException e) {
}
Exception:
java.lang.NullPointerException at
com.google.appengine.repackaged.com.google.appengine.api.search.SearchServicePb$ListDocumentsResponse$Builder.addDocument(SearchServicePb.java:13298)
at
com.google.appengine.api.search.dev.LocalSearchService.listDocumentsForApp(LocalSearchService.java:527)
at
com.google.appengine.api.search.dev.LocalSearchService.getFieldTypes(LocalSearchService.java:710)
at
com.google.appengine.api.search.dev.LocalSearchService.searchForApp(LocalSearchService.java:564)
at
com.google.appengine.api.search.dev.LocalSearchService.search(LocalSearchService.java:547)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:525)
at
com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:479)
at
com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:456)
at
java.util.concurrent.Executors$PrivilegedCallable$1.run(Executors.java:493)
at java.security.AccessController.doPrivileged(Native Method) at
java.util.concurrent.Executors$PrivilegedCallable.call(Executors.java:490)
at java.util.concurrent.FutureTask.run(FutureTask.java:262) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

How to fix Cloudant-client connection error

I used cloudant-client-1.0.0.jar to make a test to check the connection to cloudant server as:
import com.cloudant.client.api.CloudantClient;
import com.cloudant.client.api.Database;
public class test {
private CloudantClient client=null;
public CloudantClient connect(){
client=new CloudantClient("xxx", "xxx", "xxx");
System.out.println("Connection successful! "+client.getBaseUri());
return client;
}
public Database getDb(String dbName){
Database db=connect().database(dbName, true);
System.out.println("Datase avaible - "+db.getDBUri());
return db;
}
public static void main(String[] args){
new test().getDb("_user");
}
}
However, the system shows errors:
Exception in thread "main"
java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpEntityEnclosingRequestBase
at connection.test.connect(test.java:13)
at connection.test.getDb(test.java:21)
at connection.test.main(test.java:30)
Caused by:
java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpEntityEnclosingRequestBase
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
How to fix it?
You're missing a dependency for the library, Apache http client. However you should use Maven, gradle or a similar build tool which understands Maven repositories. You should also look at upgrading to 2.4.1, it contains numerous improvements and bug fixes.

How to run WS-Notification sample with Apache CXF?

I would like to try out the WS-Notification example in the Apache CXF. the only file they give is a Client.java file.
Is it that I just need to compile this Client.java file and I can get the program running? i tried but it not working.
If not, will greatly appreciate anyone that can give me a step by step guide.
Below is the code of Client.java from WS-Notification sample.
package demo.client;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import org.w3c.dom.Element;
import org.apache.cxf.wsn.client.Consumer;
import org.apache.cxf.wsn.client.NotificationBroker;
import org.apache.cxf.wsn.client.Subscription;
import org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType;
/**
*
*/
public final class Client {
private Client() {
//not constructed
}
/**
* #param args
*/
public static void main(String[] args) throws Exception {
String wsnPort = "9000";
if (args.length > 0) {
wsnPort = args[0];
}
// Start a consumer that will listen for notification messages
// We'll just print the text content out for now.
Consumer consumer = new Consumer(new Consumer.Callback() {
public void notify(NotificationMessageHolderType message) {
Object o = message.getMessage().getAny();
System.out.println(message.getMessage().getAny());
if (o instanceof Element) {
System.out.println(((Element)o).getTextContent());
}
}
}, "http://localhost:9001/MyConsumer");
// Create a subscription for a Topic on the broker
NotificationBroker notificationBroker
= new NotificationBroker("http://localhost:" + wsnPort + "/wsn/NotificationBroker");
Subscription subscription = notificationBroker.subscribe(consumer, "MyTopic");
// Send a notification on the Topic
notificationBroker.notify("MyTopic",
new JAXBElement<String>(new QName("urn:test:org", "foo"),
String.class, "Hello World!"));
// Just sleep for a bit to make sure the notification gets delivered
Thread.sleep(5000);
// Cleanup and exit
subscription.unsubscribe();
consumer.stop();
System.exit(0);
}
}
Error is here:
Aug 10, 2012 4:52:50 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://client.wsn.cxf.apache.org/}ConsumerService from class org.oasis_open.docs.wsn.bw_2.NotificationConsumer
Aug 10, 2012 4:52:52 PM org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be http://localhost:9001/MyConsumer
Aug 10, 2012 4:52:52 PM org.eclipse.jetty.server.Server doStart
INFO: jetty-7.5.4.v20111024
Aug 10, 2012 4:52:52 PM org.eclipse.jetty.server.AbstractConnector doStart
INFO: Started SelectChannelConnector#localhost:9001 STARTING
Aug 10, 2012 4:52:52 PM org.eclipse.jetty.server.handler.ContextHandler startContext
INFO: started o.e.j.s.h.ContextHandler{,null}
Aug 10, 2012 4:52:52 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: Creating Service {http://cxf.apache.org/wsn/jaxws}NotificationBrokerService from WSDL: jar:file:/home/wenbin/Desktop/keith/Apache/apache-cxf-2.6.1/lib/cxf-services-wsn-api-2.6.1.jar!/org/apache/cxf/wsn/wsdl/wsn.wsdl
Aug 10, 2012 4:52:53 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://cxf.apache.org/wsn/jaxws}NotificationBrokerService#{http://docs.oasis-open.org/wsn/brw-2}Subscribe has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:532)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:89)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
at $Proxy66.subscribe(Unknown Source)
at org.apache.cxf.wsn.client.NotificationBroker.subscribe(NotificationBroker.java:208)
at org.apache.cxf.wsn.client.NotificationBroker.subscribe(NotificationBroker.java:162)
at test.Client.main(Client.java:67)
Caused by: java.net.ConnectException: ConnectException invoking http://localhost:9000/wsn/NotificationBroker: Connection refused
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1457)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1442)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:658)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 11 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at sun.net.NetworkClient.doConnect(NetworkClient.java:173)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:409)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:530)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:240)
at sun.net.www.http.HttpClient.New(HttpClient.java:321)
at sun.net.www.http.HttpClient.New(HttpClient.java:338)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:935)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:876)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:801)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:979)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1394)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1336)
at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42)
at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1414)
... 14 more
Exception in thread "main" javax.xml.ws.WebServiceException: Could not send Message.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)
at $Proxy66.subscribe(Unknown Source)
at org.apache.cxf.wsn.client.NotificationBroker.subscribe(NotificationBroker.java:208)
at org.apache.cxf.wsn.client.NotificationBroker.subscribe(NotificationBroker.java:162)
at test.Client.main(Client.java:67)
Caused by: java.net.ConnectException: ConnectException invoking http://localhost:9000/wsn/NotificationBroker: Connection refused
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1457)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1442)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:658)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:532)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:89)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
... 4 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at sun.net.NetworkClient.doConnect(NetworkClient.java:173)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:409)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:530)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:240)
at sun.net.www.http.HttpClient.New(HttpClient.java:321)
at sun.net.www.http.HttpClient.New(HttpClient.java:338)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:935)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:876)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:801)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:979)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1394)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1336)
at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42)
at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1414)
... 14 more
okay,
finally figured it out. the issue is the ws-notification sample should be run by maven using the command line. i was trying to run them in eclipse.
when running in eclipse, we will need to add in extra line to Starts up an instance of a WS-Notification service.
the modified codes segment as below:
NotificationBroker notificationBroker
= new NotificationBroker("http://localhost:" + wsnPort + "/wsn/NotificationBroker");
//these 3 lines are the codes added.
String agu[] = new String[2];
Service service = new Service(agu);
service.start();
Subscription subscription = notificationBroker.subscribe(consumer, "MyTopic");

Resources