Search code examples
grailslog4jdependenciesplayorm

Grails and PlayORM


I am sorry for messy/complex description and constant editing of the question, but I am yet to pinpoint the root issue.

I am having difficulties using PlayORM with Grails: 1. There is a dependency conflict which I might have resolved by removing "logback-classic.jar" from BuildPath and "/lib" folder, but keeping "commons-logging". See below for details of the issue. 2. Now I am getting some strange PlayORM exceptions which I think are likely due to removed dependencies:

| Loading Grails 2.2.1
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Running Grails application
| Error 2013-06-18 10:38:31,057 [Thread-8] ERROR plugins.DefaultGrailsPlugin  - Cannot generate controller logic for scaffolded class class nosql.Transaction. It is not a domain class!
| Server running. Browse to http://localhost:8080/gibb
java.lang.RuntimeException: Failure scanning class(see chained exception)=class com.alvazan.orm.api.z8spi.meta.DboTableMeta
    at com.alvazan.orm.layer0.base.MyClassAnnotationDiscoveryListener.scanClass(MyClassAnnotationDiscoveryListener.java:50)
.......
**Caused by: java.lang.RuntimeException: Failure scanning field=private java.lang.String com.alvazan.orm.api.z8spi.meta.DboTableMeta.columnFamily for class=DboTableMeta
    at com.alvazan.orm.impl.meta.scan.ScannerForClass.inspectField(ScannerForClass.java:209)
    at com.alvazan.orm.impl.meta.scan.ScannerForClass.scanFields(ScannerForClass.java:202)
    at com.alvazan.orm.impl.meta.scan.ScannerForClass.scanSingle(ScannerForClass.java:122)
    at com.alvazan.orm.impl.meta.scan.ScannerForClass.addClass(ScannerForClass.java:80)
    at com.alvazan.orm.layer0.base.MyClassAnnotationDiscoveryListener.scanClass(MyClassAnnotationDiscoveryListener.java:48)
    ... 107 more
Caused by: java.lang.IllegalArgumentException: class=class com.alvazan.orm.impl.meta.data.MetaClassSingle has two fields that have @NoSqlId annotation.  One of them may be in a superclass.  The two fields are=private java.lang.String com.alvazan.orm.api.z8spi.meta.DboTableMeta.columnFamily and=private java.lang.String com.alvazan.orm.api.z8spi.meta.DboTableMeta.columnFamily
    at com.alvazan.orm.impl.meta.scan.ScannerForClass.processIdFieldWorks(ScannerForClass.java:253)
    at com.alvazan.orm.impl.meta.scan.ScannerForClass.inspectFieldImpl(ScannerForClass.java:220)
    at com.alvazan.orm.impl.meta.scan.ScannerForClass.inspectField(ScannerForClass.java:207)
    ... 111 more**

Note:


Initial problem: Basically I got following error messages when doing "run-app" or "test-app" on Grails:

| Loading Grails 2.2.1
| Configuring classpath
| Error SLF4J: Class path contains multiple SLF4J bindings.
| Error SLF4J: Found binding in [jar:file:/home/saasbook/Dropbox/Projects/GrailsWorkSpace/gibb/lib/logback-classic-1.0.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
| Error SLF4J: Found binding in [jar:file:/home/saasbook/.grails/ivy-cache/org.grails/grails-plugin-log4j/jars/grails-plugin-log4j-2.2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]

The app would run, but I would get a PlayORM exception when trying to flush the object to database:

java.lang.IllegalArgumentException: Entity type=nosql.Transaction was not scanned and added to meta information on startup.  It is either missing @NoSqlEntity annotation or it was not in list of scanned packages

Note: "Transaction.java" class does have @NoSqlEntity and is part of "nosql" package along with "Persistance.java".


The initial question:

My grails app produces hundreds of DEBUG o.c.g.g.i.s.PathMatchingResourcePatternResolver statements when I try to "run-app" or "test-app" or even "clean". The app runs from eclipse, but tests do not.

Important detail is - i checkout the app from local git repository and the original app runs perfectly fine on the same machine.


Response to comments: 1. The tests simply did not run. 2. I did not change anything in the log4j settings. 3. After posting this question I ran the original copy of the app (in different directory) and it produced the same garbage as the first one. I though the problem is grails saving app settings in ~/.grails/2.2.1/projects/{myProjectName} but it persists even with a single "version-location" of the app.


Solution

  • This question was resolved offline by passing in the ClassLoader of Transaction.class since grails was playing classloading games and playorm was int he parent classloader, Transaction.class was not visible in the classloader that loaded playorm.