My team has been trying to upgrade our existing Grails app from 1.3.7 to 2.1.0. After a lot of frustrations, including updating our entire test suite, everything is running as expected on our local machines. However, once we put the app on our WAS 8 WebSphere server we run into a strange error when trying to access any of our main pages. Below is an example
No signature of method: com.app.Product.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure). Stacktrace follows:
groovy.lang.MissingMethodException: No signature of method: com.app.Product.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
....
Further down in the stack trace is this:
....
Caused by: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Runtime error executing action
... 47 more
Caused by: java.lang.reflect.InvocationTargetException
... 47 more
Caused by: groovy.lang.MissingMethodException: No signature of method: com.app.Product.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
at com.app.controllers.DomainTablesController$_closure2.doCall(DomainTablesController.groovy:26)
... 47 more
I added some test code to check and findAll()
, getAll()
, and list()
methods all throw the same error. I'm no Grails guru, but it looks like the standard GORM methods are missing. We use Maven to package the Grails WAR inside an EAR which is installed on the server. Here is the dependencies section of our pom.xml. It is only slightly modified from the clean version created using the grails create-pom
command.
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.8.6</version>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-dependencies</artifactId>
<version>${grails.version}</version>
<exclusions>
<exclusion>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</exclusion>
</exclusions>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-plugin-testing</artifactId>
<version>${grails.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>mail</artifactId>
<version>1.0.1</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>jquery</artifactId>
<version>1.7.2</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>resources</artifactId>
<version>1.1.6</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>webxml</artifactId>
<version>1.4.1</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
</dependencies>
Bit more info about the project: We are hanging grails on an existing DB2 legacy database. Checking the WAR Maven generates, I can see that the grails-datastore-gorm
and grails-hibernate
JARS exist. So I'm lost as to why the basic GORM methods are not accessible in the app.
Any insight or suggestions anyone has would be greatly appreciated. Thanks
EDIT:
After adding the hibernate and grails-hibernate plugin dependencies, a new error occurs when accessing the login page. Without the grails-hibernate plugin, login page shows fine and logging in works as expected. New error is:
Error Page Exception:
Error Message: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
Error Code: 0
Target Servlet:
Error Stack:
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 JDBC driver of class 'com.ibm.db2.jcc.DB2Driver' for connect URL
...
...
...
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:453)
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
... 35 more
The drivers are already set up on the server we are deploying to, and the 1.3.7 version had no issue finding the db2 drivers or connecting to the database. Thoughts?
I think hibernate was moved to a separate dependency since 2.0.*, so you might need to add the below dependencies
:
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-hibernate</artifactId>
<version>${grails.version}</version>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>hibernate</artifactId>
<version>${grails.version}</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
and remove this dependency:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.8.6</version>
</dependency>
groovy-all
is packaged in Grails by default but I am not sure if the version is 1.8.6. If you want to explicitly use 1.8.6 then exclude
groovy-all
from grails-dependencies
and then add the above dependency.
Good to have:-
If possible you can try upgrading to the most recent version of stable release of Grails 2.3.7, since you are already going through the process of upgrade.
I know this will a steep rock to climb with management. Switch to Gradle. ;)