Monday, April 18, 2016

How to avoid CouldNotDetermineHibernateDialectException error?

Leave a Comment

I'm upgrading oracle from 10 to 12 and for this specific project I got this error:

<[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1460078994317> <BEA-101162> <User defined listener org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [Oracle]!. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [Oracle]! 

Seems like it's not recognizing the configuration I've added on DataSource:

dataSource {     pooled = true     driverClassName = "oracle.jdbc.OracleDriver"     dialect = "org.hibernate.dialect.Oracle10gDialect" } 

We are using Java 8 and we have those dependencies on the code:

runtime 'com.oracle:ojdbc7:12.1.0.2' runtime(group: 'com.oracle', name: 'ons', version: '10.2.0.3') 

The thing is that it's working for the other project (that have the same structure as this one, but for some reason it's not working here)

Is there anything missing or anything I can to find the problem and solve the issue?

1 Answers

Answers 1

This problem happened for java version 1.7.0_25. By upgrading java 1.7.0_25 to another upper version will help you to resolve the issue. Sometimes downgrade to 1.6.X also works. But upgrading is best solution.

It is fixed in Grails 2.2.3. But in Grails 2.2.3, It is still broken for OpenJDK 1.7.0_25 on Linux, Oracle's JDK does work though.

Credit goes to @aeischeid


A step by step solution is given in this tutorial: Connect Grails with Oracle 11g Example Configuration

Resource Link:

  1. How do I avoid 'Could not determine Hibernate dialect for database name [H2]!'?

UPDATE

Suggestion - 1:

From this tutorial, I got two suggestions, please try this 2 issues- You need to install the Grails H2 plugin. Add

compile ":h2:0.2.6" 

to grails-app/conf/BuildConfig.groovy, in the plugins block.

Suggestion - 2:

In DataSource.groovy, they are case sensitive. So please check is there anything(like username or others) with case mismatching.

Resource Link: MASSIVE ERROR ON GRAILS RUN-APP

Suggestion - 3:

danielnaber gives some suggestions grails compile --refresh-dependencies and/or grails clean might help. You will need to configure database access in grails-app/conf/DataSource.groovy (development for grails run-app and production for grails war)

Suggestion - 4:

From this tutorial Remove your DataSource.groovy file and rebuild the WAR after doing a grails clean, which will disable the default file based data source

Currently it is trying to create a database on the file system but failing because you do not have the permission to do so.

Suggestion - 5:

You can take a look in https://github.com/Netflix/Lipstick/issues/8

Suggestion - 6:

While you're in there you should fix the cache provider warning you're seeing too - change the value for 'cache.provider_class' in the hibernate block to

   cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'  

Please give a try of 6 suggestions. Hope it can help you.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment