Reading data into Flink Program from Kafka console producer - maven

I have created a topic named test and written some string's in the console using console Producer.
./bin/kafka-console-producer.sh --topic test --broker-list localhost:9092
Fortunately, I am able to read data produced in the console by using console-consumer. Now, I wanted to consume the output made by console-consumer in Flink Program using below code
public class ReadFromKafka {
public static void main(String[] args) throws Exception {
// create execution environment
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
Properties properties = new Properties();
properties.setProperty("bootstrap.servers", "localhost:9092");
properties.setProperty("zookeeper.connect", "localhost:2181");
properties.setProperty("group.id", "test");
DataStream<String> message = env.addSource(new FlinkKafkaConsumer08<String>("test", new SimpleStringSchema(),properties));
message.map(new MapFunction<String, String>() {
private static final long serialVersionUID = -6867736771747690202L;
#Override
public String map(String value) throws Exception {
return " Value: " + value;
}
}).print();
env.execute();
} //main
} //ReadFromKafka
Content of POM.XML is as follows
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.stsffap</groupId>
<artifactId>cep-monitoring</artifactId>
<name>cep-monitoring</name>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<flink.version>1.0.1</flink.version>
<slf4j.version>1.7.7</slf4j.version>
<log4j.version>1.2.17</log4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_2.10</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_2.10</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-cep_2.10</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka-0.8_2.10</artifactId>
<version>1.3.2</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>
<compilerId>jdt</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-jdt</artifactId>
<version>0.21.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Whenever , I execute this code I got Following error
objc[892]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java (0x109f654c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10afd44e0). One of the two will be used. Which one is undefined.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flink/streaming/api/checkpoint/CheckpointedFunction
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.stsffap.cep.monitoring.ReadFromKafka.main(ReadFromKafka.java:24)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.streaming.api.checkpoint.CheckpointedFunction
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 25 more
Also version of Kafka, I am using found by below command
find ./libs/ -name \*kafka_\* | head -1 | grep -o '\kafka[^\n]*'
is
kafka_2.11-0.9.0.0-javadoc.jar
Do I need to use .8.x version of Kafka to run my example?
Comments and suggestions are highly appriciated. Thanks in Advance.
Have a good one !

My Program started working by making following changes, I updated the Kafka version to .9.x
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka-0.9_2.10</artifactId>
<version>${flink.version}</version>
</dependency>
I upgraded the Flink version from 1.0.1 to 1.1.2 , as shown below
<properties>
<!-- <flink.version>1.0.1</flink.version>-->
<flink.version>1.1.2</flink.version>
<slf4j.version>1.7.7</slf4j.version>
<log4j.version>1.2.17</log4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_2.10</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_2.10</artifactId>
<version>${flink.version}</version>
</dependency>

Related

I have problem with ehcache i am getting an error "Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.ehcache.org/v3]"

I am trying to config to cache in spring boot with ehcache but i am getting an error
"org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.ehcache.org/v3]"
I have a config file named ehcache.xml in resources folder and i add it to main class as
#SpringBootApplication
#ImportResource("classpath:ehcache.xml")
public class AirsoftwebApplication {
public static void main(String[] args) {
SpringApplication.run(AirsoftwebApplication.class, args);
}
}
my config
<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xsi:schemaLocation='http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core.xsd'>
<cache alias="users">
<key-type>java.lang.Long</key-type>
<value-type>com.perunsmillstone.model.entities.User</value-type>
<expiry>
<ttl>10</ttl>
</expiry>
<resources>
<offheap unit="MB">150</offheap>
</resources>
</cache>
</config>
Cache config java class
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
#Configuration
#EnableCaching
public class CachingConfig {
}
my 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 http://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.2.0.M5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.perun.smillstone</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>airsoftweb</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>12</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.17.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.3.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-cdi</artifactId>
<version>6.0.17.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</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-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</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-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</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.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>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.9.3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
<version>2.2.0.RELEASE</version></dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
</project>
Whole error
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-11-03 13:02:33.854 ERROR 11172 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.ehcache.org/v3]
Offending resource: class path resource [applicationContext.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:72) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:119) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:111) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:281) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1388) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1371) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:149) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:96) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:513) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:393) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:224) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:195) ~[spring-beans-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromImportedResources$0(ConfigurationClassBeanDefinitionReader.java:379) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[na:na]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromImportedResources(ConfigurationClassBeanDefinitionReader.java:346) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:147) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:337) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:242) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.2.0.RC1.jar:5.2.0.RC1]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.0.M5.jar:2.2.0.M5]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:746) ~[spring-boot-2.2.0.M5.jar:2.2.0.M5]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:396) ~[spring-boot-2.2.0.M5.jar:2.2.0.M5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.0.M5.jar:2.2.0.M5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1225) ~[spring-boot-2.2.0.M5.jar:2.2.0.M5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214) ~[spring-boot-2.2.0.M5.jar:2.2.0.M5]
at com.perunsmillstone.AirsoftwebApplication.main(AirsoftwebApplication.java:17) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.2.0.M5.jar:2.2.0.M5]
The usual way for setting up EHcache in Spring Boot is to use this property in the application.xml:
spring.cache.jcache.config=classpath:ehcache.xml
Source: https://docs.spring.io/spring-boot/docs/2.1.7.RELEASE/reference/htmlsingle/#boot-features-caching-provider-jcache
I have used it in several projects and have never configured it by importing the configuration file as a resource.

Error creating bean with name 'ConfigurationPropertiesBindingPostProcessor' when running jar file in spring boot web application

My Spring boot web application occurs error when starting to run by jar package although I can run by mvn spring-boot:run.
Could you please help me fix this error?
I used in datasource configuration:
#PropertySource(value = {"classpath:datasource-postgresql.properties"})
My pom file:
<?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.example</groupId>
<artifactId>MultiTenancyDemo</artifactId>
<!-- <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> -->
<name>MultiTenancyDemo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<p.type>jar</p.type>
<start-class>com.example.demo.MultiTenancyDemoApplication</start-class>
<maven.test.skip>true</maven.test.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- For Thymeleaf VIEW. Remove it if using Jsp VIEW -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.2.Final</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.163</version>
</dependency>
<dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-sqlmap</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.3m</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<packaging>${p.type}</packaging>
</project>
I run by window commandline:
java -jar target\MultiTenancyDemo-2.0.0.RELEASE.jar
or
java -jar target\MultiTenancyDemo-2.0.0.RELEASE.jar --spring
.config.location=application.properties,datasource-postgresql.properties
Error:
Error starting ApplicationContext. To display the conditions report re-run your
application with 'debug' enabled.
2018-03-29 11:52:46.370 ERROR 7844 --- [ main] o.s.boot.SpringApplicat
ion : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindi
ngPostProcessor': Invocation of init method failed; nested exception is java.uti
l.ServiceConfigurationError: javax.validation.spi.ValidationProvider: Error read
ing configuration file
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710) ~[spring-be
ans-5.0.4.RELEASE.jar!/:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans
-5.0.4.RELEASE.jar!/:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5
.0.4.RELEASE.jar!/:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$
doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar!/:5.0
.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEA
SE.jar!/:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar!/:5.0.4.RELEAS
E]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:205) ~[spring-beans-5.0.4.RELEASE.jar!/:5.0.4.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate
.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:205) ~[spring
-context-5.0.4.RELEASE.jar!/:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.regist
erBeanPostProcessors(AbstractApplicationContext.java:709) ~[spring-context-5.0.4
.RELEASE.jar!/:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:534) ~[spring-context-5.0.4.RELEASE.jar!/:5.0.
4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicat
ionContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.
0.0.RELEASE.jar!/:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.
java:752) [spring-boot-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringAppli
cation.java:388) [spring-boot-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java
:327) [spring-boot-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java
:1246) [spring-boot-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java
:1234) [spring-boot-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
at com.example.demo.MultiTenancyDemoApplication.main(MultiTenancyDemoApp
lication.java:31) [classes!/:2.0.0.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.
0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.
0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:
1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_131]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner
.java:48) [MultiTenancyDemo-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [Mu
ltiTenancyDemo-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [Mu
ltiTenancyDemo-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
[MultiTenancyDemo-2.0.0.RELEASE.jar:2.0.0.RELEASE]
Caused by: java.util.ServiceConfigurationError: javax.validation.spi.ValidationP
rovider: Error reading configuration file
at java.util.ServiceLoader.fail(Unknown Source) ~[na:1.8.0_131]
at java.util.ServiceLoader.parse(Unknown Source) ~[na:1.8.0_131]
at java.util.ServiceLoader.access$200(Unknown Source) ~[na:1.8.0_131]
at java.util.ServiceLoader$LazyIterator.hasNextService(Unknown Source) ~
[na:1.8.0_131]
at java.util.ServiceLoader$LazyIterator.hasNext(Unknown Source) ~[na:1.8
.0_131]
at java.util.ServiceLoader$1.hasNext(Unknown Source) ~[na:1.8.0_131]
at javax.validation.Validation$GetValidationProviderListAction.loadProvi
ders(Validation.java:381) ~[validation-api-2.0.1.Final.jar!/:na]
at javax.validation.Validation$GetValidationProviderListAction.run(Valid
ation.java:356) ~[validation-api-2.0.1.Final.jar!/:na]
at javax.validation.Validation$GetValidationProviderListAction.getValida
tionProviderList(Validation.java:338) ~[validation-api-2.0.1.Final.jar!/:na]
at javax.validation.Validation$DefaultValidationProviderResolver.getVali
dationProviders(Validation.java:320) ~[validation-api-2.0.1.Final.jar!/:na]
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation
.java:277) ~[validation-api-2.0.1.Final.jar!/:na]
at org.springframework.boot.validation.MessageInterpolatorFactory.getObj
ect(MessageInterpolatorFactory.java:53) ~[spring-boot-2.0.0.RELEASE.jar!/:2.0.0.
RELEASE]
at org.springframework.boot.context.properties.ConfigurationPropertiesJs
r303Validator$Delegate.<init>(ConfigurationPropertiesJsr303Validator.java:71) ~[
spring-boot-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
at org.springframework.boot.context.properties.ConfigurationPropertiesJs
r303Validator.<init>(ConfigurationPropertiesJsr303Validator.java:43) ~[spring-bo
ot-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
at org.springframework.boot.context.properties.ConfigurationPropertiesJs
r303Validator.getIfJsr303Present(ConfigurationPropertiesJsr303Validator.java:64)
~[spring-boot-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
at org.springframework.boot.context.properties.ConfigurationPropertiesBi
nder.<init>(ConfigurationPropertiesBinder.java:69) ~[spring-boot-2.0.0.RELEASE.j
ar!/:2.0.0.RELEASE]
at org.springframework.boot.context.properties.ConfigurationPropertiesBi
ndingPostProcessor.afterPropertiesSet(ConfigurationPropertiesBindingPostProcesso
r.java:78) ~[spring-boot-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) ~[spring
-beans-5.0.4.RELEASE.jar!/:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-be
ans-5.0.4.RELEASE.jar!/:5.0.4.RELEASE]
... 24 common frames omitted
Caused by: java.util.zip.ZipException: invalid code lengths set
at java.util.zip.InflaterInputStream.read(Unknown Source) ~[na:1.8.0_131
]
at org.springframework.boot.loader.jar.ZipInflaterInputStream.read(ZipIn
flaterInputStream.java:52) ~[MultiTenancyDemo-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source) ~[na:1.8.0_131]
at sun.nio.cs.StreamDecoder.implRead(Unknown Source) ~[na:1.8.0_131]
at sun.nio.cs.StreamDecoder.read(Unknown Source) ~[na:1.8.0_131]
at java.io.InputStreamReader.read(Unknown Source) ~[na:1.8.0_131]
at java.io.BufferedReader.fill(Unknown Source) ~[na:1.8.0_131]
at java.io.BufferedReader.readLine(Unknown Source) ~[na:1.8.0_131]
at java.io.BufferedReader.readLine(Unknown Source) ~[na:1.8.0_131]
at java.util.ServiceLoader.parseLine(Unknown Source) ~[na:1.8.0_131]
... 42 common frames omitted
I found root cause that is because my maven cannot download library files. After deleting repositories folder in m2 folder, fixing network, I could run jar file.

Cannot Create Database connection in Spring-Boot

I am deploying a spring boot application on Openshift Tomcat 7.0.54 environment. We have total four instances of Tomcat, and when I deploy the application, it gets deploy into every instance of tomcat.
Here is the problem, I am only able to open database connection for one instance for rest of the three instances after some time I get the exception (shown below).
I am not able to find the root cause for not getting the connection. I am using SpringJDBC in the project (not using hibernate).
Since I have to move the code from Development->Stage->Production, I cannot hard code the database login credentials because of that I am using JDNI for getting it from the environment variable based on the environment in which application is running.
Application.java
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.apache.catalina.Context;
import org.apache.catalina.deploy.ContextResource;
import org.apache.catalina.startup.Tomcat;
import org.apache.log4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.jndi.JndiObjectFactoryBean;
#SpringBootApplication
#EnableAutoConfiguration(exclude = { ErrorMvcAutoConfiguration.class })
public class Application extends SpringBootServletInitializer {
private static final Logger LOGGER = Logger.getLogger(Application.class);
public static void main(String[] args) {
LOGGER.info("Spring Boot Application Started");
SpringApplication.run(Application.class, args);
LOGGER.info("Spring Boot Application Ended");
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
#Bean
public EmbeddedServletContainerFactory tomcatFactory() {
return new TomcatEmbeddedServletContainerFactory() {
#Override
protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(Tomcat tomcat) {
tomcat.enableNaming();
return super.getTomcatEmbeddedServletContainer(tomcat);
}
#Override
protected void postProcessContext(Context context) {
ContextResource resource = new ContextResource();
resource.setName("jdbc/grs_lae_cust_db");
resource.setType(DataSource.class.getName());
resource.setProperty("driverClassName", "oracle.jdbc.OracleDriver");
resource.setProperty("url","jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=ON)(FAILOVER=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=IP)(PORT=portno))(ADDRESS=(PROTOCOL=TCP)(HOST=IP)(PORT=portno)))(CONNECT_DATA=(SERVICE_NAME=service.company.com)(SERVER=DEDICATED)))");
resource.setAuth("Container");
resource.setProperty("username", "username");
resource.setProperty("password", "password");
context.getNamingResources().addResource(resource);
}
};
}
#Bean(destroyMethod = "")
public DataSource jndiDataSource() throws IllegalArgumentException, NamingException {
LOGGER.debug("Entering JNDIDataSource");
JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
bean.setJndiName("java:comp/env/jdbc/grs_lae_cust_db");
bean.setProxyInterface(DataSource.class);
bean.setLookupOnStartup(false);
bean.afterPropertiesSet();
LOGGER.info("Leaving JNDIDataSource");
return (DataSource) bean.getObject();
}
}
context.xml
<?xml version='1.0' encoding='utf-8'?>
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource name="jdbc/grs_lae_cust_db"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="${OPENSHIFT_DB_URL}"
username="${OPENSHIFT_DB_USERNAME}"
password="${OPENSHIFT_DB_PASSWORD}"
maxActive="150"
maxIdle="10"
maxWait="30000"
initialSize="2"
minIdle = "2"
jmxEnabled="true"
timeBetweenEvictionRunsMillis="180000"
minEvictableIdleTimeMillis="300000"
logAbandoned="true"
testOnBorrow="true"
testOnConnect="false"
suspectTimeout="120"
validationQuery="select 1 from dual"
validationInterval="200"
initSQL="select 1 from dual"
removeAbandoned="false"
removeAbandonedTimeout="1800"
maxAge ="1800000"
accessToUnderlyingConnectionAllowed="true"/>
</Context>
pre_restart_jbossews and pre_start_jbossews
###########START OF SCRIPT################### #
#!/bin/bash
export ORACLE_HOME="/opt/oracle/product/current"
export LD_LIBRARY_PATH="/opt/oracle/product/current/lib"
export CLASSPATH="/opt/oracle/product/current/jdbc/lib/ojdbc6.jar"
appname=`echo $OPENSHIFT_APP_NAME`
case "$appname" in
*dev) export JAVA_OPTS_EXT="${JAVA_OPTS_EXT} -D.life=dev"
export OPENSHIFT_company_LDAP="ldap://dsxstage.company.com:389"
export OPENSHIFT_DB_URL="jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm-i-nprd)(PORT=1600))(CONNECT_DATA=(SERVICE_NAME=MKWBDEV.company.com)))"
export OPENSHIFT_DB_USERNAME="username"
export OPENSHIFT_DB_PASSWORD='password';;
*stage|*stg) export JAVA_OPTS_EXT="${JAVA_OPTS_EXT} -D.life=stage"
export OPENSHIFT_company_LDAP="ldap://dsx.company.com:389"
export OPENSHIFT_DB_URL="jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=ON)(FAILOVER=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=IP)(PORT=portno))(ADDRESS=(PROTOCOL=TCP)(HOST=IP)(PORT=portno)))(CONNECT_DATA=(SERVICE_NAME=servicenema.company.com)(SERVER=DEDICATED)))"
export OPENSHIFT_DB_USERNAME="username"
export OPENSHIFT_DB_PASSWORD='password';;
*lt) export JAVA_OPTS_EXT="${JAVA_OPTS_EXT} -D.life=lt"
export OPENSHIFT_company_LDAP="ldap://dsx.company.com:389"
export OPENSHIFT_DB_URL="jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=ON)(FAILOVER=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=IP)(PORT=portno))(ADDRESS=(PROTOCOL=TCP)(HOST=IP)(PORT=portno)))(CONNECT_DATA=(SERVICE_NAME=servicenema.company.com)(SERVER=DEDICATED)))"
export OPENSHIFT_DB_USERNAME="username"
export OPENSHIFT_DB_PASSWORD='password';;
*prod|*prd) export JAVA_OPTS_EXT="${JAVA_OPTS_EXT} -D.life=prod"
export OPENSHIFT_company_LDAP="ldap://dsx.company.com:389"
export OPENSHIFT_DB_URL="jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=ON)(FAILOVER=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=IP)(PORT=portno))(ADDRESS=(PROTOCOL=TCP)(HOST=IP)(PORT=portno)))(CONNECT_DATA=(SERVICE_NAME=servicenema.company.com)(SERVER=DEDICATED)))"
export OPENSHIFT_DB_USERNAME="username"
export OPENSHIFT_DB_PASSWORD='password';;
*) export JAVA_OPTS_EXT="${JAVA_OPTS_EXT} -D.life=dev"
export OPENSHIFT_company_LDAP="ldap://dsxstage.company.com:389"
export OPENSHIFT_DB_URL="jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=IP)(PORT=portno))(CONNECT_DATA=(SERVICE_NAME=servicename.company.com)))"
export OPENSHIFT_DB_USERNAME="username"
export OPENSHIFT_DB_PASSWORD='password';;
esac
###############END OF SCRIPT##################
assembly.xml
<?xml version="1.0"?>
<assembly>
<id>${project.version}</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}/../package</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
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>tomcat7</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>cctgmap-tomcat7</name>
<description>Eloqua integration</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tomcat.version>7.0.59</tomcat.version>
<java.version>1.7</java.version>
<guava.version>12.0</guava.version>
<json-simple.version>1.1.1</json-simple.version>
<commons-codec.verison>1.10</commons-codec.verison>
<log4j-core.version>2.4.1</log4j-core.version>
<log4j-api.version>2.4.1</log4j-api.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</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-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</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>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
</dependency>
<!-- http://mvnrepository.com/artifact/commons-codec/commons-codec -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.verison}</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>${json-simple.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j-core.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j-api.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.16</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- Dependencies added for WAS and Oracle -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>classes12</artifactId>
<version>10.2.0.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.5</version>
</dependency> -->
<!-- Dependencies WAS and Oracle ends -->
<!-- Server Dependency -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-juli</artifactId>
<version>${tomcat.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-dbcp</artifactId>
<version>7.0.30</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
<!-- Server Dependency ends -->
</dependencies>
<build>
<finalName>cctgmap</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<server>TomcatServer</server>
<port>8008</port>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<outputDirectory>${project.build.directory}/../package/dependencies/jbossews/webapps </outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</project>
I am getting this error
Feb 25, 2017 1:17:48 AM org.apache.naming.NamingContext lookup
WARNING: Unexpected exception resolving reference
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (IO Error: The Network Adapter could not establish the connection)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1551)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1390)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getLogWriter(BasicDataSource.java:1100)
at org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.createDataSource(BasicDataSourceFactory.java:350)
at org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.getObjectInstance(BasicDataSourceFactory.java:156)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:141)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:842)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.NamingContext.lookup(NamingContext.java:830)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.NamingContext.lookup(NamingContext.java:830)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.NamingContext.lookup(NamingContext.java:830)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:156)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:106)
at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:135)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)
at com.sun.proxy.$Proxy60.getConnection(Unknown Source)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:204)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.springframework.session.jdbc.JdbcOperationsSessionRepository.cleanUpExpiredSessions(JdbcOperationsSessionRepository.java:475)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:458)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1558)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1547)
... 43 more
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:392)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:434)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:687)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:247)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
... 51 more
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:150)
at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:370)
... 56 more
The Code is running properly on one instance of tomcat but not on other three instances of tomcat.
We are using Oracle 12c database.
Please share your expert advice.
Any help will be appreciated.

QueryDSL generates JPQL instead of SQL for SQLDialect

Trying to get QueryDSL up for native SQL below is the Spring boot POM snippet
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
<querydsl.version>4.0.1</querydsl.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-sql</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-sql-codegen</artifactId>
<version>${querydsl.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
.....
<plugin>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>${querydsl.version}</version>
<executions>
<execution>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
<configuration>
<jdbcDriver>org.hsqldb.jdbc.JDBCDriver</jdbcDriver>
<jdbcUrl>jdbc:hsqldb:file:${project.basedir}/db/init;files_readonly=true</jdbcUrl>
<jdbcUser>sa</jdbcUser>
<schemaPattern>PUBLIC</schemaPattern>
<packageName>com.example.domain</packageName>
<targetFolder>${project.basedir}/src/generated/java</targetFolder>
</configuration>
<dependencies>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
The code for executing the query
void test() throws Exception {
QCustomer customer = QCustomer.customer;
System.out.println(dataSource.getConnection().getMetaData().getDatabaseProductName());
SQLTemplates dialect = SQLTemplates.DEFAULT;
SQLQuery query = new SQLQuery(dataSource.getConnection(), dialect);
System.out.println(query.from(customer.count()).fetch());
}
The execution results in SQLException as library generates JPQL(or HQL) instead of Native SQL
Exception in thread "main" com.querydsl.core.QueryException: Caught SQLSyntaxErrorException for
from count(CUSTOMER.ID)
at com.querydsl.sql.DefaultSQLExceptionTranslator.translate(DefaultSQLExceptionTranslator.java:50)
at com.querydsl.sql.Configuration.translate(Configuration.java:451)
at com.querydsl.sql.AbstractSQLQuery.fetch(AbstractSQLQuery.java:399)
at com.example.DemoApplication$Test.test(DemoApplication.java:55)
at com.example.DemoApplication.main(DemoApplication.java:36)
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:144)
Caused by: java.sql.SQLSyntaxErrorException: unexpected token: FROM
We should be using
query.select(customer.count())
.from(customer)
.fetch()
and for QueryDSL 4.X and later(latest version) refer http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s03.html#d0e1145

Running junits in maven build process with db2 jars

I am working on a java based webapp wherein I am using websphere JAX-RS implementation, EJB as middle layer and OpenJPA as DAO layer with DB2 in backend for data persistence. I also write junits for code.I run junits in my eclipse workspace and as I am using depenency injection annotations in my beans, so I make use of light weight embedded container jar provided by websphere to make junits launch and run fast. I provide this jar as java agent as follows:
AS I also need DB2 jars in my tests for DAO oeprations,I provide those jars as:
And I am finally able to run my junits.
But this approach I follow when I run a junit individually. Now I plan to run all my junits as part of maven build process(maven install -e). I have provided required dependencies as:
<!--added for junit testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.websphere</groupId>
<artifactId>was-embeddableContainer</artifactId>
<version>8.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc</artifactId>
<version>8.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc_license_cu</artifactId>
<version>8.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc4</artifactId>
<version>8.1.1</version>
<scope>test</scope>
</dependency>
<!-- end -->
But in maven build, junits fail with strange issue:
org.apache.openjpa.persistence.ArgumentException: The type "x.y.z.MyEntity" has not been enhanced.
I have tried all means but unable to sort our this issue.
Please help me here.
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- THIS PRODUCT CONTAINS RESTRICTED MATERIALS OF IBM 5724-H88, 5724-J08,
5724-I63, 5655-W65, COPYRIGHT International Business Machines Corp., 2013
All Rights Reserved * Licensed Materials - Property of IBM US Government
Users Restricted Rights - Use, duplication or disclosure restricted by GSA
ADP Schedule Contract with IBM Corp. -->
<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">
<licenses>
<license>
<name>IBM International License Agreement for Non-Warranted Programs</name>
<url>http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/licenses/L-JTHS-8SZMHX/HTML/</url>
<distribution>repo</distribution>
<comments>Additional notices http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/licenses/L-JTHS-8SZMHX/HTML/notices.html</comments>
</license>
</licenses>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.febe</groupId>
<artifactId>FebeApplication</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>FebeApplication</name>
<url>http://maven.apache.org</url>
<properties>
<was_home>${env.WAS8_HOME}</was_home>
</properties>
<dependencies>
<!-- <dependency> <groupId>com.ibm.tools.target</groupId> <artifactId>was</artifactId>
<version>8.5.5</version> <type>pom</type> <scope>provided</scope> </dependency> -->
<!-- added for websphere JPA -->
<dependency>
<groupId>com.ibm.websphere.ws</groupId>
<artifactId>com.ibm.ws.jpa</artifactId>
<version>8.0.0-FixPack-07</version>
<scope>provided</scope>
</dependency>
<!-- end -->
<!-- added for websphere j2ee -->
<dependency>
<groupId>com.ibm.websphere.j2ee</groupId>
<artifactId>j2ee</artifactId>
<version>8.0.0-FixPack-07</version>
<scope>provided</scope>
</dependency>
<!-- end -->
<!-- added for IBM PAI logging -->
<dependency>
<groupId>com.dcx.pai</groupId>
<artifactId>logging</artifactId>
<version>5.0.5</version>
</dependency>
<dependency>
<groupId>com.dcx.pai</groupId>
<artifactId>monitoring</artifactId>
<version>5.0.5</version>
</dependency>
<dependency>
<groupId>com.dcx.pai</groupId>
<artifactId>usersecuritycontext</artifactId>
<version>5.0.5</version>
</dependency>
<dependency>
<groupId>com.dcx.pai</groupId>
<artifactId>util</artifactId>
<version>5.0.5</version>
</dependency>
<!-- end -->
<!--added for dozer mapping -->
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.4.0</version>
</dependency>
<!-- end -->
<!--added for junit testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.websphere</groupId>
<artifactId>was-embeddableContainer</artifactId>
<version>8.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc</artifactId>
<version>8.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc_license_cu</artifactId>
<version>8.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc4</artifactId>
<version>8.1.1</version>
<scope>test</scope>
</dependency>
<!-- end -->
<!--added for JSON Ignore -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.7.1</version>
</dependency>
<!-- end -->
<!--added for DBSetUP -->
<dependency>
<groupId>com.ninja-squad</groupId>
<artifactId>DbSetup</artifactId>
<version>1.6.0</version>
</dependency>
<!--end -->
<dependency>
<groupId>javax.batch</groupId>
<artifactId>javax.batch-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-openjpa</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-embedded</artifactId>
<version>7.0.0.Final</version>
</dependency>
</dependencies>
<build>
<finalName>${project.name}</finalName>
<outputDirectory>${project.basedir}\src\main\webapp\WEB-INF\classes</outputDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- plugin added to skip test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<skipTests>false</skipTests>
</configuration>
</plugin>
<!-- end -->
</plugins>
</build>
Error trace:
Caused by: javax.ejb.EJBException: See nested exception; nested exception is: org.apache.openjpa.persistence.ArgumentException: The type "class com.test.febe.model.OrgUnit" has not been enhanced.
Caused by: org.apache.openjpa.persistence.ArgumentException: The type "class com.test.febe.model.OrgUnit" has not been enhanced.
at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1827)
at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1801)
at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:825)
at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:722)
at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:646)
at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:414)
at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:387)
at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1246)
at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:316)
at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:485)
at com.ibm.ws.jpa.management.JPATxEmInvocation.find(JPATxEmInvocation.java:223)
at com.ibm.ws.jpa.management.JPAEntityManager.find(JPAEntityManager.java:195)
at com.test.febe.commons.FebeGenericDAOImpl.find(FebeGenericDAOImpl.java:60)
at com.test.febe.org.dao.EJSLocal0SLOrgUnitDAOImpl_8ea44002.find(EJSLocal0SLOrgUnitDAOImpl_8ea44002.java)
at com.test.febe.org.service.OrgUnitServiceImpl.findOrgUnit(OrgUnitServiceImpl.java:33)
at com.test.febe.org.service.EJSLocal0SLOrgUnitServiceImpl_d9270681.findOrgUnit(EJSLocal0SLOrgUnitServiceImpl_d9270681.java)
at com.test.febe.org.resouces.OrgUnitResource.findOrgUnit(OrgUnitResource.java:44)
at com.test.febe.org.resouces.EJSLocalNSLOrgUnitResource_94f17fdf.findOrgUnit(EJSLocalNSLOrgUnitResource_94f17fdf.java)
at com.test.febe.test.org.OrgUnitTest.testGetOrgUnit(OrgUnitTest.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 8.693 sec <<< FAILURE! - in com.test.febe.test.org.OrgUnitTest
testGetAllOrgUnits(com.test.febe.test.org.OrgUnitTest) Time elapsed: 2.541 sec <<< ERROR!
javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: org.apache.openjpa.persistence.ArgumentException: The type "class com.test.febe.model.OrgUnit" has not been enhanced.
at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1827)
at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1801)
at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:825)
at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:722)
at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:646)
at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:414)
at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:387)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:188)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:153)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:243)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:213)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:206)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$200(JPQLExpressionBuilder.java:81)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:2461)
at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:61)
at org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:162)
at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:673)
at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:654)
at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:620)
at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:682)
at org.apache.openjpa.kernel.QueryImpl.compile(QueryImpl.java:589)
at org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:996)
at com.ibm.ws.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:107)
at com.ibm.ws.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:86)
at com.ibm.ws.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:34)
at com.ibm.ws.jpa.management.JPATxEmInvocation.createQuery(JPATxEmInvocation.java:204)
at com.ibm.ws.jpa.management.JPAEntityManager.createQuery(JPAEntityManager.java:299)
at com.test.febe.commons.FebeGenericDAOImpl.findAll(FebeGenericDAOImpl.java:69)
at com.test.febe.org.dao.EJSLocal0SLOrgUnitDAOImpl_8ea44002.findAll(EJSLocal0SLOrgUnitDAOImpl_8ea44002.java)
at com.test.febe.org.service.OrgUnitServiceImpl.getAllOrgUnits(OrgUnitServiceImpl.java:46)
at com.test.febe.org.service.EJSLocal0SLOrgUnitServiceImpl_d9270681.getAllOrgUnits(EJSLocal0SLOrgUnitServiceImpl_d9270681.java)
at com.test.febe.org.resouces.OrgUnitResource.getAllOrgUnits(OrgUnitResource.java:56)
at com.test.febe.org.resouces.EJSLocalNSLOrgUnitResource_94f17fdf.getAllOrgUnits(EJSLocalNSLOrgUnitResource_94f17fdf.java)
at com.test.febe.test.org.OrgUnitTest.testGetAllOrgUnits(OrgUnitTest.java:117)
testGetOrgUnit(com.test.febe.test.org.OrgUnitTest) Time elapsed: 1.904 sec <<< ERROR!
javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: org.apache.openjpa.persistence.ArgumentException: The type "class com.test.febe.model.OrgUnit" has not been enhanced.
at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1827)
at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1801)
at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:825)
at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:722)
at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:646)
at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:414)
at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:387)
at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1246)
at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:316)
at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:485)
at com.ibm.ws.jpa.management.JPATxEmInvocation.find(JPATxEmInvocation.java:223)
at com.ibm.ws.jpa.management.JPAEntityManager.find(JPAEntityManager.java:195)
at com.test.febe.commons.FebeGenericDAOImpl.find(FebeGenericDAOImpl.java:60)
at com.test.febe.org.dao.EJSLocal0SLOrgUnitDAOImpl_8ea44002.find(EJSLocal0SLOrgUnitDAOImpl_8ea44002.java)
at com.test.febe.org.service.OrgUnitServiceImpl.findOrgUnit(OrgUnitServiceImpl.java:33)
at com.test.febe.org.service.EJSLocal0SLOrgUnitServiceImpl_d9270681.findOrgUnit(EJSLocal0SLOrgUnitServiceImpl_d9270681.java)
at com.test.febe.org.resouces.OrgUnitResource.findOrgUnit(OrgUnitResource.java:44)
at com.test.febe.org.resouces.EJSLocalNSLOrgUnitResource_94f17fdf.findOrgUnit(EJSLocalNSLOrgUnitResource_94f17fdf.java)
at com.test.febe.test.org.OrgUnitTest.testGetOrgUnit(OrgUnitTest.java:141)

Resources