In one of our project we starting long time jobs on remote nodes. Those jobs sometimes can take few hours.
We've used old version some application which uses old version of Selenium WebDriver. And it works perfectly many years.
Now we've switched to new version of those application which uses new version of selenium WebDriver. And it stop to work.
I've reviewed all stack trace and see issue in class
org.openqa.selenium.remote.server.WebDriverServlet
When you execute any executor you hardcoded timeout for 10 minutes.
try {
execution.get(10, MINUTES);
} catch (ExecutionException e) {
resp.reset();
JeeInterop.execute(new ExceptionHandler(e), req, resp);
} catch (InterruptedException e) {
logger.log(Level.WARNING, "Unexpectedly interrupted: " + e.getMessage(), e);
invalidateSession = true;
Thread.currentThread().interrupt();
} catch (TimeoutException e) {
invalidateSession = true;
}
This is exactly what I'm seeing in our new application. I trying to set any timeout, but it closed session in 10 minutes.
Could you please explain why you do this?
Seems this is a bug.
Do you know any workaround to make it works?
Sincerely
Related
I use HttpAysnClient to do http requests, and I found when I throw an exception in the failed callback, the next request always be failed, how to fix it?
I use maven dependency: 'org.apache.httpcomponents:httpasyncclient:4.1.5'.
my java test code:
CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
try {
httpclient.start();
AtomicBoolean fireException = new AtomicBoolean(false);
while (true) {
try {
String url;
if (fireException.compareAndSet(false, true)) {
url = "http://localhost:8080"; // throw Connection refused
} else {
url = "http://www.apache.org/";
}
final HttpGet request2 = new HttpGet(url);
httpclient.execute(request2, new FutureCallback<HttpResponse>() {
public void completed(final HttpResponse response2) {
System.out.println("completed, " + request2.getRequestLine() + "->" + response2.getStatusLine());
}
public void failed(final Exception ex) {
System.out.println("failed, " + request2.getRequestLine() + "->" + ex);
throw new RuntimeException();
}
public void cancelled() {
System.out.println(request2.getRequestLine() + " cancelled");
}
});
TimeUnit.SECONDS.sleep(1);
} catch (Exception e) {
e.printStackTrace();
TimeUnit.SECONDS.sleep(1);
}
}
} finally {
httpclient.close();
}
exception in the next requests: java.util.concurrent.CancellationException: Request execution cancelled
I can confirm same behavior with version 4.1.5.
I must confess it is quite surprising to see an application uncontrolled exception shutting down the whole client unexpectedly. In the context of an application reusing same client instance in multiple places, means the application client gets completely unsuable, with catastrophic consequences for the service.
You can use the "isRunning" method to evaluate if the client is under this situation, and potentially try to recreate the client again. But it is definately incovenient to see the client being shutdown like this.
After exercising the client with different conditions (error responses, slow responses...), the only way to reproduce this is to point to an invalid endpoint where no server is running. This is the condition presented in the original example.
I think I found the issue here https://jar-download.com/artifacts/org.apache.httpcomponents/httpasyncclient/4.1.5/source-code/org/apache/http/impl/nio/client/InternalIODispatch.java
You can see onException doesn't have a try/catch block to properly handle exceptions from the application.
I have confirmed this issue is fixed in Httpclient5 5.1.3. So other than fixing your application code to avoid uncontrolled exceptions, the solution is to migrate into the new Httpclient5 lib version.
you can see doc in https://hc.apache.org/httpcomponents-client-5.1.x/migration-guide/migration-to-async-simple.html
and if you want to use CloseableHttpClient you must start it client.start();
I understand that this is a RuntimeException but for my usecase I need to catch it and set some attributes.
Context: I am using JPA EntityListeners for auditing and everything works fine when user accesses the application. The problem occurs when the application is accessed remotely using RemoteEJB. I am using a session object (Credentials which captures the user) in the EntityListener, so when the call is from RemoteEJB and because there is no session it fails as expected. This is the only exception I anticipate so I want to catch it and hardcode the auditing in this RemoteEJB accessing case. But somehow I am not able to catch it. I tried to catch javax.enterprise.context.ContextNotActiveException but to no avail.
public class CreateListener {
#Inject #Named("credentials") private Credentials credentials;
#PrePersist
public void setCreateAttributes(Auditable entity){
try {
entity.setCreateUserName(credentials.getUserName());
} catch (RuntimeException e) {
entity.setCreateUserName("RemoteEJB");
}
entity.setCreateTmstmp(new Date());
}
}
Environment: JDK 1.8, JBOSS EAP 7.1, hibernate-jpa-2.1-api, Hibernate 5.2.12.Final
Any help of alternative approach is appreciated.
TIA
-Avi
How do I change this exception within my automated tests:
The HTTP request to the remote WebDriver server for URL http://localhost:2064/session/dfc2b7dfad0d464f95f5bbd4d8081580/element/0.10309002696750724-127/element timed out after 60 seconds.
Whenever my tests fail, I get the exception above. The reason why it does fail, however, is because it cannot find a specific element. Whenever it cannot find an element it throws the exception. How do I get around this to throw an exception that the user would understand? What is the best way to deal with situations where an exception is thrown everytime it cannot find an element on the page?
You could write a wrapper around the find_element call to catch the error and return something else instead.
Use try - catch block to wait for the element.
try {
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By
.className("sessionHeader")));
} catch (NoSuchElementException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
}
I am working on Eclipse plugin and for that I have need of communication with the console.
I have developed the console using this:
public void openConsole() {
MyConsole = createConsole1();
}
private IOConsole createConsole1() {
//creating a console with title Welcome to SoC Console.
IOConsole ioconsole = new IOConsole("Welcome to my Console.",null);
//adding created console to console list in console view.
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {ioconsole});
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(ioconsole);
IOConsoleOutputStream OPstream = ioconsole.newOutputStream();
try {
OPstream.write("myConsole>");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But after deploying it none of the console is visible in my plugin and message shows this:
No console to display at this time.
Now I need to open my console when I open the plugin instead of this.
help me if anyone know this.
Least help by you may help me a lot so please help.
I'm using SoapUI 4.0 and i'm starting my mockservices via SoapUI API :
public static void startMockServices(String soapuiProject) throws Exception
{
WsdlProject proj = new WsdlProject(soapuiProject);
List<MockService> mockList = proj.getMockServiceList();
for (MockService mockService : mockList) {
mockService.addMockRunListener(new LogListener());
mockService.start();
}
}
public static void finishMocks() {
SoapUI.getThreadPool().shutdown();
try {
SoapUI.getThreadPool().awaitTermination(5l, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
SoapUI.shutdown();
}
The MockServices start well, but when I try to tear them down, the thread where jetty is running is still hanging up and my process does not finish.
I've tried to stop it via MockRunner.stop() as well but the thread still does not stop as well.
Is there any way I can stop the jetty thread so that my process finishes?
I know, better late than never.
On SoapUi 5.x.x, in the setting file, set the
con:setting id="HttpSettings#leave_mockengine to false!
In java, after, on the runner, you can set the settings file :)