I am using grails 2.2.3 , mongodb 1.3.3 the curd operation is working fine.
I want to log my curd operation
so i use audit-logging plugin "audit-logging:1.0.0",it work fine with mysql-database but not with mongodb.It shows
Error 2014-05-05 15:45:04,117 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Cannot get property 'datastores' on null object
Message: Cannot get property 'datastores' on null object
Line | Method
->> 90 | doCall in AuditLoggingGrailsPlugin$_closure1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 303 | innerRun in java.util.concurrent.FutureTask$Sync
| 138 | run . . in java.util.concurrent.FutureTask
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . in ''
^ 662 | run in java.lang.Thread
Any one came across this issue.
help me to solve this.
Thanks in advance. cheers..
I suggest your report the issue http://jira.grails.org/browse/GPAUDITLOGGING
Related
I'm using gorm in grails to connect to MongoDB. I'm getting MongoTimeOutException.
I'm able to successfully connect to MongoDb using mongo java driver stand alone program.
Why am i not able to connect through Grails GORM plugin?
Can someone help?
The below is the configuration
grails {
mongo {
host = "localhost"
port = 27107
databaseName = "test"
options{
connectionsPerHost=20
}
}
}
The below is domain class
class Device {
String deviceType
String deviceId
int primary
static constraints = {
}
}
The below is the exception trace
| Error 2014-11-09 16:10:39,620 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver - MongoTimeoutException occurred when processing request: [GET] /devices/Device
Timed out while waiting to connect after 10000 ms. Stacktrace follows:
Message: Timed out while waiting to connect after 10000 ms
Line | Method
->> 131 | getDescription in com.mongodb.BaseCluster
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 396 | getClusterDescription in com.mongodb.DBTCPConnector
| 569 | getType . . . . . . . in ''
| 370 | isMongosConnection in ''
| 645 | isMongosConnection . in com.mongodb.Mongo
| 454 | _check in com.mongodb.DBCursor
| 546 | _hasNext . . . . . . in ''
| 571 | hasNext in ''
| 1893 | hasNext . . . . . . . in org.grails.datastore.mapping.mongo.query.MongoQuery$MongoResultList$1
| 8 | index in ewents.DeviceController
| 198 | doFilter . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 895 | runTask . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
| 918 | run in ''
^ 695 | run . . . . . . . . . in java.lang.Thread
or could someone share sample Grails example with GORM support? Am basically new to this Grails.
I figured out the issue. It's my bad, given the port number as 27107 instead of 27017 and i took a day to figure this out. LOL
I had a similar problem, and it showed out that in my test case, I didn't get the properties from where I expected. (My host contained a quotation mark in teh string...)
My suggestion for developers with this issue in the future is to set a breakpoint in com.mongodb.mongo.java in method "boolean isMongosConnection()" and see what host and port that is actually used.
I am trying to search for users with particular role using createCriteria().I have three domain classes: User, Role and UserRole (they are from SpringSecurity).
class UserRole implements Serializable {
User user
Role role
static constraints = {
user nullbale: false
role nullable: false
}
static mapping = {
version: false
id composite: ['role', 'user']
}
}
I am searching on isActive, name or username fields on User Domain and authority field on Role Domain .
def c = UserRole.createCriteria()
def results = c {
user {
eq("isActive", true)
or {
ilike("name", "somename")
ilike("username", "someusername")
}
}
role {
eq("authority", "ROLE_USER")
}
}
On running this I get UnsupportedOperationException from mongo plugin. Here is stacktrace
ERROR errors.GrailsExceptionResolver - UnsupportedOperationException occurred when processing request: [GET] /users/search - parameters:
query:
Join queries are not supported by MongoDB. Stacktrace follows:
Message: Join queries are not supported by MongoDB
Line | Method
->> 162 | handle in org.grails.datastore.mapping.mongo.query.MongoQuery$2
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 142 | handle in ''
| 1091 | populateMongoQuery in org.grails.datastore.mapping.mongo.query.MongoQuery
| 993 | executeQuery in org.grails.datastore.mapping.mongo.query.MongoQuery$58
| 861 | doInDB . . . . . . in ''
| 833 | doInDB in ''
| 542 | list . . . . . . . in org.grails.datastore.mapping.query.Query
| 325 | invokeMethod in grails.gorm.CriteriaBuilder
| 17 | $tt__searchUsers . in com.themopi.apis.searchactivity.SearchService
| 29 | searchUser in com.themopi.apis.search.SearchController
| 198 | doFilter . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 106 | processFilterChain in com.odobo.grails.plugin.springsecurity.rest.RestTokenValidationFilter
| 72 | doFilter in ''
| 53 | doFilter . . . . . in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
I found a Jira on this issue but it is unresolved.
Any work around for this till now as jira was created on 09/Mar/12 or I am missing something?
I will be using pagination and projections in this query?
Any help or guidance is highly appreciated.
Thanks in advance.
there's an excellent article from Burt on this topic.
One of the main parts of it is, that the security model should be implemented with embedded/sub-doc entities. Actually joins shouldn't be used with mongo at all, and if you need those, use a RDBMS or Graph DB.
Anyone knows if Spring Security Core Plugin is compatible with mongoDB GORM Plugin ? I have three domain classes "User, Role, and UserRole", I added static mapWith ='mongo' to "'User, and Role" in order to make Spring Security Core Plugin read from mongoDB rather than Hibernate/MySQL but I get the following Exception, I know that Spring Security Core Plugin is trying to use Hibernate to join and map data across these tables, I wanna know if I can intercept that and make it redirect to MongoDB Rather than Hibernate :
|Running Grails application
Configuring Spring Security Core ...
... finished configuring Spring Security Core
Error |
2013-11-30 13:22:56,976 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table user_role refers to an unmapped class: com.myProject.Role
Message: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table user_role refers to an unmapped class: com.myProject.Role
Line | Method
->> 104 | postProcessBeanFactory in org.grails.datastore.gorm.plugin.support.PersistenceContextInterceptorAggregator
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 262 | run in java.util.concurrent.FutureTask
| 1145 | runWorker . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run . . . . . . . . . in java.lang.Thread
Caused by MappingException: An association from the table user_role refers to an unmapped class: com.myProject.Role
->> 104 | postProcessBeanFactory in org.grails.datastore.gorm.plugin.support.PersistenceContextInterceptorAggregator
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 262 | run in java.util.concurrent.FutureTask
| 1145 | runWorker . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run . . . . . . . . . in java.lang.Thread
Error |
Forked Grails VM exited with error
I am using Grails 2.2.0 and MongoDB. I have configured Grails to run against MongoDB instead of the default H2 in memory database. From the error message h2 seems to be involved even though I think I removed it.
My DataSource.groovy:
grails {
mongo {
host = "localhost"
port = 27017
databaseName = "physicians"
}
}
My BuildConfig.groovy:
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.8.0"
runtime ":resources:1.1.6"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"
build ":tomcat:$grailsVersion"
runtime ":database-migration:1.1"
compile ':cache:1.0.0'
compile ':mongodb:1.1.0.GA'
}
The error I get when i want to save a domain object Artist is:
| Error 2013-01-03 22:33:18,881 [http-bio-9090-exec-1] ERROR util.JDBCExceptionReporter - Table "ARTIST" not found; SQL statement:
insert into artist (id, version, artist_name, birth_name) values (null, ?, ?, ?) [42102-164]
| Error 2013-01-03 22:33:19,050 [http-bio-9090-exec-1] ERROR errors.GrailsExceptionResolver - JdbcSQLException occurred when processing request: [GET] /musicstack/artist/
Table "ARTIST" not found; SQL statement:
insert into artist (id, version, artist_name, birth_name) values (null, ?, ?, ?) [42102-164]. Stacktrace follows:
Message: Table "ARTIST" not found; SQL statement:
insert into artist (id, version, artist_name, birth_name) values (null, ?, ?, ?) [42102-164]
Line | Method
->> 329 | getJdbcSQLException in org.h2.message.DbException
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 169 | get in ''
| 146 | get . . . . . . . . in ''
| 4753 | readTableOrView in org.h2.command.Parser
| 4731 | readTableOrView . . in ''
| 954 | parseInsert in ''
| 375 | parsePrepared . . . in ''
| 279 | parse in ''
| 251 | parse . . . . . . . in ''
| 217 | prepareCommand in ''
| 415 | prepareLocal . . . in org.h2.engine.Session
| 364 | prepareCommand in ''
| 1121 | prepareCommand . . in org.h2.jdbc.JdbcConnection
| 71 | <init> in org.h2.jdbc.JdbcPreparedStatement
| 267 | prepareStatement . in org.h2.jdbc.JdbcConnection
| 1051 | prepareStatement in ''
| 508 | prepareStatement . in org.apache.commons.dbcp.DelegatingConnection
| 400 | prepareStatement in org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
| 7 | index . . . . . . . in musicstack.ArtistController
| 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter . . . . . in grails.plugin.cache.web.filter.AbstractFilter
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . . . . . . . in ''
^ 680 | run in java.lang.Thread
What am I missing here?
Best regards /Lasse
====================================
Got it working.
First I had to remove the line
runtime ":hibernate:$grailsVersion"
from the BuildConfig.groovy
When I did that I got this:
| Error Fatal error during compilation org.apache.tools.ant.BuildException:
java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
(NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
I then removed the line
runtime ":database-migration:1.1"
from BuildConfig.groovy
This last part was not found when searching to solve this problem. Is this the way it is supposed to be done?
/Lasse
To use mongodb gorm stand alone in your project, you need to comment out
compile ':cache:1.0.0'
in your BuildConfig, because cache plugin depends on hibernate. You can find it in the source code as:
plugins {
....
runtime(":hibernate:$grailsVersion") {
export = false
}
....
}
I had to remove Hibernate plugin from application.properties too for it to work. I am not sure why hibernate plugin was configured in application.properties
You had uninstalled the hibernate, so you need another plugin about mongodb.
you cound add a line
compile ':mongodb:1.0.0.GA'
from BuildConfig.groovy instead of
runtime ":hibernate:$grailsVersion"
I am working to set up grails on a local system and am working through the tutorials at:
http://www.youtube.com/watch?v=PXHxo43hn34&feature=relmfu
However, all the controller and domain class files compile correctly, but I receive the errors listed below whenever I try to execute the app
I had difficulties installing the plugins because the componenets could not be accessed, and installed all necessary plugins that I could reach, but am unsure if these are the source of the problem.
| Loading Grails 2.0.4
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 1 source files.....
| Running Grails application
| Error 2012-05-24 10:24:21,801 [pool-7-thread-1] ERROR context.GrailsContextLoader - Error executing bootstraps: 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': Invocation of init method failed; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: org.example.pomodoro.Task.details() is applicable for argument types: (java.util.LinkedHashMap) values: [[blank:false]]
Possible solutions: getAll(), getDetials(), getTags(), getId(), equals(java.lang.Object), setDetials(java.lang.String)
Message: 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': Invocation of init method failed; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: org.example.pomodoro.Task.details() is applicable for argument types: (java.util.LinkedHashMap) values: [[blank:false]]
Possible solutions: getAll(), getDetials(), getTags(), getId(), equals(java.lang.Object), setDetials(java.lang.String)
Line | Method
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by 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': Invocation of init method failed; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: org.example.pomodoro.Task.details() is applicable for argument types: (java.util.LinkedHashMap) values: [[blank:false]]
Possible solutions: getAll(), getDetials(), getTags(), getId(), equals(java.lang.Object), setDetials(java.lang.String)
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: org.example.pomodoro.Task.details() is applicable for argument types: (java.util.LinkedHashMap) values: [[blank:false]]
Possible solutions: getAll(), getDetials(), getTags(), getId(), equals(java.lang.Object), setDetials(java.lang.String)
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: org.example.pomodoro.Task.details() is applicable for argument types: (java.util.LinkedHashMap) values: [[blank:false]]
Possible solutions: getAll(), getDetials(), getTags(), getId(), equals(java.lang.Object), setDetials(java.lang.String)
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by MissingMethodException: No signature of method: org.example.pomodoro.Task.details() is applicable for argument types: (java.util.LinkedHashMap) values: [[blank:false]]
Possible solutions: getAll(), getDetials(), getTags(), getId(), equals(java.lang.Object), setDetials(java.lang.String)
->> 16 | doCall in org.example.pomodoro.Task$__clinit__closure1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Thanks for the help.
The original error is a MissingMethodException in org.example.pomodoro.Task for the details field. I'm assuming it has to do with setting constraints as it's complaining about setting [blank:false]. This root error can be seen at the end of the first long Error line in your trace.
Because suggested solutions on the next line are getDetials() and setDetials(), do you have a typo in your domain class for the property details -> detials?