I have been trying to create a lib of domain class(which uses GORM dependancy, Gradle build) which can be included as a dependency to my Grails Applications, as they are common domain classes used across three grails applications.
The goal is to have a common set of domain class rather than copying domain classes across the application.
But when I use this into my other Grails application, it creates a table into the database from that domain class but field are not created.
To achieve this goal, I have created a Gradle/Groovy application, created POJO classes in my src/main/groovy/abc/xyz Annotated with
grails.gorm.annotation.Entity
I build the application, publish it into my local m2 repo, and then use it as a dependency in my other grails application.
This will then create a table into my DB but it failed to create columns. I tried annotated fields with
javax.persistence.Column
but this is not working as well.
import grails.gorm.annotation.Entity
import org.grails.datastore.gorm.GormEntity
@Entity
class People implements GormEntity<People> {
@javax.persistence.Column public String firstName
@javax.persistence.Column public String lastName
static constraints = {
firstName blank:false
lastName blank:false
}
}
when tried to create an instance this class and save it to DB from other grails application, I got the following error.
Either class [adcomm.dom.People] is not a domain class or GORM has not been initialized correctly or has already been shut down. If you are unit testing your entities using the mocking APIs. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ExceptionInInitializerError: null
at adcomm.ad.api.RestService.$tt__rssFeed(RestService.groovy:19)
at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96)
at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93)
at adcomm.ad.api.RestController.index(RestController.groovy:14)
... 3 common frames omitted
Caused by: java.lang.IllegalStateException: Either class [adcomm.dom.People] is not a domain class or GORM has not been initialized correctly or has already been shutdown. If you are unit testing your entities using the mocking APIs
... 7 common frames omitted
What am I doing wrong here, is there a better approach or solution for this. Please help/advice.
Thank you Milan
--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/196486c1-4a10-4948-a1c3-45cd716f73cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.