0

Every time I modify my code I have to run grails clean before running grails run-app. If I don't, I get messages like this:

| Error 2014-02-13 16:33:16,774 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: 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 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting bean property 'targetDataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.OracleDriver]
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 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting bean property 'targetDataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.OracleDriver]
    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread

This is really odd, because it seems Grails cannot load the Oracle database driver... but it loads fine if I run

grails clean
grails run-app

This app I'm working on was upgraded today from Grails 2.2.4. The upgrade was seemless (until this). All I had to do was change the hibernate and tomcat versions then run grails upgrade; grails clean

Any ideas how I can get it so I can modify the code and just restart using grails run-app or better... get the reload functionality to work, so when I make code modifications it automatically compiles the file I just saved (this worked great in Grails 2.2.4).

Jason
  • 11,709
  • 9
  • 66
  • 82

1 Answers1

4

Have you tried grails -reloading run-app?

Since you have mentioned you have only changed the plugin versions during upgrade, I suppose you are not using forked mode where reloading is enabled by default.

Have a look at Forked Execution and the Reloading Agent. Also note that grails upgrade command has been deprecated in 2.3.*.

dmahapatro
  • 49,365
  • 7
  • 88
  • 117
  • This works for compiling files changed while Grails is running, but if I stop grails and restart, I still get this error loading driver class. I up-voted this, but I still need the other answer because now I have to do a clean every time I restart grails. Perhaps I should make these two separate questions. – Jason Feb 14 '14 at 19:24
  • Okay, I got it working! Your pointer to "Forked Execution ..." led me to enable forked execution according to the instructions at the link you gave. After enabling forked execution, I no longer have to run `grails clean` between restarts. Thanks! – Jason Feb 14 '14 at 19:30
  • Worked for me too, however be aware that the URL has since changed - it is currently http://grails.org/doc/latest/guide/upgradingFrom22.html. – Adrian Wragg Jul 09 '14 at 10:51
  • I was having the same problem, I upgraded from grails 2.2.4 to grails 2.3.11 and after doing that I had to run grails clean every time or it couldn't find my Informix database driver. Enabled forked mode fixed it for me as well. I can find no reasonable explanation why this is so. – Michael Oct 02 '15 at 22:25