0

So working with grails run-app VS war file.

My expectation was that all I have to do to generate a war file and throw it into Tomcat was to type in war

Code below works fine on the RUN-APP console. Code stripped down to what is not working.

package foo
import groovy.sql.Sql;
class FooAlertJob {
    static triggers = {
      simple name: 'mySimpleTrigger',  startDelay:5000, repeatInterval: 1000*10l
    }

    def dataSourceFoo

    def execute() {

        def sql = new Sql (dataSourceFoo)
    }
}

When running with tomcat and a war file built from grails I am getting (pasted below)

Cannot resolve which method to invoke for [null] due to overlapping prototypes between: [interface javax.sql.DataSource] [interface java.sql.Connection]]

Googling around I did not find a solution so perhaps I am just dense.

What do I have to do to my groovy so that when I generate a war file I do not have to worry about re-testing it all ?

I have tried the obvious about fully qualifying sql as groovy.sql.SQL but I do not have a clear example of working code from run-app to war file.

Also frustrating is the groovy / grails docs does not even mention it so I am wondering if I just don't understand basics here. I am clear on runtime groovy VS compile time but still you would think that examples you copy/paste from grails documentation would work if you produced a war file.

java 1.8 Grails 2.5.3 Groovy 2.4.5

[interface java.sql.Connection] [See nested exception: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method groovy.sql.Sql#. Cannot resolve which method to invoke for [null] due to overlapping prototypes between: [interface javax.sql.DataSource] [interface java.sql.Connection]]

Don
  • 98
  • 1
  • 4
  • 10
  • `datasourceFoo` is null – tim_yates Jan 10 '16 at 21:03
  • No it is not null. This is a grails application. It is defined in DataSource.groovy and works just like you see it in the grails console running the command run-app – Don Jan 10 '16 at 21:16
  • 1
    Yes it is null. That's what the error says – tim_yates Jan 10 '16 at 22:05
  • Please show your DataSource.groovy. – Sandeep Poonia Jan 11 '16 at 03:42
  • dataSourceFoo { loggingSql = true username = "reader" password = "reader1" readOnly = TRUE url = "jdbc:sqlserver://localhost:1433;databaseName=Reports" driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver" dialect = "org.hibernate.dialect.SQLServerDialect" } – Don Jan 11 '16 at 21:53
  • Sorry for the past above. Again the code is fine when running from grails prompt run-app. Its when you "war" it up it gets the above issue. – Don Jan 11 '16 at 21:53
  • I have this same error and ALSO missed the [null]. Thanks! – Steve Feb 21 '17 at 11:35

1 Answers1

0

war file generated by Grails ignores dataSource URL

Looks like it was a palm slap to the forehead.

The Datasource needs to be defined in the production environment as that is what the war file is expecting.

Thanks everyone.

Community
  • 1
  • 1
Don
  • 98
  • 1
  • 4
  • 10