Method on class [] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails Correctly
Asked Answered
C

3

14

PROBLEM

I know there is already a question in regards to this but I think that the issue that causes might be different based on what they are saying. I have the following setup:

  1. grails version: 2.3.4
  2. Hibernate plugin: runtime ":hibernate:3.6.10.6"
  3. My Bootstrap is empty
  4. My Controller and Service tests are commented

This grails application has multiple data sources (I am not sure if this fact has anything to do with it) and it occurs after a call against a Domain object from the second datasource which has been reversed engineered with the grails reverse engineer plugin (have done that on a separate project and then imported to my project.

This is the GORM call that causes the problem from both the Controller and the Service layers

def campusAttributes = CampusAttribute.findAllByNameLike("%Next Option%")

I have found some other complains about this and it seems to be an issue with Maven and the grails hibernate plugin version but in that scenario the issue was very particular to grails 2.3.1 and a specific hibernate plugin version.

All I did was a grails run-app (did not build the app with maven neither have any mocking)

Thanks in advance

Conradconrade answered 26/12, 2013 at 14:38 Comment(0)
D
7

I had the same problem upgrading a grails project from 2.2.4 to 2.3.6. I've upgraded the hibernate plugin from 3.6.10 to 3.6.10.8 and the error was gone.

Diestock answered 25/2, 2014 at 19:52 Comment(2)
I'm facing the problem with 3.6.10.18 hibernate version. My grails version is 2.3.8Habited
This error will also pop if you use a reserved word in mysql. dev.mysql.com/doc/refman/5.5/en/keywords.htmlPatricapatrice
L
3

I add the same error after upgrading from grails 2.3.0 to 2.3.5. What solved it in my case was to modify plugin dependencies in BuildConfig.groovy, for hibernate and tomcat to set to required level for 2.3.5 : * new tomcat : build ':tomcat:7.0.50' (old :build ":tomcat:7.0.42). * new Hibernate : runtime ':hibernate:3.6.10.7' (old : runtime ":hibernate:3.6.10.1").

Lively answered 5/2, 2014 at 11:51 Comment(0)
A
0

I have the same problem when I had moved a Domain class's package For example it was originally

com.a.DomainClass but I moved it to com.b.DomainClass

And I had not cleaned the project

Acariasis answered 30/6, 2015 at 6:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.