Using the dataSource.groovy works. When I switch to using JNDI on tomcat with a war, I get:
2014-04-14 12:16:19,244 [localhost-startStop-1] ERROR util.JDBCExceptionReporter - Table "REPORT" not found;
SQL statement: select [...] from report this_ where this_.name=? [42102-173]
This looks like its connecting to the DB ok, but cant see the table, which is bazaar.
Working config in DataSource.groovy (when I run without tomcat):
development2 {
dataSource {
url = 'jdbc:mysql://localhost/rep'
username = "root"
password = ""
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
pooled = true
jmxExport = true
dbCreate = "update"
driverClassName = "com.mysql.jdbc.Driver"
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
Not working jndi config in DataSource.groovy:
localtomcat {
dataSouce {
dbCreate = "update"
jndiName = "java:comp/env/repDB"
}
context.xml in tomcat 7:
<Resource name="repDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="5" maxWait="10000"
username="root" password="" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/rep"/>
I also tried this:
localtomcat {
dataSouce {
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
driverClassName = "com.mysql.jdbc.Driver"
dbCreate = "update"
jndiName = "java:comp/env/repDB"
}
Any ideas why it can see the DB, but not the tables (which exist, have data, and don't need updating)
Some posts say you need something in web.xml, some say you dont. I dont have anything in there.
The root user has global permissions on everything.
im building the war thus:
grails -Dgrails.env=localtomcat war
UPDATE: I should add that I actually have two datasources for each environment, the one grails uses, and another one I just query (i.e. a reporting server). This works fine outside of tomcat. the main datasource is called "datasource" and is defined below. The other one is called datasource_reporting. So my DataSource.groovy looks like this:
dataSource {
pooled = true
jmxExport = true
}
dataSource_reporting {
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
pooled = true
jmxExport = true
driverClassName = "com.mysql.jdbc.Driver"
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
environments { production{ dataSouce { dialect = org.hibernate.dialect.MySQL5InnoDBDialect driverClassName = "com.mysql.jdbc.Driver" dbCreate = "update" jndiName = "java:comp/env/rep" }
dataSource_reporting {
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
driverClassName = "com.mysql.jdbc.Driver"
jndiName = "java:comp/env/reporting"
}
}
And then I have two corresponding entires in context.xml on tomcat:
<Resource name="reporting" auth="Container" type="javax.sql.DataSource"
maxActive="20" maxIdle="5" maxWait="20000"
username="someuser" password="somepass" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://xx.xx.xx.xx:3306/somemaindb"/>
<Resource name="rep" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="5" maxWait="10000"
username="root" password="" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/rep"/>
Perhaps grails + tomcat cant handle two DB connections?
the rep DB has the report table which its complaining is missing, and the permissions of the root user are god. Perhaps grails is trying to open the reprot table on the wrong DB?