Debian 8.2
Java 7 + jre
Grails 2.2.4
Oracle 12c
Tomcat 7
Having troubles to startup grails after instalation Oracle 12c.
Everything working fine on Debian 8.2 + Oracle 10XE.
THX for help
app.log:
2016-01-01 20:57:43,245 [localhost-startStop-1] ERROR resource.ResourceMeta - While processing /bundle-bundle_applications_head.css, /styles/dist/gui/core/main.css, /styles/dist/gui/core/top-panel.css, /styles/dist/gui/core/footer.css, /styles/dist/gui/core/general/modal-window.css, /styles/dist/gui/core/general/metro-tiles.css, /styles/dist/gui/core/general/buttons.css, /styles/src/libs/jquery.mCustomScrollbar.css, a resource was required but not found: /styles/src/libs/mCSB_buttons.png
2016-01-01 20:57:46,005 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: groovy.lang.MissingMethodException: No signature of method: cz.test.dto.system.Client.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: cz.test.dto.system.Client.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:308)
at grails.util.Environment.executeForEnvironment(Environment.java:301)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:277)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: groovy.lang.MissingMethodException: No signature of method: cz.test.dto.system.Client.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
at cz.test.libs.core.privileges.PrivilegeApiService.generateAccessRules(PrivilegeApiService.groovy:45)
at BootStrap$_closure1.doCall(BootStrap.groovy:259)
... 8 more
2016-01-01 20:57:46,012 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing Grails: groovy.lang.MissingMethodException: No signature of method: cz.test.dto.system.Client.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: cz.test.dto.system.Client.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:308)
at grails.util.Environment.executeForEnvironment(Environment.java:301)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:277)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: groovy.lang.MissingMethodException: No signature of method: cz.test.dto.system.Client.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
at cz.test.libs.core.privileges.PrivilegeApiService.generateAccessRules(PrivilegeApiService.groovy:45)
at BootStrap$_closure1.doCall(BootStrap.groovy:259)
... 8 more
DataSource.Groovy:
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource_system {
dbCreate = "update"
pooled = true
url = "jdbc:oracle:thin:#localhost:1521:xe"
driverClassName = 'oracle.jdbc.OracleDriver'
username = "user"
password = "pass"
}
dataSource_usersettings {
dbCreate = "update"
pooled = true
url = "jdbc:oracle:thin:#localhost:1521:xe"
driverClassName = 'oracle.jdbc.OracleDriver'
username = "user"
password = "pass"
}
}
production {
dataSource_system {
dbCreate = "update"
pooled = true
url = "jdbc:oracle:thin:#localhost:1521:xe"
driverClassName = 'oracle.jdbc.OracleDriver'
username = "user"
password = "pass"
}
dataSource_usersettings {
dbCreate = "update"
pooled = true
url = "jdbc:oracle:thin:#localhost:1521:xe"
driverClassName = 'oracle.jdbc.OracleDriver'
username = "user"
password = "pass"
}
}
}
Build.Config.groovy
grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
// uncomment (and adjust settings) to fork the JVM to isolate classpaths
//grails.project.fork = [
// run: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256]
//]
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsCentral()
mavenLocal()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.22'
}
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.8.3"
runtime ":resources:1.2"
// 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.5"
build ":tomcat:$grailsVersion"
runtime ":database-migration:1.3.2"
compile ':cache:1.0.1'
}
}
anyway got this fixed by linking JAVA_HOME somehow export JAVA_HOME= didnt worked, so i used /tomcat/bin/patchclas.sh / env.sh and did some export JAVA_HOME=
and finaly got this working:)
For anyone stumbling onto this question attempting to get an old grails application to run with Oracle 12c, something I've had to do is explicitly specify the dialect in the DataSource.groovy file:
dataSource_system {
dbCreate = "update"
pooled = true
url = "jdbc:oracle:thin:#localhost:1521:xe"
driverClassName = 'oracle.jdbc.OracleDriver'
username = "user"
password = "pass"
dialect = SequencePerTableOracleDialect
}
Related
I am trying to get dependency resolution to work in Grails 2.2 from a custom repository which has username password.
I have tried adding the following in my BuildConfig.groovy
grails.project.dependency.resolver = "maven"
grails.project.ivy.authentication = {
repositories {
mavenRepo('https://maven.companyname.com/repository/repository-name') {
auth([
username: 'myusername',
password: 'mypassword'
])
}
}
}
But I get error like
Caused by: groovy.lang.MissingMethodException: No signature of method: groovy.util.ConfigSlurper$_parse_closure5.auth() is applicable for argument types: (java.util.LinkedHashMap) values:
I tried looking at https://grails.github.io/grails2-doc/2.2.0/guide/single.html#dependencyRepositories but it does not tell me more information. It does say that I need to put the credentials in settings.groovy but is that absolutely necessary? I tried putting the credentials inside mavenRepo closure but that did not work. Any ideas?
Grails 2 - quite some time ago…
This way it is working here.
BuildConfig.groovy:
…
grails.project.dependency.resolver = "ivy"
grails.project.dependency.resolution = {
repositories {
mavenRepo "https://repo.example.com/myrepo"
}
…
~/.grails/settings.groovy:
…
grails.project.ivy.authentication = {
credentials {
realm = "My Realm"
host = "repo.example.com"
username = "user"
password = "secret"
}
}
…
Just upgraded from grails 2.3.11 to 3.2.0.M2
Have a problem with dbm-gorm-diff and other dbm-* scripts
My app has multiproject structure. Domain classes placed in separate plugin.
Build.gradle
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "org.grails.plugins:hibernate5:6.0.0.M2"
classpath "org.grails.plugins:database-migration:2.0.0.RC4"
}
}
version "0.1"
group "core"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"org.grails.grails-plugin"
apply plugin:"org.grails.grails-plugin-publish"
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.grails:grails-dependencies"
compile "org.grails.plugins:hibernate5"
compile "org.grails.plugins:cache"
compile "org.hibernate:hibernate-core:5.1.0.Final"
compile "org.hibernate:hibernate-ehcache:5.1.0.Final"
console "org.grails:grails-console"
profile "org.grails.profiles:plugin:3.2.0.M2"
provided "org.grails:grails-plugin-services"
provided "org.grails:grails-plugin-domain-class"
provided 'javax.servlet:javax.servlet-api:3.1.0'
runtime "org.grails.plugins:database-migration:2.0.0.RC4"
runtime "mysql:mysql-connector-java:5.1.39"
testCompile "org.grails:grails-plugin-testing"
}
grailsPublish {
// TODO: Provide values here
user = 'user'
key = 'key'
githubSlug = 'app/core'
license {
name = 'Apache-2.0'
}
title = "Core"
desc = "***"
developers = ["***"]
portalUser = ""
portalPassword = ""
}
sourceSets {
main {
resources {
srcDir "grails-app/migrations"
}
}
}
application.yml
grails:
profile: plugin
codegen:
defaultPackage: core
spring:
transactionManagement:
proxies: false
info:
app:
name: '#info.app.name#'
version: '#info.app.version#'
grailsVersion: '#info.app.grailsVersion#'
spring:
groovy:
template:
check-template-location: false
---
grails:
plugin:
databasemigration:
updateOnStart: true
updateOnStartFileNames:
- changelog.groovy
- changelog-part-2.groovy
hibernate:
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
dataSource:
dbCreate: none
driverClassName: "com.mysql.jdbc.Driver"
dialect: "org.hibernate.dialect.MySQL5InnoDBDialect"
url: "jdbc:mysql://localhost:3306/project?zeroDateTimeBehavior=convertToNull&autoreconnect=true&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8"
username: "root"
password: "root"
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: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
Stacktrace
2016-08-16 18:57:06.731 WARN 5736 --- [ main] o.s.mock.web.MockServletContext : Couldn't determine real path of resource class path resource [src/main/webapp/WEB-INF/sitemesh.xml]
java.io.FileNotFoundException: class path resource [src/main/webapp/WEB-INF/sitemesh.xml] cannot be resolved to URL because it does not exist
at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187) ~[spring-core-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:48) ~[spring-core-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.mock.web.MockServletContext.getRealPath(MockServletContext.java:458) ~[spring-test-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.grails.web.sitemesh.Grails5535Factory.<init>(Grails5535Factory.java:78) [grails-web-sitemesh-3.2.0.M2.jar:3.2.0.M2]
at org.grails.web.servlet.view.SitemeshLayoutViewResolver.loadSitemeshConfig(SitemeshLayoutViewResolver.java:105) [grails-web-gsp-3.2.0.M2.jar:3.2.0.M2]
at org.grails.web.servlet.view.SitemeshLayoutViewResolver.init(SitemeshLayoutViewResolver.java:67) [grails-web-gsp-3.2.0.M2.jar:3.2.0.M2]
at org.grails.web.servlet.view.SitemeshLayoutViewResolver.onApplicationEvent(SitemeshLayoutViewResolver.java:146) [grails-web-gsp-3.2.0.M2.jar:3.2.0.M2]
at org.grails.web.servlet.view.SitemeshLayoutViewResolver.onApplicationEvent(SitemeshLayoutViewResolver.java:42) [grails-web-gsp-3.2.0.M2.jar:3.2.0.M2]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:382) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:336) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:877) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
at grails.boot.GrailsApp.run(GrailsApp.groovy:55) [grails-core-3.2.0.M2.jar:3.2.0.M2]
at grails.ui.command.GrailsApplicationContextCommandRunner.run(GrailsApplicationContextCommandRunner.groovy:55) [grails-console-3.2.0.M2.jar:3.2.0.M2]
at grails.ui.command.GrailsApplicationContextCommandRunner.main(GrailsApplicationContextCommandRunner.groovy:102) [grails-console-3.2.0.M2.jar:3.2.0.M2]
2016-08-16 18:57:07.035 INFO 5736 --- [ main] .c.GrailsApplicationContextCommandRunner : Started GrailsApplicationContextCommandRunner in 21.719 seconds (JVM running for 23.484)
2016-08-16 18:57:07.035 INFO 5736 --- [ main] grails.boot.GrailsApp : Application starting in environment: development
Command execution error: Bean named 'sessionFactory' must be of type [org.springframework.beans.factory.FactoryBean], but was actually of type [org.hibernate.internal.SessionFactoryImpl]
2016-08-16 18:57:07.185 INFO 5736 --- [ Thread-7] g.u.s.DevelopmentWebApplicationContext : Closing grails.ui.support.DevelopmentWebApplicationContext#2abc224d: startup date [Tue Aug 16 18:56:48 MSK 2016]; root of context hierarchy
2016-08-16 18:57:07.382 INFO 5736 --- [ Thread-7] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase -2147483648
2016-08-16 18:57:07.406 INFO 5736 --- [ Thread-7] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
Can you help me?
Already found it. This is known issue - https://github.com/grails-plugins/grails-database-migration/issues/81
Discussed here: Grails 3 schemaExport contains warning with FileNotFoundException that looks for sitemesh.xml
You can ignore it. Still a problem in Grails 4.
I want to make a web-app using Grails framework for the server part and Neo4j database for storage. I found the Neo4j GORM plugin on Grails site, but unfortunately after numerous attempts I could not make it work properly. If i solve one error I get more, i can't even set a basic app to work. So I would like to write my own code for handling CRUD operations. I would like to override the default CRUD operations for domain classes. For example when I save a Person entity, i would use the REST API offered by Neo4j database to store the entity there etc. Would this be an acceptable solution? If yes, then how should I proceed about overriding the CRUD methods for domain classes?
Problem i had with GORM plugin: I followed the steps described in the documentation : http://projects.spring.io/grails-data-mapping/neo4j/manual/guide/gettingStarted.html . I created a simple Grails web-app, included the Neo4j-GORM plugin dependency. The application started.
If I try to access 'org.grails.datastore.gorm.neo4j.Neo4jController' I get some strange errors:
Here are the errors I get in the console:
015-01-04 14:11:22,460 [http-bio-8080-exec-2] ERROR errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [GET] /ANewHope/neo4j/node
Cannot invoke method getNodeById() on null object. Stacktrace follows:
Message: Cannot invoke method getNodeById() on null object
Line | Method
->> 30 | doCall in org.grails.datastore.gorm.neo4j.Neo4jController$_closure2
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Here is my BuildConfig.groovy:
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the test-app JVM, uses the daemon by default
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the run-app JVM
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the run-war JVM
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
mavenRepo 'http://m2.neo4j.org/releases'
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.29'
// runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55"
// plugins for the compile step
compile ":neo4j:2.0.0-M02"
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
compile ":asset-pipeline:1.9.9"
// plugins needed at runtime but not for compilation
// runtime ":hibernate4:4.3.6.1" // or ":hibernate:3.6.10.18"
//runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
// Uncomment these to enable additional asset-pipeline capabilities
//compile ":sass-asset-pipeline:1.9.0"
//compile ":less-asset-pipeline:1.10.0"
//compile ":coffee-asset-pipeline:1.8.0"
//compile ":handlebars-asset-pipeline:1.3.0.3"
}
}
Here is DataSource.groovy:
dataSource {
pooled = true
jmxExport = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
//hibernate {
// cache.use_second_level_cache = true
// cache.use_query_cache = false
//// cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
// cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
// singleSession = true // configure OSIV singleSession mode
// flush.mode = 'manual' // OSIV session flush mode outside of transactional context
//}
//grails {
// neo4j {
// type = "embedded"
// location = "C:\\data\\neo4j"
// params = []
// }
//}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
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:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
}
After this I tried to specify the location as suggested in the documentation and added the following to DataSource.groovy:
grails {
neo4j {
type = "embedded"
location = "C:\\data\\neo4j"
params = []
}
}
The result was the same. After failed attempts I decided to try some other solution.
I want to use Neo4j for my Bachelor Thesis project, and my professor suggested me to use it with Grails. I like both Neo4j and Grails, but unfortunately I got into this problem when I tried to use them together.
If you don't want to use the GORM plugin, you could for instance use the Neo4j-JDBC driver from Grails to send parameterized Cypher Statements to the server. Much like you would do with a relational database.
There is also a new ORM in the works but it is still very much work in progress. You can find it here: https://github.com/neo4j/neo4j-ogm
As powerful as the GORM is, it isn't right for every project. I often elect to use something else, however, grails expects that anything in the domain directory is going to be using the GORM. If you want to use a different API you should just put your classes in src/groovy. If you still want to be able to use constraints for validation, you can apply the #Validatable annotation to the class. Details on that can be found in the Validation Grails docs. I would then just put all of your code to interface with the Neo4j REST API into a Grails Service.
I'm using Grails 2.2.4 to build a plugin. The plugin is an access manager and need to access some datasources (more than one). As the Grails manual specify in Providing Basic Artefacts, the DataSource.groovy is not bundled with the plugin.
Is there a way to "copy" the datasources defined on the plugin DataSource.groovy file to the application's DataSource.groovy file that uses the plugin?
I really don't want to manually define the plugin datasources on every application that uses the plugin.
============
Full stacktrace (requested in comments)
2013-12-11 11:39:33,055 ERROR org.codehaus.groovy.grails.web.context.GrailsConte
xtLoader - Error initializing the application: groovy.lang.MissingMethodExceptio
n: No signature of method: portal.Aplicacao.methodMissing() is applicable for ar
gument types: () values: []
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMetho
dException: No signature of method: portal.Aplicacao.methodMissing() is applicab
le for argument types: () values: []
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.
java:308)
at grails.util.Environment.executeForEnvironment(Environment.java:301)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java
:277)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor .java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: groovy.lang.MissingMethodException: No signature of method: portal.Ap
licacao.methodMissing() is applicable for argument types: () values: []
at portal.PortalService.criaAplicacaoNoPortal(PortalService.groovy:233)
at BootStrap$_closure1.doCall(BootStrap.groovy:16)
... 8 more
You can use the platform-core plugin, and then define the dataSources as application config in the doWithConfig section of your plugin, like so:
def doWithConfig = { config ->
// ...
application {
Environment.executeForCurrentEnvironment {
development {
dataSource_myDatasource {
dbCreate = "create-drop"
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
// other datasource configuration here...
}
}
}
test {
dataSource_myDatasource {
// test datasource
dbCreate = "create-drop"
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
// ...
}
}
}
}
}
}
I'm using spring security within a simple app. The app runs fine locally when connecting to amazon RDS instance. When I upload my app to elastic beanstalk the creation of a role fails in Bootstrap:
def init = { servletContext ->
println log.name
log.debug("hello 1")
def adminRole = new Role(authority: 'ROLE_ADMIN')
log.debug("hello 2")
if (!adminRole.save(flush: true, failOnError: true)) {
log.debug("hello 3")
adminRole.errors.each {
println it
log.error(it)
}
}
2013-12-17 23:25:33,311 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: groovy.lang.MissingMethodException: No signature of method: com.nrfa.Role.save() is applicable for argument types: () values: []
Possible solutions: save(), save(boolean), save(java.util.Map), wait(), last(), any()
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: com.nrfa.Role.save() is applicable for argument types: () values: []
Possible solutions: save(), save(boolean), save(java.util.Map), wait(), last(), any()
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:308)
at grails.util.Environment.executeForEnvironment(Environment.java:301)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:277)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: groovy.lang.MissingMethodException: No signature of method: com.nrfa.Role.save() is applicable for argument types: () values: []
Possible solutions: save(), save(boolean), save(java.util.Map), wait(), last(), any()
at BootStrap$_closure1.doCall(BootStrap.groovy:15)
... 9 more
If it were a database connectivity issue - which it may be - I would have thought the error would have been 'hey, can't connect to the database'. Not the non-descriptive error of can't find Role.save().
EDIT:
Full bootstrap:
import com.nrfa.Role
import com.nrfa.User
import com.nrfa.UserRole
class BootStrap {
def springSecurityService
def init = { servletContext ->
println log.name
log.debug("hello 1")
def adminRole = new Role(authority: 'ROLE_ADMIN')
log.debug("hello 2")
if (!adminRole.save(flush: true, failOnError: true)) {
log.debug("hello 3")
adminRole.errors.each {
println it
log.error(it)
}
}
log.debug("hello 4")
def userRole = new Role(authority: 'ROLE_USER').save(flush: true, failOnError: true)
def testUser = new User(username: 'me', password: 'password')
testUser.save(flush: true, failOnError: true)
UserRole.create testUser, userRole, true
assert User.count() == 1
assert Role.count() == 2
assert UserRole.count() == 1
}
def destroy = {
}
}
EDIT: Include BuildConfig.Groovy:
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
//runtime 'mysql:mysql-connector-java:5.1.27'
runtime 'org.slf4j:slf4j-api:1.7.5'
}
plugins {
build ":hibernate:$grailsVersion"
runtime ":jquery:1.8.3"
runtime ":resources:1.2"
runtime ":mysql-connectorj:5.1.22.1"
compile ':spring-security-core:2.0-RC2'
// 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.5"
build ":tomcat:$grailsVersion"
build ":database-migration:1.3.2"
compile ':cache:1.0.1'
// runtime ":mysql-connectorj:5.1.22.1"
}
That error is usually indicative of the hibernate plugin not being installed or working. Can you see the expanded war on the remote server? I'm not familiar with the workings of beanstalk itself so maybe something is in conflict there.
Adding "runtime 'mysql:mysql-connector-java:5.1.27'" in dependencies and remove it from plugins?