WebAPI install problem - hibernate.dialect

Hi ALL.

I’m trying to setup the ATLAS system, which requires the installation of WebAPI.
I followed the instructions for WebAPI installation and get the following error related to hibernate.dialect settings from tomcat:

2016-10-03 13:35:42.374 INFO localhost-startStop-1 org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - - Building JPA container EntityManagerFactory for persistence unit ‘default’
2016-10-03 13:36:04.326 DEBUG localhost-startStop-1 org.springframework.jdbc.datasource.DriverManagerDataSource - - Creating new JDBC DriverManager Connection to [jdbc:oracle:thin:@127.0.0.1:1521/oracle1]
2016-10-03 13:36:04.522 WARN localhost-startStop-1 org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext - - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘cohortResultsService’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.ohdsi.webapi.source.SourceRepository org.ohdsi.webapi.service.AbstractDaoService.sourceRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sourceRepository’: Cannot create inner bean ‘(inner bean)#77c2abc9’ of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property ‘entityManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘(inner bean)#77c2abc9’: Cannot resolve reference to bean ‘entityManagerFactory’ while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [org/ohdsi/webapi/DataAccessConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:117)
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108)
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:68)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5623)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.ohdsi.webapi.source.SourceRepository org.ohdsi.webapi.service.AbstractDaoService.sourceRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sourceRepository’: Cannot create inner bean ‘(inner bean)#77c2abc9’ of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property ‘entityManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘(inner bean)#77c2abc9’: Cannot resolve reference to bean ‘entityManagerFactory’ while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [org/ohdsi/webapi/DataAccessConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
… 29 more

Thanks,
Yonghui

I think I have seen this happen when the appropriate JDBC driver is not in the classpath and the Hibernate engine can’t interrogate the jdbc connection to determine the dialect.

Can you please provide the following details:
What database are you configuring WebAPI to point to?
What JDBC url are you using to connect to it?
What version of the JDBC driver are you using?

-Chris

Hi Chris,

I’m using Oracle database.
I downloaded ojdbc6.jar from oracle and installed using maven command following the instruction.
The following db URL were used : jdbc:oracle:thin:@//127.0.0.1:1521/oracle1

Thanks,
Yonghui

Here is the settings.xml file used to compile the package:
mvn clean package -s settings.xml -P webapi-oracle

<profile>
    <id>webapi-oracle</id>
    <properties>
      <datasource.driverClassName>oracle.jdbc.OracleDriver</datasource.driverClassName>
     <datasource.url>jdbc:oracle:thin:@//127.0.0.1:1521/oracle1</datasource.url>
      <datasource.username>OHDSI</datasource.username>
      <datasource.password>PASS_WORD</datasource.password>
      <datasource.dialect>oracle</datasource.dialect>
      <datasource.ohdsi.schema>OHDSI</datasource.ohdsi.schema>
      <flyway.datasource.driverClassName>${datasource.driverClassName}</flyway.datasource.driverClassName>
      <flyway.datasource.url>jdbc:oracle:thin:@//127.0.0.1:1521/oracle1</flyway.datasource.url>
      <flyway.datasource.username>OHDSI</flyway.datasource.username>
      <flyway.datasource.password> PASS_WORD </flyway.datasource.password>
      <flyway.locations>classpath:db/migration/oracle</flyway.locations>
    </properties>
</profiles>

Yonghui

Just found that I should use the following database string:
jdbc:oracle:thin:@//127.0.0.1:1521:oracle1

Here, oracle1 is the SID.

Will let you know how it works.

Thanks Chris,
Yonghui

Hi Chris,

The new database string works for Oracle. The WebAPI was started without error.
My new problem is the SOURCE and SOURE_DAIMON settings. After I insert the data sources, I tried to verify it by accessing http://localhost:8080/WebAPI/source/sources. However, I can’t get the valid data source info from WebAPI.
Here, the username for CDM has special symbols ‘C##nerCDMW’. Could that be a problem?

Here are the insert sql:
INSERT INTO ohdsi.source (source_id, source_name, source_key, source_connection, source_dialect)
VALUES (1, ‘CERNER’, ‘CERNER_CDM’, ’ jdbc:oracle:thin:ohdsi/PASS@localhost:1521:oracle1’, ‘oracle’);

INSERT INTO ohdsi.source_daimon (source_daimon_id, source_id, daimon_type, table_qualifier, priority)
VALUES (1,1,0, ‘C##nerCDMW’, 0);

INSERT INTO ohdsi.source_daimon (source_daimon_id, source_id, daimon_type, table_qualifier, priority)
VALUES (2,1,1, ‘C##nerCDMW’, 0);

INSERT INTO ohdsi.source_daimon (source_daimon_id, source_id, daimon_type, table_qualifier, priority)
VALUES (3,1,2, ‘OHDSI’, 0);

Thanks,
Yonghui

Follow up: After restarting the WebAPI several time. It finally works.

Yonghui

There’s a route you can access to reload the cached source/source_daimons:

http://localhost:8080/WebAPI/source/refresh

The set of sources and daimons is cached during startup which would explain why you didn’t see them until you restarted. The refresh route will refresh that without a restart.

-Chris

Great. Thanks, Chris.

Yonghui