Closed mcam11 closed 5 years ago
Please upload a sample application replicating the problem. Also, look into the Demo App.
I was able to reproduce with the following two domains. If I remove the 3 mentions of 'company' from within the Employee domain, then all works fine.
class Company {
static searchable = {
only = ['companyName', 'state', 'country']
}
static hasMany = [employees: Employee]
String companyName
String address
String address2
String city
String state
String country
Date created = new Date()
static constraints = {
companyName(blank: false, size: 1..255)
address(blank: false, size: 1..255)
address2(nullable: true, maxSize: 255)
city(blank: false, size: 1..255)
state(nullable: true)
country(nullable: true)
}
static mapping = {
table 'COMPANY'
}
}
and
class Employee {
static searchable = {
only = ['name', 'email', 'position']
}
static belongsTo = [Company]
String name
String email
String position
Double salary
Date created = new Date()
Company company
static constraints = {
email email: true
company(nullable: true)
}
static mapping = {
table 'EMPLOYEE'
}
}
I started with a new Grails project. Added these two domains + crud.
Added the following to my build.gradle (the runtime mapper-attachments was necessary) and I used a MySQL database to store data. The error happens when you start up the application with stored data that then needs to be indexed on app startup.
def esVersion = '5.4.1'
ext['elasticsearch.version'] = esVersion
dependencies {
compile 'org.grails.plugins:elasticsearch:2.4.0'
runtime "org.elasticsearch.plugin:mapper-attachments:2.4.6"
runtime "mysql:mysql-connector-java:5.1.37"
}
Created an application.groovy with these contents (to go along with existing application.yml):
elasticSearch.datastoreImpl = 'hibernateDatastore'
elasticSearch.client.mode = 'local'
elasticSearch.migration.strategy = 'delete'
elasticSearch.disableAutoIndex = false
elasticSearch.bulkIndexOnStartup = true
Modified application.yml to use a MySQL database for prod:
dataSource:
pooled: true
jmxExport: true
driverClassName: com.mysql.jdbc.Driver
username: sa
password: ''
environments:
development:
dataSource:
dbCreate: create-drop
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: update
url: jdbc:mysql://localhost:3306/mydb
username: 'mydbuser'
password: 'mydbpassword'
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: true
I created an empty MySQL database with db permissions, launched app (grails prod run-app), and created a company and employee. Shutdown app. Relaunched and got the error.
I'm not sure how to upload a sample application.
Also meant to say that I can search one domain or the other, but not both. So if I comment out "static searchable ..." on Company, it works for Employee, and vice versa.
I think the issue is that my Employee domain contains an instance of my Company domain and that instance can be null.
If I get rid of the following constraint in my Employee domain, it works; I am able to successfully launch the application ten out of ten times with no indexing issues of my data.
static constraints = {
...
company(nullable: true)
}
Also, when it doesn't work (the original domains above) it is intermittent. If I run the app and create 3 companies and 3 employees, then exit, when I restart the app ten times it fails about five times with the original error shown above.
From your latest comment, it seems like the issue is not with Elasticsearch plugin.
Also, you can follow Grails Guide as a starting point for your project.
To answer your questions "I'm not sure how to upload a sample application." You can create a sample application with minimum code, demonstrating the problem and then push it to a new GitHub repository so that I can test it by myself.
I think I ran across this same issue, had to do with Hibernate proxies not being unwrapped in IndexRequestQueue
and JSONDomainFactory
.
I'll try to submit a pull request with the fix as soon as I can.
I think I ran across this same issue, had to do with Hibernate proxies not being unwrapped in
IndexRequestQueue
andJSONDomainFactory
.I'll try to submit a pull request with the fix as soon as I can.
I was having exactly the same issue (Grails 3.3.2, ES Plugin 2.4.1 and Hibernate) and this fix resolved it.
I am new to ElasticSearch (was using Searchable plugin before with Grails 2.4.4) and am getting the following error when starting up my Grails 3.3.2 application. Note: previously I submitted issue #214 which was fixed, but am now getting a different error.
Here is my build.gradle:
Here is my configuration code from application.groovy: