Announcement Announcement Module
Collapse
No announcement yet.
Grails 2.0.4 Oracle in STS - driver not found (though it's in the build path) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Grails 2.0.4 Oracle in STS - driver not found (though it's in the build path)

    I was building a new Grails application with 2.0.4 (it's been a couple of years since I've done this) and I keep getting an error running an Integration test for a service class. It's telling me that the OracleDriver class is not found. I've added ojdbc14.jar to the /lib directory, added it to the Libraries in the build path, and have the following DataSource.groovy

    Code:
    dataSource {
    	pooled = true
    	driverClassName = "oracle.jdbc.OracleDriver"
    	dialect = "org.hibernate.dialect.Oracle10gDialect"
    }
    hibernate {
    	cache.use_second_level_cache = true
    	cache.use_query_cache = false
    	cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
    }
    // environment specific settings
    environments {
    	development {
    		dataSource {
    			url = "jdbc:oracle:thin:@devserver:1528:dev"
    			userName = "USER"
    			password  = "****"
    		}
    	}
    	test {
    		dataSource {
    			url = "jdbc:oracle:thin:@testserver:1528:ist"
    			userName = "USER"
    			password  = "****"
    		}
    	}
    	... more
    }
    I've create an integration test for the service, and when (in STS) I run tests with test-app, I get the classic "Cannot load JDBC driver class 'oracle.jdbc.OracleDriver" error. I expect this when I don't have the jar in the /lib directory, or haven't added that to the build path. I've done all this before, and either something has changed, or I'm missing something easy.

    Here's my versions:
    Grails 2.0.4
    SpringSource Toolsuite 2.9.2
    Groovy 1.8.6
    Oracle 11g

    Thanks for your responses!

    Brian

  • #2
    Run "grails compile --refresh-dependencies". Putting jars in the lib directory is still supported (although adding dependencies in BuildConfig.groovy is the preferred approach) but they're not auto-discovered.

    Comment


    • #3
      Originally posted by burtbeckwith View Post
      Run "grails compile --refresh-dependencies". Putting jars in the lib directory is still supported (although adding dependencies in BuildConfig.groovy is the preferred approach) but they're not auto-discovered.
      Burt,

      I did that, from the STS command prompt, and that didn't work. BuildConfig.groovy uses Mavenish style, but how would I add a dependency to a local file (/lib/ojdbc.jar)? I'll put it in there.

      Brian

      Comment


      • #4
        The STS classpath is derived from the Grails classpath; run Project | Grails Tools | Refresh Dependencies to sync up STS and Grails. Try doing this outside of the IDE to reduce the number of concurrent variables, then get STS working.

        Comment


        • #5
          None of those suggestions has made a difference. I did a refresh-dependencies from the command line, and from STS and I still get the same error. When I look at the classpath section in STS I see the JRE System Library, the Grails Dependencies, and the Groovy DSL support, but the /lib directory and that jar are missing.

          Can I configure this from BuildConfig.groovy?

          How would I add this jar to it, since it's not Mavenish?

          Brian

          Comment


          • #6
            Originally posted by bgardner View Post
            Can I configure this from BuildConfig.groovy? How would I add this jar to it, since it's not Mavenish?
            Ok, I added the following line to my BuildConfig.groovy:

            Code:
            runtime 'com.oracle:ojdbc14:10.2.0.1.0'
            I set the log level to 'warn' and ran the test again. I saw one of the places was the location of the jars in the /dist directory under the grails-2.0.4 product directory. I copied the jar file there, and then ran the test again. The original error no longer occurs; instead there's a new error:

            Code:
            Error Error executing script TestApp: 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 '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 create PoolableConnectionFactory (invalid arguments in call)
            I guess we're getting somewhere... Much of this wouldn't be a problem if I could get to Maven repositories outside of our network. They recently cut us off, and put a Nexus instance inside the org, but with a minimum set of projects/jars. If you want one that they don't have, you have to submit a request to a committee that decides if your request is valid. Then you wait.

            Brian
            Last edited by bgardner; Oct 5th, 2012, 10:01 AM.

            Comment

            Working...
            X