Does selenium webdriver support Struts 2 - selenium

I want to use Selenium WebDriver API using Struts2 Framework. So will it be supported or not.
If not then what should I do.
It means, suppose I have an textfield on my jsp, linked with action class and I want search on www.google.com with my textfield value by sendKeys to element "q".
What am trying to do is
index.jsp :
<s:form action="test">
<s:textfield name="search" label="Enter Search "></s:textfield>
</s:form>
</body>
struts.xml:
<action name="test" class="com.actions.TestAction">
<result name="SUCCESS">/success.jsp</result>
</action>
ActionClass :
package com.actions;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import com.opensymphony.xwork2.ActionSupport;
public class TestAction extends ActionSupport
{
private String search;
public String getSearch() {
return search;
}
public void setSearch(String search) {
this.search = search;
}
private static final long serialVersionUID = -1241657564582564726L;
#Override
public String execute() throws Exception {
WebDriver driver = new HtmlUnitDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys(getSearch());
element.submit();
System.out.println("Page title is: " + driver.getTitle());
System.out.println(driver.getPageSource());
driver.quit();
return "SUCCESS";
}
}
Error :
SEVERE: Exception starting filter struts2
java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:428)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:378)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:495)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:286)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:437)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:193)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:278)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:259)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:383)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:104)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
eagerly waiting for your replies.
Thank You !

Until someone comes along with a better answer... I've never used struts directly but I think I have a basic idea of what it does.
Selenium operates on the front end, as the user would. I believe struts is a back-end only technology, which means that the browser doesn't even know it's receiving something assembled by struts. Struts just helps the server assemble the html, css, and javascript.
Selenium operates well with html, javascript, and css, and since that's what your server is sending out, it should all be good, it should "support it" just fine!

Related

Get Infinispan JMX Statistics from Java

I am new to Infinispan. I am trying to get statistics of cache by my Java code. By googling out, I found out some of the ways but nothing turned out to be a solution for me. Please have a look at the code and please let me know where I am missing.
import java.io.IOException;
import org.infinispan.Cache;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.global.GlobalConfiguration;
import org.infinispan.configuration.global.GlobalConfigurationBuilder;
import org.infinispan.manager.DefaultCacheManager;
public class InfinispanCacheStats {
public static void main(String[] args) throws InterruptedException, IOException {
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder()
.globalJmxStatistics()
.enable()
.build();
Configuration config = new ConfigurationBuilder()
.expiration().wakeUpInterval(5000l).lifespan(1000l).maxIdle(500l)
.build();
config.jmxStatistics().enabled();
DefaultCacheManager m = new DefaultCacheManager(globalConfig, config, true);
// DefaultCacheManager m = new DefaultCacheManager("D:\\infinispan.xml");
Cache<Integer, String> cache = m.getCache();
cache.start();
System.out.println(m.getCache().getAdvancedCache().getStats().getStores());
}
}
I also tried configuring infinispan.xml file and providing it to DefaultCacheManager(), but it produces the following exception
Exception in thread "main" java.util.ServiceConfigurationError: org.infinispan.lifecycle.ModuleLifecycle: Provider org.infinispan.query.impl.LifecycleManager could not be instantiated
at java.util.ServiceLoader.fail(Unknown Source)
at java.util.ServiceLoader.access$100(Unknown Source)
at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
at java.util.ServiceLoader$1.next(Unknown Source)
at org.infinispan.commons.util.ServiceFinder.addServices(ServiceFinder.java:60)
at org.infinispan.commons.util.ServiceFinder.load(ServiceFinder.java:42)
at org.infinispan.util.ModuleProperties.resolveModuleLifecycles(ModuleProperties.java:41)
at org.infinispan.factories.GlobalComponentRegistry.<init>(GlobalComponentRegistry.java:94)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:292)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:271)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:244)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:231)
at com.practice.asrl.infinispan.InfinispanCacheStats.main(InfinispanCacheStats.java:26)
Caused by: java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
... 11 more
Caused by: java.lang.IllegalArgumentException: Logger implementation class org.infinispan.query.logging.Log_$logger has no matching constructor
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2256)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214)
at org.infinispan.util.logging.LogFactory.getLog(LogFactory.java:21)
at org.infinispan.query.impl.LifecycleManager.<clinit>(LifecycleManager.java:82)
... 16 more
Content of infinispan.xml :
<infinispan>
<cache-container statistics="true"/>
</infinispan>
Any help will be appreciated
You need to enable the statistics from the ConfigurationBuilder object. They are disabled by default.
Configuration config = new ConfigurationBuilder()
.expiration().wakeUpInterval(5000l).lifespan(1000l).maxIdle(500l)
.jmxStatistics().enable()
.build();
When you call config.jmxStatistics().enabled(); this will tell you if the statistics are enabled or not, but that won't change the configuration.

After executing code inside #BeforeTest its giving null pointer exception for #Test

After executing the#BeforeTest its showing java.lang.NullPointerException for #Test part.
Error displayed:
Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 34173
Only local connections are allowed.
Sep 08, 2017 10:40:43 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
FAILED CONFIGURATION: #AfterTest Aftertest
java.lang.NullPointerException
at SampleTesting.Test1.Aftertest(Test1.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
at org.testng.TestRunner.afterRun(TestRunner.java:958)
at org.testng.TestRunner.run(TestRunner.java:606)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
FAILED: Test1
java.lang.NullPointerException
at SampleTesting.Test1.Test1(Test1.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================
Code Used
package SampleTesting;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.*;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.Select;
public class NameClassTest {
WebDriver driver;
ChromeOptions options;
#Test
public void Test1() {
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WebElement tabAgreement = driver.findElement(By.xpath("***Value***"));
tabAgreement.click();
WebElement btnNew = driver.findElement(By.xpath("***Value***"));
btnNew.click();
Select lstRecordType = new Select(driver.findElement(By.id***Value***));
lstRecordType.selectByVisibleText("MSA");
WebElement btnContinue = driver.findElement(By.xpath("***Value***"));
btnContinue.click();
WebElement txtAgreementName = driver.findElement(By.xpath("***Value***"));
txtAgreementName.clear();
txtAgreementName.sendKeys("***Value***");
Date date = new Date();
System.out.println("Date is "+ date);
}
#BeforeTest
public void BeforeTest() {
options = new ChromeOptions();
options.addArguments("user-data-dir=C:\\\\Users\\UserName\\AppData\\Local\\Google\\Chrome\\User Data");
String exepath =
"C:\\\\Users\\UserNAme\\Downloads\\chromedriver_win32\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver",exepath);
WebDriver driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("***URL***");
WebElement userName = driver.findElement(By.id("username"));
WebElement password = driver.findElement(By.id("password"));
WebElement btnLogin = driver.findElement(By.id("Login"));
userName.sendKeys("****userName****");
password.sendKeys("****password****");
btnLogin.click();
}
#AfterTest
public void Aftertest() {
WebElement drpUserName = driver.findElement(By.id***Value***);
drpUserName.click();
WebElement lnkLogout = driver.findElement(By.xpath(***Value***));
lnkLogout.click();
driver.close();
}
}
TestNG.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite_SuiteName">
<test name="Test_TestName">
<classes>
<class name="SuiteName.ClassName"/>
</classes>
</test> <!-- Test_TestName -->
</suite> <!-- Suite_SuiteName -->
Its executing the block under #BeforeTest successfully but when its coming to #Test part its giving an error message - Null Pointer exception. I am not sure what mistake I made here in my code.
This is because you have mentioned WebDriver driver = new ChromeDriver(options); in #BeforeMethod annotated method. So your webdriver instance limited for that method only.
So if go in #test annotated method it will find driver not initialized so throw the NullPointerException
Just remove WebDriver from here
#BeforeTest
public void BeforeTest()
{
options = new ChromeOptions();
options.addArguments("user-data-dir=C:\\\\Users\\UserName\\AppData\\Local\\Google\\Chrome\\User Data");
String exepath = "C:\\\\Users\\UserNAme\\Downloads\\chromedriver_win32\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver",exepath);
driver = new ChromeDriver(options); // remove "WebDriver" from this line
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("***URL***");
Let me know if still have issue. Thanks :)
In your #BeforeTest annotated method you have this line
WebDriver driver = new ChromeDriver(options);
This causes your code to shadow out the class level data member and so when your #Test methods try accessing the driver, you hit a NullPointerException.
To fix this, please change WebDriver driver = new ChromeDriver(options); to driver = new ChromeDriver(options); in your #BeforeTest annotated method.
On a side note, I would recommend that you either use one of the following instead of using the #BeforeTest because #BeforeTest methods are called only once per <test> tag. So if you have two test classes which are relying on the #BeforeTest method, then you are again looking at NullPointerException
#BeforeClass - so that the webdriver is instantiated once per test class and is then shared by all the #Test methods in the class. The issue would be that you would need to resort to sequential execution only, because parallel execution can cause test methods to step on each other's shoes.
#BeforeMethod - so that the webdriver is instatiated once for every #Test method. This causes a browser to be spun off for every test method. The flip side of this would be that you would need to use ThreadLocal if you want run the methods in parallel. If sequential execution is fine, then you don't need to do anything extra.
Try creating object of WebDriver outside #BeforeTests
as mentioned below,
public class nameClassTest {
WebDriver driver = new ChromeDriver(options);
#BeforeTest
public void BeforeTest()
{
}
that will resolve your issue.

java.lang.NullPointerException error while running test ng case

I am trying to run this code with TestNG but all it gives me is java.lang.NullPointerException error. Firefox does get opened but after that error comes up. What's going wrong. Please help!
Also is it mandatory to run testNG with XML.
public class GuestCheckout
{
public WebDriver driver ;
public String baseURL = "http://www.google.com";
#BeforeTest
public void setBaseURL(){
WebDriver driver = new FirefoxDriver();
driver.get(baseURL);
}
#Test(priority = 0)
public void EmailPasswordEntry() {
// Entering Email and Password values
driver.findElement(By.id("loginRegister")).click();
WebElement email = driver.findElement(By.id("head_username"));
email.clear();
email.sendKeys("abcd#gmail.com");
WebElement password = driver.findElement(By.id("head_password"));
password.clear();
password.sendKeys("123456");
driver.findElement(By.name("loginsubmit")).click();
}
#Test(priority = 1)
void AssertionVerification() {
// Verifying "My Account" text after login
String bodyText = driver.findElement(By.xpath("//span[#id='loginHeader']/descendant::a[text()='My Account']")).getText();
Assert.assertTrue(bodyText.contains("My Accountii"), "Not matched");
}
}
Error:
--------
FAILED: EmailPasswordEntry
java.lang.NullPointerException
at package_1.GuestCheckout.EmailPasswordEntry(GuestCheckout.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
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 `enter code here`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:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
and same for the second Test method
Since you have instantiated WebDriver in local way and trying use that as a global instance so you are getting Null Pointer Exception. Do this in this way:
public WebDriver driver ;
public String baseURL = "http://www.ggolge.com";
#BeforeTest
public void setBaseURL(){
driver = new FirefoxDriver(); // Now this is a global instance for this class
driver.get(baseURL);
}
#Test(priority = 0)
public void EmailPasswordEntry() {
// Entering Email and Password values
driver.findElement(By.id("loginRegister")).click();
WebElement email = driver.findElement(By.id("head_username"));
email.clear();
email.sendKeys("abcd#gmail.com");
WebElement password = driver.findElement(By.id("head_password"));
password.clear();
password.sendKeys("123456");
driver.findElement(By.name("loginsubmit")).click();
}
#Test(priority = 1)
void AssertionVerification() {
// Verifying "My Account" text after login
String bodyText = driver.findElement(By.xpath("//span[#id='loginHeader']/descendant::a[text()='My Account']")).getText();
Assert.assertTrue(bodyText.contains("My Accountii"), "Not matched");
}
No it is not mandatory to run using TestNg xml, if you are using some intelligent IDE like Eclipse then you can run your tests without xml.
XMLs are beneficial when you have multiple classes to run all together as a suite.
since using webdriver... try using public static
public static webdriver driver
in each class files

Jetty HttpClientTransportOverHTTP2 with SSL

I am trying to make a simple GET request using Jetty's HttpClientTransportOverHTTP2, but it fails. Here is my code:
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http2.client.HTTP2Client;
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.util.ssl.SslContextFactory;
public class JettyClientExample {
public static void main(String[] args) throws Exception {
HttpClientTransportOverHTTP2 clientTransport = new HttpClientTransportOverHTTP2(new HTTP2Client());
HttpClient client = new HttpClient(clientTransport, new SslContextFactory(true));
client.start();
ContentResponse response = client.GET("https://http2.akamai.com");
System.out.println("Version: " + response.getVersion());
System.out.println("Status: " + response.getStatus());
System.out.println("Content: " + response.getContentAsString());
}
}
And here is the Exception I get in the line client.GET("https://http2.akamai.com")
Exception in thread "main" java.util.concurrent.ExecutionException: java.nio.channels.ClosedChannelException
at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118)
at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:101)
at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:653)
at org.eclipse.jetty.client.HttpClient.GET(HttpClient.java:343)
at org.eclipse.jetty.client.HttpClient.GET(HttpClient.java:328)
at de.consol.labs.h2c.examples.client.okhttp.JettyClientExample.main(JettyClientExample.java:15)
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:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.nio.channels.ClosedChannelException
at org.eclipse.jetty.http2.HTTP2Session.onShutdown(HTTP2Session.java:779)
at org.eclipse.jetty.http2.HTTP2Connection$HTTP2Producer.produce(HTTP2Connection.java:181)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:162)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.execute(ExecuteProduceConsume.java:101)
at org.eclipse.jetty.http2.HTTP2Connection.onOpen(HTTP2Connection.java:80)
at org.eclipse.jetty.http2.client.HTTP2ClientConnectionFactory$HTTP2ClientConnection.onOpen(HTTP2ClientConnectionFactory.java:105)
at org.eclipse.jetty.io.ssl.SslConnection.onOpen(SslConnection.java:152)
at org.eclipse.jetty.io.ClientConnectionFactory$Helper.open(ClientConnectionFactory.java:70)
at org.eclipse.jetty.io.ClientConnectionFactory$Helper.replaceConnection(ClientConnectionFactory.java:63)
at org.eclipse.jetty.io.NegotiatingClientConnection.replaceConnection(NegotiatingClientConnection.java:113)
at org.eclipse.jetty.io.NegotiatingClientConnection.onFillable(NegotiatingClientConnection.java:89)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:245)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:192)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:245)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
I am using version 9.3.3.v20150827, and I put the ALPN JAR into my boot classpath with -Xbootclasspath/p:<path>.
For some reason, I didn't find any working example of HttpClientTransportOverHTTP2 with SSL on the Internet.
What am I missing?
You hit this bug, which is fixed in Jetty 9.3.4.

Encountering error: java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList$Builder

I'm new to Selenium WebDriver using EclipseIDE with TestNG. I'm currently running this sample code in Eclipse via TestNG:
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import java.util.List;
public class CheesecakeFactory {
FirefoxDriver driver;
#BeforeTest
public void startDriver() {
driver = new FirefoxDriver();
}
#AfterTest
public void stopDriver() {
driver.close();
}
#Test
public void listCheesecakes() {
driver.get("http://www.thecheesecakefactory.com/");
driver.findElement(By.linkText("Menu")).click();
driver.findElement(By.linkText("Cheesecake")).click();
List<WebElement> cheesecakes = driver.findElements(By.xpath("id('leftNav_levelTwo')//li"));
System.out.println(cheesecakes.size() + " cheesecakes:");
for (int i=0; i<cheesecakes.size(); i++) {
System.out.println(i+1 + ". " + cheesecakes.get(i).getText());
}
}
}
But Eclipse returns this:
[TestNG] Running:
C:\Users\ryan\AppData\Local\Temp\testng-eclipse--616826937\testng-customsuite.xml
FAILED CONFIGURATION: #BeforeTest startDriver
java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList$Builder
at org.openqa.selenium.os.WindowsUtils.getPathsInProgramFiles(WindowsUtils.java:275)
at org.openqa.selenium.firefox.internal.Executable.locateFirefoxBinaryFromPlatform(Executable.java:148)
at org.openqa.selenium.firefox.internal.Executable.<clinit>(Executable.java:25)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:78)
at CheesecakeFactory.startDriver(CheesecakeFactory.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.TestRunner.beforeRun(TestRunner.java:641)
at org.testng.TestRunner.run(TestRunner.java:609)
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:1197)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1122)
at org.testng.TestNG.run(TestNG.java:1030)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
I don't understand why I'm getting this error. I've done the following:
Added the guava-12.0.jar file (along with the other jar files in the Selenium-2.25.0 webdriver) as an external jar file in Eclipse. (This jar file contains the ImmutableList$Builder class)
Added the path of this jar file in the CLASSPATH (Environment Variables>System Variables)
Am I missing something? Any help is greatly appreciated.
I guess you are using selenium-java-2.25.0.jar. You should rather use selenium-server-standalone-2.25.0.jar, it will take care of all the dependencies (i.e. required jar files).
Also you dont need to explicitly define the environment variables if the jar files are added in the Eclipse, unless you are running the test outside from eclipse.
Hope this helps... :)