Hi Ramesh,
As per your earlier response I made changes , but now I am getting some different error.
Related to teiid log level
Changed log level from DEBUG to TRACE in my application.properties
logging.level.org.teiid.spring=TRACE
Changes Made
Changes A and B are as per your inputs for datasource name
Change C is inline with teiid-spring-boot project available on Github
Change D,E to explicitely mention table name
A]Changes in datasource bean configuration
From
@ConfigurationProperties(prefix="spring.datasource.teiiduserexample")
@Bean
public DataSource teiiduserexampleDs() {
return DataSourceBuilder.create().build();
}
To
@ConfigurationProperties(prefix="spring.datasource. teiiduserexampleDs")
@Bean
public DataSource teiiduserexampleDs() {
return DataSourceBuilder.create().build();
}
B] Changes in application.properties
a. spring.datasource.teiiduserexampleDs.url=jdbc:oracle:thin:@<DB-IP>:1521/XE
b. spring.datasource.teiiduserexampleDs.username=<DB-USER>
c. spring.datasource.teiiduserexampleDs.password=<DB-password>
d. spring.datasource.teiiduserexampleDs.driver-class-name=oracle.jdbc.OracleDriver
it was earlier referring
- a. spring.datasource.teiiduserexample.url etc (please note Ds suffix was missing for all spring.datasource related keys)
C]Changes made in Pom.xml
- A. C.1] changed version for spring-boot-starter-parent
Changed spring-boot-starter-parent version from 1.3.5 to 1.5.3. it is inline with demo project.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
</parent>
- A. C.2]Added dependency for jdbc
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
D] Changes in TeiidUser Entity
- A. D.1] Added explicit Table annotation for TeiidUser
- B. D.2]replace teiiduserexample to teiiduserexampleDs
Please refer in code marked in bold
@Entity
@Table (name="TEIIDUSER")
@SelectQuery( " select thisAppUser.userid," +
" externalUser.age,"
+" thisAppUser.firstname,"
+" externalUser.gender "
+" thisAppUser.username,"
+" from teiiduserexampleDs.TEIIDUSER as thisAppUser,"
+" external_system_user as externalUser "
+" WHERE thisAppUser.username=externalUser.username ")
public class TeiidUSER implements Serializable {
//fields
}
E] For External user added explicit Table annotation
@Entity
@Table (name="external_system_user")
@JsonTable(endpoint="http://<IP:PORT>/findAllUsersfromExternal" ,rootIsArray=true)
public class ExternalSystemUser implements Serializable{
Logs Observation
A] Found logs for VDB in console
2017-10-06 12:40:07.704 INFO 8968 --- [ main] o.h.e.j.e.i.LobCreatorBuilderImpl : HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
2017-10-06 12:40:08.118 INFO 8968 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-10-06 12:40:09.126 INFO 8968 --- [ main] o.t.spring.autoconfigure.TeiidServer : Added teiiduserexampleDs to the Teiid Database
2017-10-06 12:40:09.127 INFO 8968 --- [ main] org.teiid.RUNTIME.VDBLifeCycleListener : TEIID40120 VDB spring.1.0.0 will be removed from the repository
2017-10-06 12:40:09.128 INFO 8968 --- [ main] org.teiid.RUNTIME.VDBLifeCycleListener : TEIID40119 VDB spring.1.0.0 removed from the repository
2017-10-06 12:40:09.149 INFO 8968 --- [ main] org.teiid.RUNTIME.VDBLifeCycleListener : TEIID40118 VDB spring.1.0.0 added to the repository
2017-10-06 12:40:09.586 INFO 8968 --- [ main] org.teiid.CONNECTOR : OracleExecutionFactory Commit=true;DatabaseProductName=Oracle;DatabaseProductVersion=Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production;DriverMajorVersion=12;DriverMajorVersion=1;DriverName=Oracle JDBC driver;DriverVersion=12.1.0.1.0;IsolationLevel=2
2017-10-06 12:40:09.978 WARN 8968 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'teiiduserexampleDs' defined in class path resource [com/mastekpoc/teiidpoc/DataSources.class]: Initialization of bean failed; nested exception is org.teiid.metadata.DuplicateRecordException: TEIID60013 Duplicate Table USERS
2017-10-06 12:40:09.979 INFO 8968 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-10-06 12:40:09.980 INFO 8968 --- [ main] o.s.j.d.e.EmbeddedDatabaseFactory : Shutting down embedded database: url='jdbc:teiid:spring;useCallingThread=true;autoFailover=true;waitForLoad=5000;autoCommitTxn=OFF'
2017-10-06 12:40:10.413 INFO 8968 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2
B]And got following exception
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'teiiduserexampleDs' defined in class path resource [com/mypoc/teiidpoc/DataSources.class]: Initialization of bean failed; nested exception is org.teiid.metadata.DuplicateRecordException:
TEIID60013 Duplicate Table USERS
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
Caused by: org.teiid.metadata.DuplicateRecordException: TEIID60013 Duplicate Table USERS
at org.teiid.metadata.Schema.addTable(Schema.java:47) ~[teiid-api-10.0.0.Beta3-SNAPSHOT.jar:10.0.0.Beta3-SNAPSHOT]
at org.teiid.metadata.MetadataFactory.addTable(MetadataFactory.java:181) ~[teiid-api-10.0.0.Beta3-SNAPSHOT.jar:10.0.0.Beta3-SNAPSHOT]
at org.teiid.translator.jdbc.JDBCMetdataProcessor.addTable(JDBCMetdataProcessor.java:379) ~[translator-jdbc-10.0.0.Beta3-SNAPSHOT.jar:10.0.0.Beta3-SNAPSHOT]
at org.teiid.translator.jdbc.JDBCMetdataProcessor.addTable(JDBCMetdataProcessor.java:362) ~[translator-jdbc-10.0.0.Beta3-SNAPSHOT.jar:10.0.0.Beta3-SNAPSHOT]
at org.teiid.translator.jdbc.JDBCMetdataProcessor.getTables(JDBCMetdataProcessor.java:335) ~[translator-jdbc-10.0.0.Beta3-SNAPSHOT.jar:10.0.0.Beta3-SNAPSHOT]