Not able to create a java8 neo4j hello world example - java-8

I have to integrate into a current java8 container some limited neo4j functionality but I'm not able to build a simple hello world example.
Created a simple demo app
gradle init \
--project-name neo-question \
--type java-application \
--package neo.question \
--test-framework junit \
--dsl groovy
I have added source and target compatibility with java 8 and also a dependency to the org.neo4j.driver:neo4j-java-driver:1.7.6 and this is how my build.gradle looks like
plugins {
id 'application'
}
sourceCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
jcenter()
}
dependencies {
testImplementation 'junit:junit:4.13'
implementation 'com.google.guava:guava:29.0-jre'
implementation 'org.neo4j.driver:neo4j-java-driver:1.7.6'
}
application {
mainClass = 'neo.question.App'
}
This is how I start my neo docker to perform this test and I can connect to it from a java11 compatible code
docker run \
--name testneo4j \
-p7474:7474 -p7687:7687 \
-d \
-v $HOME/neo4j/data:/data \
-v $HOME/neo4j/logs:/logs \
-v $HOME/neo4j/import:/var/lib/neo4j/import \
-v $HOME/neo4j/plugins:/plugins \
--env NEO4J_dbms_security_auth__minimum__password__length=4 \
--env NEO4J_AUTH=neo4j/test \
neo4j:latest
I'm using this example for 1.7.6 driver on how to connect: 1.7.6 overview
This is my java8 HelloWorldExample.Java class
package neo.question;
import org.neo4j.driver.v1.*;
import static org.neo4j.driver.v1.Values.parameters;
public class HelloWorldExample implements AutoCloseable{
private final Driver driver;
public HelloWorldExample(String uri, String user, String password )
{
driver = GraphDatabase.driver( uri, AuthTokens.basic( user, password ) );
}
#Override
public void close() throws Exception
{
driver.close();
}
public void printGreeting( final String message )
{
try ( Session session = driver.session() )
{
String greeting = session.writeTransaction( new TransactionWork<String>()
{
#Override
public String execute( Transaction tx )
{
StatementResult result = tx.run( "CREATE (a:Greeting) " +
"SET a.message = $message " +
"RETURN a.message + ', from node ' + id(a)",
parameters( "message", message ) );
return result.single().get( 0 ).asString();
}
} );
System.out.println( greeting );
}
}
public static void main( String... args ) throws Exception
{
try ( HelloWorldExample greeter = new HelloWorldExample( "bolt://localhost:7687", "neo4j", "test" ) )
{
greeter.printGreeting( "hello, world" );
}
}
}
When I try to run the HelloWorldExample this is what I get
Jan 10, 2023 11:11:03 AM org.neo4j.driver.internal.logging.JULogger info
INFO: Direct driver instance 1113619023 created for server address localhost:7687
Jan 10, 2023 11:11:04 AM org.neo4j.driver.internal.logging.JULogger info
INFO: Closing connection pool towards localhost:7687
Exception in thread "main" org.neo4j.driver.v1.exceptions.ServiceUnavailableException: Connection to the database terminated. This can happen due to network instabilities, or due to restarts of the database
at org.neo4j.driver.internal.util.Futures.blockingGet(Futures.java:123)
at org.neo4j.driver.internal.DriverFactory.verifyConnectivity(DriverFactory.java:349)
at org.neo4j.driver.internal.DriverFactory.newInstance(DriverFactory.java:95)
at org.neo4j.driver.v1.GraphDatabase.driver(GraphDatabase.java:141)
at org.neo4j.driver.v1.GraphDatabase.driver(GraphDatabase.java:124)
at org.neo4j.driver.v1.GraphDatabase.driver(GraphDatabase.java:99)
at neo.question.HelloWorldExample.<init>(HelloWorldExample.java:12)
at neo.question.HelloWorldExample.main(HelloWorldExample.java:43)
Suppressed: org.neo4j.driver.internal.util.ErrorUtil$InternalExceptionCause
at org.neo4j.driver.internal.util.ErrorUtil.newConnectionTerminatedError(ErrorUtil.java:50)
at org.neo4j.driver.internal.async.HandshakeHandler.channelInactive(HandshakeHandler.java:81)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:262)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:248)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:241)
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:392)
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:357)
at org.neo4j.driver.internal.shaded.io.netty.handler.ssl.SslHandler.channelInactive(SslHandler.java:1074)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:262)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:248)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:241)
at org.neo4j.driver.internal.shaded.io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:81)
at org.neo4j.driver.internal.shaded.io.netty.handler.timeout.IdleStateHandler.channelInactive(IdleStateHandler.java:277)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:262)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:248)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:241)
at org.neo4j.driver.internal.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:262)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:248)
at org.neo4j.driver.internal.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:813)
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at org.neo4j.driver.internal.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
> Task :app:HelloWorldExample.main() FAILED

Related

Unable to load a resource from a different jar file than my springboot jar from the commandline but it works in eclipse

I have three projects and three jar files.
My springboot project has a dependency on two other projects.
When I run the application within eclipse, by going to the main class within the springboot application everything is fine.
When I try to run the app with
java -jar target/springbootproj.jar
It fails with
java.lang.IllegalArgumentException: illegal path sql/h2/h2_full.sql
The offending line is
public static String getClassLoaderResourceAsString(String path) {
InputStream is = getClassLoaderResourceAsStream(path);
String retval;
try {
retval = new String(is.readAllBytes());
} catch (IOException e) {
throw new RuntimeException("unable to read resource '" + path + "' " + e.getMessage());
}
return retval;
}
I can see the resource file in my Springboot jar if I extract the dependent jar fie
jar xvf target/vend-web-22.1.0-SNAPSHOT.jar BOOT-INF/lib/core
and then look in the extracted jar, this inter project resource loading works for me very well, until I create a springboot jar.
This runs just fine within Eclipse but fails when I run the springboot jar, built with maven from the commandline with
java -jar springboot-webapp.jar
Trying this:
#Component
#SpringBootApplication
#EnableConfigurationProperties(StorageProperties.class)
public class UploadingFilesApplication {
#Autowired
private ResourceLoader resourceLoader;
#Value("classpath:joblogger/postgresql/joblog_schema.sr.sql")
private Resource joblogResource;
public static void main(String[] args) {
SpringApplication.run(UploadingFilesApplication.class, args);
}
#Bean
CommandLineRunner init(StorageService storageService) {
System.out.println("resourceLoader is " + resourceLoader);
System.out.println("joblogResource is " + joblogResource);
try {
String ddl Files.readString(Paths.get(joblogResource.getURI()), StandardCharsets.UTF_8);
results in
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.CommandLineRunner]: Factory method 'init' threw exception; nested exception is java.nio.file.FileSystemNotFoundException
Getting closer
I wrote the following
package org.webapp
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.springframework.util.ResourceUtils;
public class ResourceGetter {
public static String loadResource(String resourceName) {
try {
File file = ResourceUtils.getFile("classpath:" + resourceName);
return FileUtils.readFileToString(file,"UTF-8");
} catch (IOException e) {
throw new RuntimeException(e) ;
}
}
}
And I get
Caused by: java.io.FileNotFoundException: class path resource [/joblogger/postgresql/joblog_schema.sr.sql] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/home/jjs/git/diamond-9.5/javautil/vendweb/target/vend-web-22.1.0-SNAPSHOT.jar!/BOOT-INF/lib/javautil-core-22.1.0-SNAPSHOT.jar!/joblogger/postgresql/joblog_schema.sr.sql
But it appears to be there.
jar xvf target/vend-web-22.1.0-SNAPSHOT.jar BOOT-INF/lib/javautil-core-22.1.0-SNAPSHOT.jar
extracted: BOOT-INF/lib/javautil-core-22.1.0-SNAPSHOT.jar
jar tvf BOOT-INF/lib/javautil-core-22.1.0-SNAPSHOT.jar joblogger/postgresql/joblog_schema.sr.sql
4107 Tue Mar 29 16:33:22 EDT 2022 joblogger/postgresql/joblog_schema.sr.sql
enter code here

EJB Corba Marshalling Exception

We work with a Websphere cluster with two apps in it (app1 and app2). I can call EJBs from both apps from my local spring boot out of Intellij-Idea.
When I deploy the spring boot application to the companies private openshift cloud then there is a marshalling exception in one of the two services (client side) talking to one of the websphere apps.
#Service
public class App1BookingsManagementService implements EjbService<DomainFacade> {
private static final String DOMAINFACADE_EJB_NAME = "ejb/org/company/app/DomainFacade";
private static final Logger LOG = LoggerFactory.getLogger(App1BookingsManagementService.class);
#Autowired
private InitialContext initialContext;
public List<BookingDataRow> getBookingsToday() {
DomainFacade domainFacade = null;
try {
domainFacade = createEjbStub();
BookingSelektionskriterien selektionskriterien = new BookingSelektionskriterien();
selektionskriterien.setTerminFrom(valueOf(now()));
selektionskriterien.setTerminUntil(valueOf(now().plusDays(1)));
ResultList<BookingDataRow> resultList = domainFacade.sucheBookingsDataRows(selektionskriterien);
if (resultList == null) {
LOG.warn("Error in EJB {} from APP1 returned null. ", DOMAINFACADE_EJB_NAME);
}
LOG.info("Calling EJB sucheBookingsDataRows returned {} results. ", resultList.getList().size());
return resultList.getList();
} catch (NamingException | CreateException | RemoteException | DomainException e) {
LOG.error("Error in calling EJB {} from APP1: {}, {}", DOMAINFACADE_EJB_NAME, e.getClass().getName(), e.getMessage());
} finally {
if (domainFacade != null) {
try {
domainFacade.remove();
} catch (RemoteException | RemoveException e) {
LOG.error("could not remove ejb {}", DOMAINFACADE_EJB_NAME, e);
}
}
}
return Collections.emptyList();
}
public DomainFacade createEjbStub() throws NamingException, RemoteException, CreateException {
Object stub = initialContext.lookup(DOMAINFACADE_EJB_NAME);
DomainFacadeHome facadeHome = (DomainFacadeHome) PortableRemoteObject.narrow(stub, DomainFacadeHome.class);
return facadeHome.create();
}
}
Here the config:
#Configuration
public class CorbaConfig {
#Value("${corba-location}")
private String corbaLocation;
#Value("classpath:sas.client.props")
private Resource sasClientProps;
#Bean
public InitialContext corbaContext() throws NamingException, IOException {
Hashtable<String, Object> env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(PROPS.HOSTNAME_NORMALIZER, PROPS.HOSTNAME_NORMALIZER_NONE);
env.put("com.ibm.CORBA.ConfigURL", sasClientProps.getInputStream());
env.put(Context.PROVIDER_URL, corbaLocation);
return new InitialContext(env);
}
#Bean
public MBeanServer mbeanServer() {
MBeanServerFactoryBean factory = new MBeanServerFactoryBean();
factory.setLocateExistingServerIfPossible(true);
factory.afterPropertiesSet();
return factory.getObject();
}
}
This is the error I see in openshift:
2021-02-04 08:14:53,714 [ERROR] P=891120:O=0:CT appname=app-ejbcall corid= c.s.n.e.s.App1BookingsManagementService: Error in calling EJB ejb/org/company/app/DomainFacade from APP1: java.rmi.MarshalException, CORBA MARSHAL 0x4942f89a No; nested exception is:
org.omg.CORBA.MARSHAL:
>> SERVER (id=431c9d95, host=was.company.org) TRACE START:
>> org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : Default data must be read first vmcid: IBM minor code: 89A completed: No
>> at com.ibm.rmi.iiop.CDRReader.read_value(CDRReader.java:1644)
>> at com.ibm.rmi.iiop.EncoderInputStream.read_value(EncoderInputStream.java:970)
>> at org.company.app.Domain.ejb.facade._EJSRemoteStatelessDomainFacade_a1729579_Tie.sucheBookingenDataRows(Unknown Source)
>> at org.company.app.Domain.ejb.facade._EJSRemoteStatelessDomainFacade_a1729579_Tie._invoke(Unknown Source)
>> at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:638)
>> at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:508)
>> at com.ibm.rmi.iiop.ORB.process(ORB.java:613)
>> at com.ibm.CORBA.iiop.ORB.process(ORB.java:1584)
>> at com.ibm.rmi.iiop.Connection.doRequestWork(Connection.java:3190)
>> at com.ibm.rmi.iiop.Connection.doWork(Connection.java:3051)
>> at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:64)
>> at com.ibm.ws.giop.threadpool.WorkQueueElement.dispatch(WorkQueueElement.java:174)
>> at com.ibm.ws.giop.filter.GiopFilterChain.processMessage(GiopFilterChain.java:203)
>> at com.ibm.ws.giop.threadpool.PooledThread.handleRequest(PooledThread.java:81)
>> at com.ibm.ws.giop.threadpool.PooledThread.run(PooledThread.java:102)
>> at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)
>> SERVER (id=431c9d95, host=was.company.org) TRACE END.
vmcid: IBM minor code: 89A completed: No
Locally there is no problem talking to the same websphere server. One guess was the RMI stub is not the same but then it would be also a problem locally, no?
App 1
App 2
Local Spring Boot run in IDE
OK
OK
Deployt in Openshift Cloud
OK
NOK
The problem was that I configured the build with jdk-8 but at runtime the jre was set to version 11.
So I had to find the internal configuration for the correct docker file to use java 8.

java.io.IOException: Timed out waiting for Mini HDFS Cluster to start

I am getting timeout exception while trying to start the Hbase mini cluster. Further I want to write a hbase test case but currently its failing for hadoop 3.1.1 and hbase 2.0.2 combination.
1) Have tried with all the version of > = 3.1.1 and hbase >=2.0.0
2) Have taken code from https://github.com/apache/hbase/blob/rel/2.0.2/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java
and
https://github.com/apache/ranger/blob/master/hbase-agent/src/test/java/org/apache/ranger/authorization/hbase/HBaseRangerAuthorizationTest.java
import java.net.ServerSocket;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
public class HBaseRangerAuthorizationTest2 {
private static int port;
private static HBaseTestingUtility utility;
public static void main(String args[]) {
try {
port = getFreePort();
utility = new HBaseTestingUtility();
utility.getConfiguration().set("test.hbase.zookeeper.property.clientPort", "" + port);
utility.getConfiguration().set("hbase.master.port", "" + getFreePort());
utility.getConfiguration().set("hbase.master.info.port", "" + getFreePort());
utility.getConfiguration().set("hbase.regionserver.port", "" + getFreePort());
utility.getConfiguration().set("hbase.regionserver.info.port", "" + getFreePort());
utility.getConfiguration().set("zookeeper.znode.parent", "/hbase-unsecure");
utility.startMiniCluster();
/*
utility= new HBaseTestingUtility();
// Set a different zk path for each cluster
utility.getConfiguration().set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
utility.startMiniZKCluster();
utility.startMiniCluster();*/
}catch(Exception e) {
e.printStackTrace();
}
}
public static int getFreePort() throws IOException {
ServerSocket serverSocket = new ServerSocket(0);
int port = serverSocket.getLocalPort();
serverSocket.close();
return port;
}
}```
I expect the mini server should start without fail.
I am using hadoop version 2.7.3 and hbase version 1.1.2
For timeout exception, add the hadoop-client dependency to your gradle file:
compile 'org.apache.hadoop:hadoop-client:2.7.3'
Further check if you have added the dependency:
compile 'org.apache.hbase:hbase-testing-util:1.1.2'

Flink- error on running WordCount example on remote cluster

I have a Flink Cluster on VirtualBox incliding three node, 1 master and 2 slaves. I customized WordCount example and create a fat jar file to run it using VirtualBox Flink remote cluster, But I faced Error.
Notice: I imported dependencies manually to the project(using Intellij IDEA) and I didn't use maven as dependency provider. I test my code on local machine and it was OK!
More details are following:
Here is my Java code:
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.util.Collector;
public class WordCount {
// *************************************************************************
// PROGRAM
// *************************************************************************
public static void main(String[] args) throws Exception {
final ParameterTool params = ParameterTool.fromArgs(args);
final int port;
final String ip;
DataSet<String> text;
try {
ip = params.get("ip");
port = params.getInt("port");
final ExecutionEnvironment env = ExecutionEnvironment.createRemoteEnvironment(ip, port, 2);
text = env.readTextFile(params.get("input"));
} catch (Exception e) {
System.err.println("No port or input or ip specified. Please run 'SocketWindowWordCount --ip <ip> --port <port>'" +
" --input <input>");
return;
}
DataSet<Tuple2<String, Integer>> counts =
// split up the lines in pairs (2-tuples) containing: (word,1)
text.flatMap(new Tokenizer())
// group by the tuple field "0" and sum up tuple field "1"
.groupBy(0)
.sum(1);
System.out.println("Printing result to stdout. Use --output to specify output path.");
counts.print();
}
// *************************************************************************
// USER FUNCTIONS
// *************************************************************************
/**
* Implements the string tokenizer that splits sentences into words as a user-defined
* FlatMapFunction. The function takes a line (String) and splits it into
* multiple pairs in the form of "(word,1)" ({#code Tuple2<String, Integer>}).
*/
public static final class Tokenizer implements FlatMapFunction<String, Tuple2<String, Integer>> {
#Override
public void flatMap(String value, Collector<Tuple2<String, Integer>> out) {
// normalize and split the line
String[] tokens = value.toLowerCase().split("\\W+");
// emit the pairs
for (String token : tokens) {
if (token.length() > 0) {
out.collect(new Tuple2<String, Integer>(token, 1));
}
}
}
}
}
I created ExecutionEnvironment object using command:
final ExecutionEnvironment env = ExecutionEnvironment.createRemoteEnvironment(ip, port, 2);
, And I run the code using the following command on host machine(that is connected to the cluster nodes and VirtualBox is running on that)
java -cp FlinkWordCountClusetr.jar WordCount --ip 192.168.101.10 --port 6123 --input /usr/local/flink/LICENSE
, But I faced the following error(in summarized):
Exception in thread "main" org.apache.flink.client.program.ProgramInvocationException: Could not start the ActorSystem needed to talk to the JobManager.
Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.remote.log-received-messages'
How can I fix that?
After trying many settings, it was all about maven dependencies was not matching Flink version installed on the remote cluster. Maven dependencies were Flink version 1.3.2 build on Scala 2.10, while Flink installed on the remote cluster was 1.3.2 build on Scala 2.11. Just a minor difference but important!

Error running mvn with selenium test

I'm new using Selenium and I find a problem after running mvn verify with my test included in my code. I'm using Java Junit with webdriver.
Here is my test code:
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class SeleniumTest {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "/home/francop/Downloads/geckodriver");
WebDriver driver = new FirefoxDriver();
driver.get("http://localhost:8448/login");
driver.quit();
}
#Before
public void setUp() throws Exception {
System.setProperty("webdriver.gecko.driver", "/home/francop/Downloads/geckodriver");
driver = new FirefoxDriver();
baseUrl = "http://localhost:8448/login";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
#Test
public void testSelenium() throws Exception {
driver.get(baseUrl);
driver.findElement(By.name("username")).clear();
driver.findElement(By.name("username")).sendKeys("dbaranowski");
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys("dbaranowski");
driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
driver.findElement(By.id("searchBtn")).click();
driver.findElement(By.id("icon")).click();
driver.findElement(By.id("filter-button")).click();
driver.findElement(By.id("clear-button")).click();
driver.findElement(By.id("filter-button")).click();
driver.findElement(By.id("clear-button")).click();
driver.findElement(By.id("input")).click();
driver.findElement(By.xpath("//div[#id='contentWrapper']/div/paper-listbox/paper-item")).click();
driver.findElement(By.id("filter-button")).click();
driver.findElement(By.id("scrim")).click();
driver.findElement(By.xpath("(//input[#value='MORON '])[4]")).click();
driver.findElement(By.cssSelector("#infoBtn > #icon")).click();
driver.findElement(By.xpath("//paper-dialog[#id='affectedClientsDetail']/div[5]/paper-button[3]")).click();
driver.findElement(By.xpath("(//input[#value='MORON '])[16]")).click();
driver.findElement(By.cssSelector("#infoBtn > #icon")).click();
driver.findElement(By.id("insertClientBtn")).click();
driver.findElement(By.xpath("//vaadin-grid[#id='grid']/div/div[3]")).click();
driver.findElement(By.xpath("(//input[#value='MORON '])[13]")).click();
driver.findElement(By.cssSelector("#infoBtn > #icon")).click();
driver.findElement(By.xpath("//vaadin-grid[#id='grid']/div/div[3]")).click();
driver.findElement(By.xpath("(//input[#value='MORON '])[16]")).click();
driver.findElement(By.cssSelector("#infoBtn > #icon")).click();
driver.findElement(By.id("insertClientBtn")).click();
driver.findElement(By.xpath("//vaadin-grid[#id='grid']/div/div[3]")).click();
driver.findElement(By.xpath("(//input[#value='MORON '])[13]")).click();
driver.findElement(By.cssSelector("#infoBtn > #icon")).click();
driver.findElement(By.id("infoBtn")).click();
driver.findElement(By.id("insertClientBtn")).click();
driver.findElement(By.xpath("(//input[#id='input'])[13]")).clear();
driver.findElement(By.xpath("(//input[#id='input'])[13]")).sendKeys("0387722559");
driver.findElement(By.xpath("(//iron-icon[#id='icon'])[32]")).click();
driver.findElement(By.xpath("//iron-collapse[#id='collapse1']/div[2]/paper-button")).click();
driver.findElement(By.id("modifyInt")).click();
driver.findElement(By.xpath("//paper-dialog[#id='affectedClientsDetail']/div[3]/paper-button")).click();
driver.findElement(By.cssSelector("#exportBtn > #icon")).click();
driver.findElement(By.cssSelector("body.layout.vertical > #exportDialog > div.buttons > paper-button.x-scope.paper-button-0")).click();
driver.findElement(By.cssSelector("#selection-button > #icon")).click();
driver.findElement(By.xpath("//button[#type='button']")).click();
driver.findElement(By.id("gwt-uid-3")).click();
driver.findElement(By.id("gwt-uid-4")).click();
driver.findElement(By.id("gwt-uid-5")).click();
driver.findElement(By.id("gwt-uid-6")).click();
driver.findElement(By.id("gwt-uid-7")).click();
driver.findElement(By.id("gwt-uid-8")).click();
driver.findElement(By.id("gwt-uid-9")).click();
driver.findElement(By.cssSelector("#gwt-uid-10 > span.v-on > div")).click();
driver.findElement(By.id("gwt-uid-11")).click();
driver.findElement(By.id("gwt-uid-12")).click();
driver.findElement(By.id("gwt-uid-13")).click();
driver.findElement(By.cssSelector("#gwt-uid-14 > span.v-on > div")).click();
driver.findElement(By.cssSelector("#gwt-uid-15 > span.v-on > div")).click();
driver.findElement(By.cssSelector("#gwt-uid-16 > span.v-on > div")).click();
driver.findElement(By.id("gwt-uid-16")).click();
driver.findElement(By.id("gwt-uid-15")).click();
driver.findElement(By.id("gwt-uid-14")).click();
driver.findElement(By.id("gwt-uid-13")).click();
driver.findElement(By.id("gwt-uid-12")).click();
driver.findElement(By.xpath("//button[#type='button']")).click();
driver.findElement(By.cssSelector("#copy-button > #icon")).click();
driver.findElement(By.id("gwt-uid-47")).click();
driver.findElement(By.cssSelector("label.vaadin-grid.style-scope")).click();
driver.findElement(By.cssSelector("#selection-button > #icon")).click();
driver.findElement(By.id("icon")).click();
driver.findElement(By.xpath("//div[#id='tabsContent']/paper-tab[2]/div")).click();
driver.findElement(By.id("icon")).click();
driver.findElement(By.id("paperToggle")).click();
driver.findElement(By.xpath("//div[#id='tabsContent']/paper-tab[2]/div")).click();
driver.findElement(By.id("paperToggle")).click();
driver.findElement(By.xpath("(//div[#id='checkboxContainer'])[23]")).click();
driver.findElement(By.xpath("(//iron-icon[#id='icon'])[10]")).click();
driver.findElement(By.xpath("(//div[#id='buttons']/paper-checkbox)[3]")).click();
driver.findElement(By.xpath("(//div[#id='buttons']/paper-checkbox)[2]")).click();
driver.findElement(By.xpath("(//div[#id='checkboxContainer'])[20]")).click();
driver.findElement(By.xpath("(//iron-icon[#id='icon'])[9]")).click();
driver.findElement(By.xpath("//div[#id='tabsContent']/paper-tab/div")).click();
driver.findElement(By.id("filter-button")).click();
driver.findElement(By.id("scrim")).click();
driver.findElement(By.id("searchBtn")).click();
driver.findElement(By.cssSelector("#logoutBtn > #icon")).click();
driver.findElement(By.cssSelector("#logoutDialog > div.buttons > paper-button.x-scope.paper-button-0")).click();
driver.findElement(By.name("username")).clear();
driver.findElement(By.name("username")).sendKeys("");
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys("");
}
#After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
I generate this using selenium IDE for firefox and exported it as Java / Junit / Webdriver. Integrating it in src/test/java/ and also adding the necesary dependencies to my pom.xml
When I run in my terminal mvn verify it loads the test and finish with fail:
Failed tests:
SeleniumTest.testSelenium on testSelenium(SeleniumTest)(SeleniumTest)
Run 1: SeleniumTest.setUp:29 ยป IllegalAccess tried to access class org.openqa.seleniu...
Run 2: SeleniumTest.tearDown:130 NullPointer
This is the full error log:
java.lang.IllegalAccessError: tried to access class org.openqa.selenium.os.ExecutableFinder from class org.openqa.selenium.firefox.FirefoxBinary
at org.openqa.selenium.firefox.FirefoxBinary.locateFirefoxBinariesFromPlatform(FirefoxBinary.java:412)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:108)
at java.util.Optional.orElseGet(Optional.java:267)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:204)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:108)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:104)
at SeleniumTest.setUp(SeleniumTest.java:29)
testSelenium on testSelenium(SeleniumTest)(SeleniumTest) Time elapsed: 0.184 sec <<< FAILURE!
java.lang.NullPointerException: null
at SeleniumTest.tearDown(SeleniumTest.java:130)
Also I'm trying to use hedless test with Xvfb but I'm unable to even verify it in my local machine. I'm using Ubuntu 17.10
I wasn't able to find any step by step implementation for this. Or for integrate the test into jenkinsfile for a jenkins pipeline
You should add extension to the Gecko Driver to resolve one of the error.
System.setProperty("webdriver.gecko.driver", "/home/francop/Downloads/geckodriver.exe");
WebDriver driver = new FirefoxDriver();

Resources