user1854751
user1854751

Reputation: 107

Error when attempting Grails start up, following JDBC setup

There is a potential that I should be reusing an existing question of mine. Connecting a groovy application to SQL server Express

BUT this seems to be a bit different. The question was brought up while configuring a test application, now I am doing the real thing and this is the time that it goes really wrong.

As you can see the Jar file is in my lib and classpath

jdbc shown in ggts

my datasource is configured as below (pretty much a copy paste job from my working example)

dataSource {
username = "sa"
password = "password"
url = "jdbc:sqlserver://localhost:1433;databaseName=TimeTracker"
driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
dialect = "org.hibernate.dialect.SQLServerDialect"

and I am getting the following error on grails run-app, any advice would be welcomed with open arms

Error 2013-01-27 16:09:06,772 [localhost-startStop-1] ERROR context.GrailsContextLoader  
- Error executing bootstraps: 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 'lobHandlerDetector' while setting bean property 
'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'lobHandlerDetector': 
Invocation of init method failed; nested exception is 
org.springframework.jdbc.support.MetaDataAccessException: 
Error while extracting DatabaseMetaData; 
nested exception is org.apache.commons.dbcp.SQLNestedException: 
Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
Message: 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 'lobHandlerDetector' 
while setting bean property 'lobHandler'; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 
'lobHandlerDetector': Invocation of init method failed; nested exception is 
org.springframework.jdbc.support.MetaDataAccessException: 
Error while extracting DatabaseMetaData; nested exception is 
org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 
'com.microsoft.sqlserver.jdbc.SQLServerDriver'

Upvotes: 0

Views: 4521

Answers (2)

chanwit
chanwit

Reputation: 3214

Do grails --refresh-dependencies compile one more time, and it will be good to go.

If the problem still persists, here's additional information to double checking:

  1. Check if there's whitespace in your path. Grails does not work well if the path contains whitespace characters, especially on Windows.
  2. Check your Grails installation, and make sure it's working for a simple app.
  3. Check if your ivy cache (under ~/.grails/ or c:\<your home>\.grails) is healthy. If not, just delete it and Grails will recreate a new ivy cache for you.
  4. If no. 1-3 couldn't help, delete ~/.grails or c:\<your home>\.grails to clean everything releated to Grails, and start over.

Upvotes: 3

user1854751
user1854751

Reputation: 107

The issue to this lay largely with my version of Grails, specifically the IVY files that had been built up over time...... I pretty much have been annihilating this project since day one and each project you run in grails creates it's own config files in your home grails directory. Mine had become horribly corrupted after months of abuse.

By renaming the folder and downloading my version of grails to the expected directory again the application files were created fresh and the application was immediately able to find the SQL JDBC jar.

I owe finding this solution to ChanWit without whom I think I would have had a mental breakdown.

Upvotes: 0

Related Questions