Apache Flink: java.lang.NoClassDefFoundError for FlinkKafkaConsumer - apache-flink

I am trying to test simple flink kafka example.
mvn package works fine and then I ran ../../flink-1.14.3/bin/flink run -c com.comapny.flinktest.App target/flinktest-1.0-SNAPSHOT.jar and got the following error:
java.lang.NoClassDefFoundError: org/apache/flink/streaming/connectors/kafka/FlinkKafkaConsumer
at com.optiver.flinktest.App.main(App.java:38)
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:498)
at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:355)
at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:222)
at org.apache.flink.client.ClientUtils.executeProgram(ClientUtils.java:114)
at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:812)
at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:246)
at org.apache.flink.client.cli.CliFrontend.parseAndRun(CliFrontend.java:1054)
at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:1132)
at org.apache.flink.runtime.security.contexts.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:28)
at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1132)
My pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.flinktest</groupId>
<artifactId>flinktest</artifactId>
<version>1.0-SNAPSHOT</version>
<name>flinktest</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-core</artifactId>
<version>1.14.3</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>1.14.3</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_2.12</artifactId>
<version>1.14.3</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_2.12</artifactId>
<version>1.14.3</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka_2.12</artifactId>
<version>1.14.3</version>
<scope>Compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<mainClass>com.company.flinktest.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Folder structure: src/main/java/com/company/flinktest/App.java
Editor: Vscode
App.java Code:
package com.company.flinktest;
import java.util.Properties;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import java.util.InvalidPropertiesFormatException;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;
import org.apache.flink.streaming.util.serialization.SimpleStringSchema;
public class App{
public static void main(String[] args) throws Exception{
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
Properties properties = new Properties();
properties.setProperty("bootstrap.servers", "kafkaserver:9092");
properties.setProperty("group.id", "testgroup");
FlinkKafkaConsumer<String> myConsumer = new FlinkKafkaConsumer<String>(
"mytopic",
new SimpleStringSchema(),
properties);
DataStream<String> stream = env.addSource(myConsumer);
stream.print();
env.execute("flink from kafka");
}
}
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.

You can refer to my answer in one of the posts. Check the Scala language version though.

Related

H2 memory database not starting

I have a spring boot application deployed on heroku, which uses a postgres db hosted on heroku.
I have configured config vars on heroku and am using them in my spring boot application like this :
and in my code I use a connectionService:
public static Connection getConnection() {
try {
final String dbUrl = System.getenv("SPRING_DATASOURCE_URL");
final String dbUserName = System.getenv("SPRING_DATASOURCE_USERNAME");
final String dbPassword = System.getenv("SPRING_DATASOURCE_PASSWORD");
return DriverManager.getConnection(dbUrl,dbUserName,dbPassword);
} catch(final SQLException e) {
LoggerService.writeErrorMsg("There was an error with the connection : [errorMsg: \n" + e + " ]");
}
return null;
}
}
And I use DAOs with CRUD methods to access the database, for example :
public static AdminAccount getAdminAccountById(final int id) throws SQLException {
final Connection connection = ConnectionService.getConnection();
final String sql = "select * from admin_account where id = ?";
final PreparedStatement preparedStatement = connection.prepareStatement(sql);
preparedStatement.setInt(1, id);
final ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
final AdminAccount adminAccount = new AdminAccount();
adminAccount.setId(resultSet.getInt("id"));
adminAccount.setFacility(resultSet.getString("facility"));
adminAccount.setFirstName(resultSet.getString("first_name"));
adminAccount.setLastName(resultSet.getString("last_name"));
adminAccount.setEmail(resultSet.getString("email"));
connection.close();
return adminAccount;
} else {
return null;
}
}
This is working fine on the deployed app, however it no longer works in localhost since I removed the hardcoded db credentials. Also, after reading about best practices, I have figured out that it's best to have a separate DB only for testing/development, so you don't actually run queries against the production DB.
I have tried setting up a h2 memory database but with no luck. It doesn't seem to even start when I check the logs.
This is my pom.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>rbooking</name>
<description>...</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.6</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Switch back from Spring Boot 2.x standard HikariCP to Tomcat JDBC,
configured later in Heroku (see https://stackoverflow.com/a/49970142/4964553) -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>app/**</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>2.0.8</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And this is my application.properties:
#PORT
server.port = 8081
#LOGGING
logging.file.name=src/main/resources/logs/application.log
logging.file.path=src/main/resources/logs
logging.level.root = INFO
#SECURITY
security.basic.enable= false
security.ignored=/**
#DB
spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create
spring.jpa.show-sql=true
spring.jpa.defer-datasource-initialization=true
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
#DEVTOOLS
When I try to access the h2 database at localhost:8081/h2-console, I get this error msg:
What am I missing here to make it start and recognize my application.properties variables?
I have used the exact same application.properties configuration for another project and the h2 database starts and runs without issues
EDIT
I was able to make it work by specifying an older version of the h2 maven dependency :
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.193</version>
</dependency>

How to execute jar file of a TestNG project in Eclipse

I am able to run a TestNg project in Eclipse by running the testng.xml file. After building the Maven project, I tried to run the jar file in the terminal using the command java -jar jarname.
But it showing an error "no main manifest attribute". So i created a runner class and tried to run that class by run as -> Java application. But it throwing an error "cannot find class in classpath"
My code is given below.
pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-
4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MockTest</groupId>
<artifactId>MockFrameTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
testng.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
<listeners>
<listener class-name="com.reportListners.testListner"/>
</listeners>
<test name="Test">
<classes>
<class name="com.tests.Login"/>
<class name="com.tests.Home"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
runner.java
package runner;
import java.util.ArrayList;
import java.util.List;
import org.testng.TestNG;
public class TestNGrunner {
public static void main(String[] args) {
TestNG runner=new TestNG();
// Create a list of String
List<String> suitefiles=new ArrayList<String>();
// Add xml file which you have to execute
suitefiles.add(".//testng.xml");
// now set xml file for execution
runner.setTestSuites(suitefiles);
// finally execute the runner using run method
runner.run();
}
}
So how can i run this TestNG project using the Jar file. Can anyone help me?

Apache Camel 3.x + Spring Boot + JDBC DataSource: java.lang.IllegalStateException: No supported DataSource type found

This is no doubt a configuration/dependency issue.
failing code snippet
#Bean
#ConfigurationProperties(prefix="rmw.datasource")
public DataSource getDataSource() {
return DataSourceBuilder.create().build();
}
application.properties
rmw.datasource.url=jdbc:sqlserver://123.123.123.123
rmw.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
rmw.datasource.username=xxxx
rmw.datasource.password=zzzz
rmw.datasource.platform=sqlserver
I have tried with and without rmw.datasource.platform=sqlserver - it makes no difference.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>biz.suitej.poc</groupId>
<artifactId>http-producer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.11</java.version>
<camel.version>3.1.0</camel.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-dependencies</artifactId>
<version>${camel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-core-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-http-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-log-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-jackson-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-jdbc-starter</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.2.2.jre11</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have camel-jdbc-starter and mssql-jdbc JDBC driver.
I have tried camel-sql-starter and get the same error.
console output
2020-06-17 13:15:45.978 WARN 128833 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getDataSource' defined in class path resource [c10y/sql/query/GetRemodelWorksRouteBuilder.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'getDataSource' threw exception; nested exception is java.lang.IllegalStateException: No supported DataSource type found
2020-06-17 13:15:45.998 INFO 128833 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-17 13:15:46.009 ERROR 128833 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getDataSource' defined in class path resource [c10y/sql/query/GetRemodelWorksRouteBuilder.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'getDataSource' threw exception; nested exception is java.lang.IllegalStateException: No supported DataSource type found
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:484) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
...
The solution listed elsewhere to add spring-boot-starter-data-jpa didn't work for me (it just returned a different error):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>1.5.6.RELEASE</version>
</dependency>
I'm baffled why this just doesn't work 'straight out of the box'.
Thanks in advance for your help.
Just after posting this I found the solution that worked for me:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>1.5.6.RELEASE</version>
</dependency>

NoClassDefFoundError HibernateJpaVendorAdapter.java while deploying in wildfly 10.1

I am finding it really hard to figure out the cause of the error. I have been getting this error during LocalContainerEntityManagerFactoryBean creation in my config. I have attached the Error I get. I am using
Springboot
Wildfly 10.1
Hibernate-search
Caused by: java.lang.NoClassDefFoundError: org/hibernate/HibernateException
at org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.<init>(HibernateJpaVendorAdapter.java:66)
at com.mas.dhcpr3.config.Appconfig.entityManagerFactory(Appconfig.java:42)
at com.mas.dhcpr3.config.Appconfig$$EnhancerBySpringCGLIB$$b1fb2a11.CGLIB$entityManagerFactory$3(<generated>)
at com.mas.dhcpr3.config.Appconfig$$EnhancerBySpringCGLIB$$b1fb2a11$$FastClassBySpringCGLIB$$67e8e45c.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at com.mas.dhcpr3.config.Appconfig$$EnhancerBySpringCGLIB$$b1fb2a11.entityManagerFactory(<generated>)
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:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 39 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.HibernateException from [Module "deployment.newdhcpr3-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
... 51 more
The POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>newdhcpr3</artifactId>
<packaging>war</packaging>
<groupId>com.mas.dhcpr3</groupId>
<name>Spring Boot Data JPA Sample</name>
<description>Spring Boot Data JPA Sample</description>
<version>0.0.1-SNAPSHOT</version>
<url>http://projects.spring.io/spring-boot/</url>
<organization>
<name>Pivotal Software, Inc.</name>
<url>http://www.spring.io</url>
</organization>
<properties>
<main.basedir>${basedir}/../..</main.basedir>
<java.version>1.8</java.version>
<thymeleaf.version>3.0.3.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.2.1</thymeleaf-layout-dialect.version>
</properties>
<parent>
<!-- Your own application should inherit from spring-boot-starter-parent -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Search-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.8.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.1.7</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<excludes>
<exclude>com/mas/dhcpr3/newdhcpr3/data/*/*/*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
The bean code
#Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan(new String[] { "com.mas.dhcpr3.Entities" });
// em.setPersistenceProviderClass(HibernatePersistenceProvider.class);
em.setJpaProperties(additionalProperties());
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
return em;
}
Can any of you please help. I dont get any compilation error, and i can see the JPAVendorAdapter class in spring-orm 4.3 jar in my packaged war file. I was guessing that it could be because of the conflict in Wildfly's internal version. But i couldnt find any spring-orm jars. I am completely lost. can any of you please help Thank you

Trying to add a new Tab in Allure report

I'm trying to create a plugin for Allure, that will add a new tab called Browsers, that will display TC statuses across all browsers, but I'm stuck at the first step of it - adding Browsers Tab to the report itself. I was using allure-report-plugin-api and instructions from this question - Allure: How do I customize the test report to write "Browsers" instead of "Xunit"? and examples from the git repo of the allure-report-plugin-api.
But I have no luck, the tab isn't added, despite the code being so simple. Could you, please, point me where I did mistakes and show me what is the correct way to do it? Big thanks in advance!
Here's an example how I'm trying to add the new tab
Here's the project structure
src
--->main
--->--->java
--->--->--->allure
--->--->--->--->(Class) BrowserInfo
--->--->resourses
--->--->--->(directory)allure
--->--->--->--->(directory)BrowserInfo
--->--->--->--->--->en.json
--->--->--->--->--->script.js
--->test
--->--->allure
--->--->--->(Class) GoogleSearchTest
--->--->testcases
--->--->--->SearchTest.xml
pom.xml
Here's BrowserInfo class
package allure;
import ru.yandex.qatools.allure.Allure;
import ru.yandex.qatools.allure.data.AllureAttachment;
import ru.yandex.qatools.allure.data.AllureStep;
import ru.yandex.qatools.allure.data.AllureTestCase;
import ru.yandex.qatools.allure.data.plugins.DefaultTabPlugin;
import ru.yandex.qatools.allure.data.plugins.Plugin;
import ru.yandex.qatools.allure.model.Label;
import java.util.ArrayList;
import java.util.List;
#Plugin.Name("browserList")
public class BrowserInfo extends DefaultTabPlugin {
#Override
public void process(AllureTestCase data) {
}
}
Here's en.json
{
"browserList": {
"TITLE": "Browsers",
"TITLE_FULL": "List of browsers"
}
}
Here's script.js
/*global angular*/
(function() {
"use strict";
var module = angular.module('allure.browserList', []);
module.config(function($stateProvider, allureTabsProvider) {
allureTabsProvider.addTab('browserList', {title: 'browserList.TITLE'});
});
})();
Here's just a little test
package allure;
import junit.framework.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class GoogleSearchTest {
#Test
public void searchBananasTest() {
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com/");
driver.findElement(By.id("lst-ib")).sendKeys("BANANAS");
driver.findElement(By.cssSelector("[type = 'submit']")).click();
Assert.assertTrue(driver.findElement(
By.cssSelector("[data-async-context='query:BANANAS'] h3")
).getText().toLowerCase().contains("banana"));
driver.quit();
}
}
Here's TestNG test xml for the test
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="searching bananas">
<test name="searching bananas" preserve-order="true">
<classes>
<class name="allure.GoogleSearchTest">
<methods>
<include name = "searchBananasTest"/>
</methods>
</class>
</classes>
</test>
</suite>
Here's pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>AllurePluginTest</groupId>
<artifactId>AllurePluginTest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>allure</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<aspectj.version>1.8.5</aspectj.version>
<allure.version>1.4.16</allure.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suitexml}</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-testng-adaptor</artifactId>
<version>${allure.version}</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.46.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.7</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-report-plugin-api</artifactId>
<version>1.4.16</version>
</dependency>
</dependencies>
<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</reporting>
</project>
The main problem is that Allure loads plugins via Java SPI. So you need to create file
ru.yandex.qatools.allure.data.plugins.Plugin in META-INF/services/ in your resources folder with the following content:
allure.BrowserInfo
Then you need to configure allure-maven-plugin to use your plugin:
<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<plugins>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</plugin>
</plugins>
</configuration>
</plugin>
</plugins>
</reporting>
Note: the plugin should be installed to local repository.
I recommend to use the separate project for your plugin and generate the preview report using maven-invoker-plugin. In this case you no need to run tests (you can just place test results to folder you need) and no need to install/deploy plugin.
And few more comments for you:
BrowserInfo
By default Allure expects that each plugin provides some data in file ${pluginName}.json. So you need to add some dummy data. An example you can simple add field like this:
#Plugin.Data
private List<String> strings = new ArrayList<>();
The other way configure this behavior in script.js (empty resolve section):
allureTabsProvider.addTab('browserList', {title: 'browserList.TITLE', resolve: {}});
Translation
To add translation to the report use the following command:
allureTabsProvider.addTranslation('cats');
Take a look: Allure JavaScript API
Plugin template
Allure looks for tab.tpl.html for each tab plugin. So you need to add it to your plugin resources.
I hope it helps.
Add dependencies ALlure Report Builder then add below code
// It will generate the Allure Report folder.
new AllureReportBuilder("1.5.4", new File("target/allure-report")).unpackFace();
new AllureReportBuilder("1.5.4", new File("target/allure-report")).processResults(new File("target/allure-results"));

Resources