Announcement Announcement Module
Collapse
No announcement yet.
Grails and Oracle Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Grails and Oracle

    Hi

    I want to work with Grails and with an Oracle Database (10G). I read some tutorials, but I didn't find one which is up to date. So to the point: It is not working.

    I don't know if this correct:

    Code:
    dataSource {
        pooled = true
        url = "jdbc:oracle:thin@localhost:1521:XE"
        driverClassName = "oracle.jdbc.OracleDriver"
        username = "pete"
        password = "pete"
    }
    So it is written in the tutorial, but so it won't work. I have the .jar file "ojdbc14.jar" copied in the /lib folder. What is wrong here?

    The error which i get:
    Code:
    | Error 2012-14-03 10:15:31,966 [pool-7-thread-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 '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.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'jdbc:oracle:thin@localhost:1521:XE'
    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 '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.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'jdbc:oracle:thin@localhost:1521:XE'
       Line | Method
    ->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |   138 | run      in java.util.concurrent.FutureTask
    |   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
    |   908 | run      in     ''
    ^   662 | run . .  in java.lang.Thread
    Caused by 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.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'jdbc:oracle:thin@localhost:1521:XE'
    ->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |   138 | run      in java.util.concurrent.FutureTask
    |   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
    |   908 | run      in     ''
    ^   662 | run . .  in java.lang.Thread
    Caused by 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.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'jdbc:oracle:thin@localhost:1521:XE'
    ->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |   138 | run      in java.util.concurrent.FutureTask
    |   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
    |   908 | run      in     ''
    ^   662 | run . .  in java.lang.Thread
    I realy hope for help.

    Pete
    Arizona, Phoenix

  • #2
    The first thing to determine is if this is a grails issue or an STS issue. Try running grails run-app on the command line and see if this works for you.

    Comment


    • #3
      Hi Andrew,

      thank you for your response.
      When i run it on the command line, the same error apears. What is the great difference between running on STS with Grails plugin or on the command line?

      Greets
      Pete

      Comment


      • #4
        There really *shouldn't* be any difference between running in STS and on the command line, but in the past we have had some problems. Typically, if it runs on the command line, but not STS, then it is something that we have the expertise to look at. If, however, it does not run on the command line either, then someone on the grails team should have a look.

        I moved this thread to the Grails forum. Hopefully someone here can help.

        Comment


        • #5
          Hi lolocaust,

          I think you're just missing the Dialect line.

          I have successfully connected a Grails app to one of our Oracle 11g databases. I dropped the ojdbc14.jar into my project's lib folder and then the following settings in my dataSource.config

          driverClassName = "oracle.jdbc.driver.OracleDriver"
          dialect = "org.hibernate.dialect.Oracle10gDialect" //I know it's 10g but it works fine

          //1521 or 1522 are the standard Oracle DB ports
          url = "jdbc:oracle:thin:@com.your.serverort:1521:YOUR-INSTANCE"

          //I then placed these properties into my prod environment settings because depending on how your DB is configured,
          //Oracle may terminate your connections on its own and this will prevent your app from bombing due to a dead connection
          properties {
          maxActive = 50
          maxIdle = 25
          minIdle = 1
          initialSize = 1
          maxWait = 10000

          timeBetweenEvictionRunsMillis=60000
          numTestsPerEvictionRun=3
          minEvictableIdleTimeMillis=60000
          }
          Last edited by Brian Riley; Apr 19th, 2012, 10:04 AM.

          Comment


          • #6
            Agreed. Here's the important bit from that stack trace: " Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; "

            Comment

            Working...
            X