Using webdrivermanager 1.7.1 to automate binary downloads for chromedriver but I'm getting "The driver is not executable" message.
I know the solution chmod +x ../chromedriver but required an automated process for that!!
Any help much appreciated.
Thanks
Similar issue here as well. Chrome was working but not Firefox. Removed geckodriver folder and tried as well.
But I did chmod 777 on geckdriver and it worked.
package frameWork;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.safari.SafariDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
public class BaseClass {
public WebDriver driver;
public WebDriver initializeDriver() throws IOException {
Properties p = new Properties();
FileInputStream f = new FileInputStream("src/main/java/frameWork/data.properties");
p.load(f);
String browser = p.getProperty("browser");
if(browser.equals("chrome")) {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
} else if(browser.equals("firefox")) {
WebDriverManager.firefoxdriver().setup();
driver = new FirefoxDriver();
} else {
System.setProperty("webdriver.safari.driver","/usr/bin/safaridriver");
driver = new SafariDriver();
}
//driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
return driver;
}
}
Error
[RemoteTestNG] detected TestNG version 6.8.0 [TestNG] Running:
/private/var/folders/q1/2vf46m2546926xbq00dw66l40000gp/T/testng-eclipse-1456133345/testng-customsuite.xml
[main] INFO io.github.bonigarcia.wdm.WebDriverManager - Latest version
of [wires, geckodriver] is 0.20.0 Mar 13, 2018 10:49:44 AM
org.apache.http.client.protocol.ResponseProcessCookies processCookies
WARNING: Invalid cookie header: "Set-Cookie: logged_in=no;
domain=.github.com; path=/; expires=Sat, 13 Mar 2038 05:19:44 -0000;
secure; HttpOnly". Invalid 'expires' attribute: Sat, 13 Mar 2038
05:19:44 -0000 WARNING: An illegal reflective access operation has
occurred WARNING: Illegal reflective access by
org.rauschig.jarchivelib.FileModeMapper$FileSystemPreferencesReflectionChmodCommand
(file:/Users/basil/.m2/repository/org/rauschig/jarchivelib/0.7.1/jarchivelib-0.7.1.jar)
to method
java.util.prefs.FileSystemPreferences.chmod(java.lang.String,int)
WARNING: Please consider reporting this to the maintainers of
org.rauschig.jarchivelib.FileModeMapper$FileSystemPreferencesReflectionChmodCommand
WARNING: Use --illegal-access=warn to enable warnings of further
illegal reflective access operations WARNING: All illegal access
operations will be denied in a future release Mar 13, 2018 10:49:50 AM
org.rauschig.jarchivelib.FileModeMapper$UnixPermissionMapper chmod
WARNING: Could not set file permissions of
/Users/basil/.m2/repository/webdriver/geckodriver/macos/0.20.0/geckodriver.
Exception was: null [main] WARN io.github.bonigarcia.wdm.Downloader -
Error setting file
/Users/basil/.m2/repository/webdriver/geckodriver/macos/0.20.0/geckodriver-v0.20.0-macos.tar.gz
as executable [main] INFO io.github.bonigarcia.wdm.WebDriverManager -
Exporting webdriver.gecko.driver as
/Users/basil/.m2/repository/webdriver/geckodriver/macos/0.20.0/geckodriver-v0.20.0-macos.tar.gz
FAILED: basePageNavigation java.lang.IllegalStateException: The driver
executable does not exist:
/Users/basil/.m2/repository/webdriver/geckodriver/macos/0.20.0/geckodriver-v0.20.0-macos.tar.gz
at
com.google.common.base.Preconditions.checkState(Preconditions.java:585)
at
org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:136)
at
org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:131)
at
org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41)
at
org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:141)
at
org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:339)
at
org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:158)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:98)
at frameWork.BaseClass.initializeDriver(BaseClass.java:32) at
frameWork.HomePage.basePageNavigation(HomePage.java:11) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564) at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at
org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at
org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767) at
org.testng.TestRunner.run(TestRunner.java:617) at
org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at
org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at
org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at
org.testng.SuiteRunner.run(SuiteRunner.java:240) at
org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at
org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at
org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) at
org.testng.TestNG.runSuitesLocally(TestNG.java:1123) at
org.testng.TestNG.run(TestNG.java:1031) at
org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Try with this WebDriverManager version:
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.8.1</version>
</dependency>
Related
This question already has answers here:
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
(9 answers)
Selenium-TestNG-Maven - Getting "java.lang.NoClassDefFoundError: org/openqa/selenium/firefox/FirefoxDriver"
(2 answers)
Closed 2 years ago.
I have this script in InteliJ Idea
package com.test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Main {
public static void main(String[] args) throws InterruptedException {
// write your code here
WebDriver driver = new ChromeDriver();
driver.get("https://cs.wikipedia.org/wiki/Wiki");
WebElement link;
link = driver.findElement(By.linkText("English"));
link.click();
Thread.sleep(5000);
WebElement searchbox;
searchbox = driver.findElement(By.id("searchInput"));
searchbox.sendKeys("Software");
Thread.sleep(5000);
driver.quit();
}
}
When i tried to run it it gives me this error:
"C:\Program Files\Java\jdk-10.0.2\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.1.1\lib\idea_rt.jar=51622:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.1.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\Jenda\IdeaProjects\test\out\production\test;D:\automatizace testů\selenium\selenium-java-3.141.59\client-combined-3.141.59.jar;D:\automatizace testů\selenium\selenium-java-3.141.59\libs\byte-buddy-1.8.15.jar;D:\automatizace testů\selenium\selenium-java-3.141.59\libs\commons-exec-1.3.jar;D:\automatizace testů\selenium\selenium-java-3.141.59\libs\guava-25.0-jre.jar;D:\automatizace testů\selenium\selenium-java-3.141.59\libs\okhttp-3.11.0.jar;D:\automatizace testů\selenium\selenium-java-3.141.59\libs\okio-1.14.0.jar;D:\automatizace testů\selenium\selenium-java.jar;D:\automatizace testů\selenium\guava-14.0.jar;D:\automatizace testů\selenium\json-20080701.jar;D:\automatizace testů\selenium\selenium-api-2.31.0.jar" com.test.Main
Error: Unable to initialize main class com.test.Main
Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
Process finished with exit code 1
could you please give me some advice what is wrong?
I am using camel 2.15.1 which uses CXF 3.0.4. I am trying to deploy my web application into Websphere 7.0. It is throwing Incompatible class version version. I have already Disabled websphere JAX WS engine com.ibm.websphere.webservices.DisableIBMJAXWSEngine=true and changed classloader to parent last. Still get below error. Similar approach with Camel 2.10.X on my earlier application has worked though. Below is stacktrace.
[5/11/16 21:12:59:157 GMT+08:00] 00000024 extension E com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor createServletWrapper Error occured while preparing the servlet for initialization.
javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:434)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:169)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1809)
at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:98)
at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:1038)
at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:959)
at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:638)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:436)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:304)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:166)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:731)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:616)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:376)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:668)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1147)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1320)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:611)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:945)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:760)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$1.run(ApplicationMgrImpl.java:1292)
at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5305)
at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5483)
at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1297)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2069)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:434)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:377)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:648)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:610)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1204)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:272)
at javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1152)
at java.security.AccessController.doPrivileged(AccessController.java:298)
at com.ibm.oti.security.CheckedAccessControlContext.securityCheck(CheckedAccessControlContext.java:30)
at sun.misc.JavaSecurityAccessWrapper.doIntersectionPrivilege(JavaSecurityAccessWrapper.java:41)
at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1146)
at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:999)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:847)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:783)
at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1331)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1224)
at com.ibm.ws.management.connector.AdminServiceDelegator.invoke(AdminServiceDelegator.java:181)
at com.ibm.ws.management.connector.ipc.CallRouter.route(CallRouter.java:242)
at com.ibm.ws.management.connector.ipc.IPCConnectorInboundLink.doWork(IPCConnectorInboundLink.java:353)
at com.ibm.ws.management.connector.ipc.IPCConnectorInboundLink$IPCConnectorReadCallback.complete(IPCConnectorInboundLink.java:595)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1662)
Caused by: org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.apache.camel.component.cxf.transport.CamelTransportFactory.
at org.apache.cxf.bus.extension.Extension.tryClass(Extension.java:183)
at org.apache.cxf.bus.extension.Extension.getClassObject(Extension.java:199)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.activateAllByType(ExtensionManagerImpl.java:144)
at org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:180)
at org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:186)
at org.apache.cxf.bus.CXFBusFactory.createBus(CXFBusFactory.java:40)
at org.apache.cxf.bus.CXFBusFactory.createBus(CXFBusFactory.java:36)
at org.apache.cxf.bus.CXFBusFactory.createBus(CXFBusFactory.java:32)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:146)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:122)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:94)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:83)
at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:83)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:76)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:358)
... 64 more
Caused by: java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=org/apache/camel/component/cxf/transport/CamelTransportFactory, offset=6
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:287)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:74)
at com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:778)
at com.ibm.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:691)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:532)
at java.lang.ClassLoader.loadClass(ClassLoader.java:643)
at org.apache.cxf.bus.extension.Extension.tryClass(Extension.java:164)
... 78 more
Found the problem. It is due to WAS 7.0 running with java 6 and application is build using 1.7.
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.
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;
}
}
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");