grails bootstrap error writing to mysql - grails

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?

Related

jenkins job dsl - No signature of method: java.lang.String.call()

I am unable to run this piece of code:
buildPath = 'applications'
buildJob(['java', 'nodejs'])
def buildJob(def jobList){
for(job in jobList){
def jobName = "${job}_seed"
def jobDescription = "Jenkins DSL seed for ${job}"
def jobScriptPath = "resources/dsl/${jobName}.groovy"
job("${buildPath}/${jobName}")
}
}
So, I am getting this error:
Processing provided DSL script
ERROR: (script, line 12) No signature of method: java.lang.String.call() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [applications/java_seed]
Possible solutions: wait(), any(), wait(long), take(int), each(groovy.lang.Closure), any(groovy.lang.Closure)
Finished: FAILURE
I do not see where or what is causing this error. I created a single job outside of the buildJob(def jobList) function and it is working but I need to do the loop to automation the jobs creation.
Any ideas?
Posting a similar issue i have run into. Isn't much around the web on this issue.
No signature of method: java.lang.String.call() is applicable for argument types: (java.lang.String) values: [some-value]
Say we are implementing a job dsl plugin (https://github.com/jenkinsci/multibranch-build-strategy-extension-plugin) like:
includeRegionBranchBuildStrategy {
includedRegions(String value)
}
And we have code like:
def includedRegions = r ? String.join("\n", r) : null
branchSources {
branchSource {
buildStrategies {
if(includedRegions){
includeRegionBranchBuildStrategy {
includedRegions(includedRegions)
}
}
}
}
}
Need to rename your variable to get it to work! e.g the method can't have the same name as a var defined above.
def regions = r ? String.join("\n", r) : null
branchSources {
branchSource {
buildStrategies {
if(regions){
includeRegionBranchBuildStrategy {
includedRegions(regions)
}
}
}
}
}
you are iterating string array in the following line:
for(job in jobList){
and using variable job for this.
then you try to invoke method call on this variable:
job("${buildPath}/${jobName}")

How to get working Grails 2.2.4 with Oracle 12c?

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
}

Grails custom test - No signature of method: org.codehaus.groovy.grails.test.runner.phase.IntegrationTestPhaseConfigurer.prepare()

I'm trying to follow Luke Daley's instructions on http://ldaley.com/post/615966534/custom-grails-test to add a custom test type, which should behave as an integration spec (grails-2.4.4, btw).
I've put my specs under test/apint and my _Events.groovy loooks like below:
eventAllTestsStart = {
phasesToRun << "apint"
}
def apintSpecsSuffix = "spec"
def apintSpecsDirectory = "apint"
def apintSpecsTestType = new GrailsSpecTestType(apintSpecsSuffix, apintSpecsDirectory)
apintTests = [apintSpecsTestType]
apintTestPhasePreparation = {
integrationTestPhasePreparation()
}
apintTestPhaseCleanUp = {
integrationTestPhaseCleanUp()
}
When I run grails test-app apint: I get the following error message:
Fatal error running tests: No signature of method: org.codehaus.groovy.grails.test.runner.phase.IntegrationTestPhaseConfigurer.prepare() is applicable for argument types: () values: []
Possible solutions: prepare(groovy.lang.Binding, java.util.Map), prepare(groovy.lang.Binding, java.util.Map), grep(), grep(java.lang.Object), every(), println() (Use --stacktrace to see the full trace)
.Tests FAILED
Any ideas why this is happening or how to fix it?
Thanks!

Use grails plugin datasource

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"
// ...
}
}
}
}
}
}

Grails 2.2.1 groupProperty on Integration tests

For some reason the groupProperty is not working on my integration tests. I'm getting the following exception:
groovy.lang.MissingMethodException: No signature of method:
mypackage.CarIntTests.groupProperty() is applicable for argument
types: (java.lang.String) values: [car]
def names = ['Honda', 'Toyota', 'Nissan']
3.times {
Garage.build(name: names[it])
}
def results = Garage.withCriteria {
car {
eq('brand', 'Honda')
}
projections {
groupProperty('car')
}
}
assert results == names[0..0]

Resources