Drols exception Unable to load dialect 'mvel' - drools

I'm trying to start a rather trivial example
KieContainer kieContainer = KieServices.Factory.get().getKieClasspathContainer();
StatelessKieSession kieSession = kieContainer.newStatelessKieSession("MyStatelessValidationStep");
and at the 2nd line I get an error NullPointerException which seems to be caused by the exception Unable to load dialect 'mvel'.
It happens with the latest Drools version 7.57.0.Final but works OK with e.g. 7.39.0.Final. I've listed the docs trying to find out what changed between those versions, but couldn't find the answer. So, is this a bug or I'm missing something new in my source code?
p.s.
Here is a list of the libraries I'm using:
ext {
drools_version = '7.57.0.Final'
slf4j_version = '1.7.32'
mvel_version = '2.4.12.Final'
junit_version = '5.6.0'
}
#"Roddy of the Frozen Peas", here are the dependencies:
dependencies {
// https://mvnrepository.com/artifact/org.drools/drools-core
implementation group: 'org.drools', name: 'drools-core', version: "$drools_version"
// https://mvnrepository.com/artifact/org.drools/drools-compiler
implementation group: 'org.drools', name: 'drools-compiler', version: "$drools_version"
// https://mvnrepository.com/artifact/org.kie/kie-api
compileOnly group: 'org.kie', name: 'kie-api', version: "$drools_version"
// https://mvnrepository.com/artifact/org.kie/kie-internal
implementation group: 'org.kie', name: 'kie-internal', version: "$drools_version"
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
implementation group: 'org.slf4j', name: 'slf4j-api', version: "$slf4j_version"
// https://mvnrepository.com/artifact/org.slf4j/slf4j-nop
implementation group: 'org.slf4j', name: 'slf4j-nop', version: "$slf4j_version"
// https://mvnrepository.com/artifact/org.mvel/mvel2
implementation group: 'org.mvel', name: 'mvel2', version: "$mvel_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}
Note that if I replace compileOnly with implementation for the kie-api, nothing changes in the final result - I still get NPE.

Since 7.45.0.Final MVEL evaluation has been moved to a separated module called drools-mvel, see the release notes. Please add that module as well or use instead the aggregator module drools-engine-classic

Related

Gradle wrapper version conflict

I Have the following build.gradle file:
buildscript {
ext {
scalaVersion = '2.12.10'
gatlingVersion = '3.8.4'
}
all {
resolutionStrategy {
force("com.google.protobuf:protobuf-java:2.4.1")
}
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'log4j', module: 'log4j'
}
}
dependencies {
implementation("org.scala-lang:scala-library:${scalaVersion}")
implementation("org.scala-lang:scala-reflect:${scalaVersion}")
implementation("io.gatling:gatling-app:${gatlingVersion}")
implementation("io.gatling.highcharts:gatling-charts-highcharts:${gatlingVersion}")
implementation('org.scala-lang.modules:scala-parser-combinators_2.12:1.1.2')
implementation('io.netty:netty-all:4.1.81.Final')
}
When I try to build it shows me:
* What went wrong:
Execution failed for task ':compileTestScala'.
> Could not resolve all dependencies for configuration ':zinc'.
> Conflict(s) found for the following module(s):
- org.scala-lang:scala-library between versions 2.12.10, 2.12.2, 2.12.8, 2.12.4 and 2.12.0
- org.scala-lang:scala-reflect between versions 2.12.10 and 2.12.8
Why it shows me to choose from these version when I already import one of these versions?
Thanks in advance

Lombok installer did not work for Eclipse with Gradle project

I have an Eclipse project which makes use of Lombok for annotations. One such annotation is #Access. The Eclipse compiler cannot see this, even if I explicitly put lombok.jar in the classpath of the project. I wish I could just get the Eclipse plugin to work, but would settle for modifying the build scripts and not checking them in.
Lombok jar version 1.18.22
Eclipse (Tried latest MyEclipse, and 2021-09).
Running on Linux
Based on the project instructions, I ran
java -jar lombok.jar
and specified my Eclipse directory.
It copied lombok.jar to the Eclipse directory and modified the eclipse.ini file to be this:
-startup
plugins/org.eclipse.equinox.launcher_1.6.300.v20210813-1054.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.2.300.v20210828-0802
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_16.0.2.v20210721-1149/jre/bin
-vmargs
-Dosgi.requiredJavaVersion=11
-Dosgi.instance.area.default=#user.home/eclipse-workspace
-Dsun.java.command=Eclipse
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=11
-Dosgi.dataAreaRequiresExplicitInit=true
-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true
-Xms256m
-Xmx2048m
--add-modules=ALL-SYSTEM
-javaagent:lombok.jar
But the annotation processing still does not work. I'm in a Gradle shop, but I wasn't sure where to put the either the plugin modification or non-plugin gradle modification.
I tried adding
compileOnly 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
directly to the dependencies, but it did not care.
My Gradle file does not look the same as the examples specified. My build.gradle is:
import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.api.JavaVersion
apply plugin: "distribution"
apply plugin: "idea"
apply plugin: "io.spring.dependency-management"
apply plugin: "jacoco"
apply plugin: "java"
apply plugin: "maven"
apply plugin: "org.liquibase.gradle"
apply plugin: "org.springframework.boot"
// apply plugin: "org.unbroken-dome.test-sets"
def javaVersion = JavaVersion.VERSION_11;
sourceCompatibility = javaVersion;
targetCompatibility = javaVersion; // defaults to sourceCompatibility
bootRun {
systemProperties = System.properties
systemProperty 'management.info.git.mode', 'FULL'
}
ext {
groupId = project.property('groupId')
version = project.property('version')
fernCommonVersion = project.property('fernCommonVersion')
walnutCommonVersion = project.property('walnutCommonVersion')
}
group groupId
version version
buildscript {
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
// classpath group: "gradle.plugin.org.unbroken-dome.gradle-plugins", name: "gradle-testsets-plugin", version: "1.4.2"
classpath group: "io.spring.gradle", name: "dependency-management-plugin", version: "1.0.10.RELEASE"
classpath group: "org.codehaus.groovy", name: "groovy-all", version: "2.0.1"
classpath group: "org.codehaus.groovy", name: "groovy-xml", version: "2.0.1"
classpath group: "org.liquibase", name: "liquibase-gradle-plugin", version: "2.0.1"
classpath group: "org.postgresql", name: "postgresql", version: "42.2.0"
classpath group: "org.springframework.boot", name: "spring-boot-gradle-plugin", version: "2.3.4.RELEASE"
classpath group: "pl.project13.maven", name: "git-commit-id-plugin", version: "2.2.1"
}
}
jacoco {
toolVersion = "0.8.5"
reportsDir = file("$buildDir/reports/jacoco")
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
xml.destination file("${buildDir}/reports/jacoco/coverage.xml")
html.destination file("${buildDir}/reports/jacoco/html")
}
}
springBoot {
mainClassName = 'com.tii.walnut.manager.AcornManagerApplication'
buildInfo {
// Generate extra build info.
properties {
additional = [
by : System.properties['user.name'],
operatingSystem: "${System.properties['os.name']} (${System.properties['os.version']})",
// machine: InetAddress.localHost.hostName,
// Override buildInfo property time
time : buildTime()
]
}
}
}
def buildTime() {
final dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ")
dateFormat.timeZone = java.util.TimeZone.getTimeZone('GMT')
dateFormat.format(new Date())
}
repositories {
mavenLocal()
maven { url 'http://bin-repo.iparadigms.com/artifactory/libs-release' }
maven { url 'http://bin-repo.iparadigms.com/artifactory/libs-snapshot' }
mavenCentral()
maven { url "http://repo.spring.io/release" }
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://jitpack.io" }
maven { url "http://dl.bintray.com/typesafe/maven-releases" }
maven { url "https://repository.apache.org/snapshots" }
}
sourceSets {
main {
java.srcDir 'src/main/java'
}
test {
java.srcDir 'src/test/java'
resources.srcDir 'src/test/resources'
}
}
configurations {
codacy
// we use the tii commons logging module for logging
compile.exclude module: 'log4j12'
compile.exclude module: 'slf4j-log4j12'
compile.exclude module: 'log4j-slf4j-impl'
compile.exclude module: 'log4j-core'
compile.exclude module: 'log4j-api'
compile.exclude module: 'spring-boot-starter-tomcat'
compile.exclude module: 'log4j-over-slf4'
}
dependencies {
compile (group: "com.tii", name: "fern-common", version: "${fernCommonVersion}") {
exclude group: "org.springframework.boot"
exclude group: "org.slf4j"
exclude module: 'spring-boot-starter-jetty'
}
compile group: "com.tii.walnut", name: "walnut-common", version: "${walnutCommonVersion}"
compile (group: 'com.turnitin.commons', name: 'logging', version: '0.0.2') {
exclude group: "org.springframework.boot"
}
compile (group: 'com.turnitin.commons', name: 'stream', version: '1.2-SNAPSHOT') {
// sadly the common libraries have incorrectly defined dependencies on Spring - this leads to version mismatches
exclude group: "org.springframework.boot"
exclude group: "org.springframework"
}
compile group: 'com.turnitin.commons', name: 'metrics', version: '0.3.8'
compile group: "com.fasterxml.jackson.dataformat", name: "jackson-dataformat-yaml"
compile group: "com.google.guava", name: "guava", version: "23.0"
compile group: 'com.jayway.jsonpath', name: 'json-path', version: '2.5.0'
compile group: "com.newrelic.agent.java", name: "newrelic-api", version: "4.1.0"
compile group: 'com.opencsv', name: 'opencsv', version: '5.5.1'
compile group: "com.squareup.okhttp3", name: "okhttp", version: "3.6.0"
compile group: "com.vladmihalcea", name: "hibernate-types-52", version: "2.9.11"
compile group: "io.jsonwebtoken", name: "jjwt", version: "0.7.0"
compile group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
compile group: "net.jodah", name: "failsafe", version: "2.4.0"
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'
compile group: "org.apache.commons", name: "commons-lang3", version: "3.9"
compile group: "org.aspectj", name: "aspectjweaver", version: "1.8.8"
compile (group: "org.codehaus.janino", name: "commons-compiler", version: "3.0.8") {
force = true
exclude group: "org.codehaus.janino", module: "janino"
}
compile group: "org.codehaus.janino", name: "janino", version: "3.0.8"
compile group: "org.functionaljava", name: "functionaljava-java8", version: "4.7"
compile group: "org.hibernate", name: "hibernate-c3p0", version: "5.2.10.Final"
compile group: "org.hibernate", name: "hibernate-java8", version: "5.2.10.Final"
compile group: "org.postgresql", name: "postgresql", version: "42.2.1"
compile group: "org.springframework", name: "spring-context-support"
compile group: "org.springframework.boot", name: "spring-boot-starter"
compile group: "org.springframework.boot", name: "spring-boot-starter-actuator"
compile group: "org.springframework.boot", name: "spring-boot-starter-data-jpa"
compile group: "org.springframework.boot", name: "spring-boot-starter-jdbc"
compile group: "org.springframework.boot", name: "spring-boot-starter-web"
compile group: "org.springframework.boot", name: "spring-boot-starter-webflux"
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jetty'
compile group: 'org.springframework.plugin', name: 'spring-plugin-core'
compile group: 'com.turnitin.commons', name: 'launchdarkly', version: '0.0.13'
runtime group: "org.springframework.boot", name: "spring-boot-devtools"
runtime("ch.qos.logback:logback-core")
testCompile group: "org.apiguardian", name: "apiguardian-api", version: "1.0.0"
testCompile group: "org.awaitility", name: "awaitility", version: "3.0.0"
testCompile group: "org.junit.jupiter", name: "junit-jupiter-api", version: "5.3.2"
testCompile group: "org.junit.jupiter", name: "junit-jupiter-params", version: "5.3.2"
testCompile group: "org.liquibase", name: "liquibase-core", version: "3.6.3"
testCompile group: "org.lz4", name: "lz4-java", version: "1.4.1"
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.28.2'
testCompile group: "org.springframework", name: "spring-test"
testCompile group: "org.springframework.boot", name: "spring-boot-starter-test"
liquibaseRuntime group: "ch.qos.logback", name: "logback-classic", version: "1.2.3"
liquibaseRuntime group: "ch.qos.logback", name: "logback-core", version: "1.2.3"
liquibaseRuntime group: "org.liquibase", name: "liquibase-core", version: "3.6.3"
liquibaseRuntime group: "org.postgresql", name: "postgresql", version: "42.2.1"
liquibaseRuntime group: "org.slf4j", name: "slf4j-api", version: "1.7.25"
testRuntime group: "org.junit.jupiter", name: "junit-jupiter-engine", version: "5.3.2"
codacy group: "com.github.codacy", name: "codacy-coverage-reporter", version: "-SNAPSHOT"
}
ext.testsRegEx = project.hasProperty('tests') ? project.getProperty('tests') : "*"
test {
jacoco {
append = false
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpDir = file("$buildDir/jacoco/classpathdumps")
}
useJUnitPlatform {
excludeTags 'slow'
}
filter {
includeTestsMatching "${testsRegEx}"
}
minHeapSize = "4g"
maxHeapSize = "8g"
reports.junitXml.destination = file('build/test-results/junit-platform')
testLogging {
exceptionFormat = 'full'
events = ["passed", "skipped", "failed"]
}
if (System.getProperty('DEBUG', 'false') == 'true') {
jvmArgs '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9099'
}
}
liquibase {
activities {
// new Dev env
uscald {
changeLogFile 'src/main/resources/database/Changelog.xml'
url 'jdbc:postgresql://dev-walnut-leader.uscald:5432/walnut?currentSchema=manager'
username 'walnut_admin'
password 'somepasswd'
liquibaseSchemaName 'public'
}
}
runList = 'uscald'
}
install.dependsOn(bootJar)
distributions {
main {
contents {
from jar
}
}
}
// this for debugging remotely - add -DDEBUG=true to the command line - remote debug at 9099
tasks.withType(JavaExec) {
if (System.getProperty('DEBUG', 'false') == 'true') {
jvmArgs '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9099'
}
}
// generated from bootstrap-jet - begin
task resolveDependencies {
doLast {
project.rootProject.allprojects.each { subProject ->
subProject.buildscript.configurations.each { configuration ->
resolveConfiguration(configuration)
}
subProject.configurations.each { configuration ->
resolveConfiguration(configuration)
}
}
}
}
void resolveConfiguration(configuration) {
if (isResolveableConfiguration(configuration)) {
configuration.resolve()
}
}
boolean isResolveableConfiguration(configuration) {
def nonResolveableConfigurations = ['apiElements', 'implementation',
'runtimeElements', 'runtimeOnly',
'testImplementation', 'testRuntimeOnly',
'generatedImplementation', 'generatedRuntimeOnly']
if (nonResolveableConfigurations.contains(configuration.getName())) {
return false
}
return true
}
// generated from bootstrap-jet - end

How to call a scala method from build.gradle file

I have just started working on the scala and gradle. I want to know how we can call any scala method from the gradle build file. Can somebody please help me?
From comment: I want to run multiple files present in a directory. So in order to get all the files in the directory, I have written a method in scala. That method I am trying to call from build.gradle file
Gradle allows to specify dependencies of build script itself inside buildscript{ dependencies { ... } } (not to be confused with project dependencies inside ordinary dependencies { ... }).
For example here I added Shapeless dependency and used an HList in build.gradle
build.gradle
buildscript{
dependencies {
classpath group: 'com.chuusai', name: 'shapeless_2.13', version: '2.4.0-M1'
}
}
plugins {
id 'java'
id 'scala'
id 'application'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
// compile group: ...
}
application {
mainClassName = 'App'
}
import shapeless.*
task hello {
doLast {
HList l = new $colon$colon(1, new $colon$colon("a", new HNil$()))
println l
}
}
Terminal
$ ./gradlew hello
Output
> Task :hello
1 :: a :: HNil
BUILD SUCCESSFUL in 457ms
1 actionable task: 1 executed
So you can compile your Scala sources, package classes into jar, publish it locally and specify your local dependency in
buildscript{
dependencies {
classpath group: 'yourOrganization', name: 'yourArtifact', version: 'yourVersion'
}
}
and then call methods from your Scala code in build.gradle.

W.r.t. Pass options to JPAAnnotationProcessor from Gradle

I am using Gradle version 2.14, I have made changes in build.gradle to exclude packages from JPAAnnotationProcessor as mentioned in question.
My build.gradle configuration for same as follows:
configurations {
querydslapt
}
dependencies{
compile group: 'com.querydsl', name: 'querydsl-core', version: '4.1.4'
compile group: 'com.querydsl', name: 'querydsl-apt', version: '4.1.4'
compile group: 'com.querydsl', name: 'querydsl-jpa', version: '4.1.4'
}
task generateQueryDSL(type: JavaCompile, group: 'build', description: 'Generates the QueryDSL query types') {
source =sourceSets.main.java
classpath = configurations.compile + configurations.querydslapt
options.compilerArgs = [
"-proc:only",
"-processor", "com.querydsl.apt.jpa.JPAAnnotationProcessor",
"-Aquerydsl.excludedPackages=com.projectx.data.domain.poc.lombok"
]
destinationDir = sourceSets.generated.java.srcDirs.iterator().next()
}
compileJava {
dependsOn generateQueryDSL
source generateQueryDSL.destinationDir
}
compileGeneratedJava {
dependsOn generateQueryDSL
options.warnings = false
classpath += sourceSets.main.runtimeClasspath
}
But when I am building application I getting warning as warning: The following options were not recognized by any processor: '[querydsl.excludedPackages]'
And specified packages are not excluded from preprocessing.
Found a solution!
After adding querydsl.entityAccessors=true to aptOptions warning still present, but excluding packages works!
In your case, you should try add -Aquerydsl.entityAccessors=true to options.compilerArgs =[]
hope it helps
UPDATED
Just noticed that you use lombook in your project.
Found this one ( How to make QueryDSL and Lombok work together ) Hope it could be helpful for you!

Installing and using MongoDB in Grails 3.x

I've been following Manning's Grails In Action, but their section on configuring data sources is woefully out-of-date for Grails 3.0.3.
My intention is to convert from the default data source of H2 to MongoDB version 3.0.2. Google searches have yielded conflicting results -- many answers are often for earlier versions of Grails, which used 'BuildConfig.groovy' and 'DataSources.groovy' in order to establish plug-ins and data sources.
I've downloaded the 3.0.2 JDBC for MongoDB and stored it in various folders (i.e. the root of the application, a created /lib/ folder, and in /grails-app/conf/) without success.
My application.yml file reads:
---
grails:
profile: web
codegen:
defaultPackage: qotd
info:
app:
name: '#info.app.name#'
version: '#info.app.version#'
grailsVersion: '#info.app.grailsVersion#'
spring:
groovy:
template:
check-template-location: false
---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlets: html
taglib: none
staticparts: none
---
hibernate:
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
dataSource:
pooled: true
jmxExport: true
host: 'localhost'
port: 27017
driverClassName: mongodb-driver-3.0.2.jar
databaseName: 'test_db'
environments:
development:
dataSource:
dbCreate: create
url: jdbc:mongodb://localhost:27017
test:
dataSource:
dbCreate: update
url: jdbc:mongodb://localhost:27017
production:
dataSource:
dbCreate: update
url: jdbc:mongodb://localhost:27017
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
My build.gradle file reads:
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.1.1'
}
}
plugins {
id "io.spring.dependency-management" version "0.5.2.RELEASE"
}
version "0.1"
group "qotd"
apply plugin: "spring-boot"
apply plugin: "war"
apply plugin: "asset-pipeline"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
assets {
minifyJs = true
minifyCss = true
}
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-starter-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile 'org.mongodb:mongodb-driver:3.0.2'
compile "org.grails.plugins:hibernate"
compile "org.grails.plugins:cache"
compile "org.hibernate:hibernate-ehcache"
runtime "org.grails.plugins:asset-pipeline"
runtime "org.grails.plugins:scaffolding"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
// Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'
console "org.grails:grails-console"
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
... and finally, the actual stack trace when I try to execute $ grails run-app is:
java.util.concurrent.ExecutionException: org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.3-bin.zip'.
at java_util_concurrent_Future$get.call(Unknown Source)
at run-app.run(run-app.groovy:90)
at org.grails.cli.profile.commands.script.GroovyScriptCommand.handle(GroovyScriptCommand.groovy:152)
at org.grails.cli.profile.DefaultProfile.handleCommand(DefaultProfile.groovy:177)
at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:239)
at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:220)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:198)
at org.grails.cli.GrailsCli.main(GrailsCli.groovy:99)
Caused by: org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.3-bin.zip'.
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:57)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
at org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:71)
at org.grails.cli.gradle.GradleUtil$_runBuildWithConsoleOutput_closure4.doCall(GradleUtil.groovy:109)
at org.grails.cli.gradle.GradleUtil$_withProjectConnection_closure2.doCall(GradleUtil.groovy:89)
at org.grails.cli.gradle.GradleUtil$_withProjectConnection_closure2.call(GradleUtil.groovy)
at grails.io.support.SystemOutErrCapturer.withNullOutput(SystemOutErrCapturer.groovy:64)
at org.grails.cli.gradle.GradleUtil.withProjectConnection(GradleUtil.groovy:88)
at org.grails.cli.gradle.GradleUtil.runBuildWithConsoleOutput(GradleUtil.groovy:104)
at org.grails.cli.gradle.GradleInvoker.invokeMethod(GradleInvoker.groovy:50)
at org.grails.cli.gradle.GradleAsyncInvoker$_invokeMethod_closure2.doCall(GradleAsyncInvoker.groovy:51)
at org.grails.cli.gradle.GradleAsyncInvoker$_invokeMethod_closure2.doCall(GradleAsyncInvoker.groovy)
Caused by: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':bootRun'.
at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:77)
at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:43)
at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:30)
at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:119)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:48)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:71)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':bootRun'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:306)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
... 34 more
Caused by: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/bin/java'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:365)
at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:31)
at org.gradle.api.tasks.JavaExec.exec(JavaExec.java:60)
at org.springframework.boot.gradle.run.BootRunTask.exec(BootRunTask.java:58)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 57 more
| Error Failed to start server
Any help would be greatly appreciated; many hours have been spent slamming my head against my desk and finding unhelpful search results.
Yeah, it's a challenge finding up-to-date documentation for configuring Grails 3.0 to use MongoDB. The solution below was cobbled together from various sources.
build.gradle
dependencies {
...
compile "org.grails.plugins:mongodb"
...
}
You do not need to manually download and install any JDBC files.
grails-app/conf/application.yml
environments:
development:
grails:
mongodb:
connectionString: "mongodb://localhost:27017/project-db"
grails-app/domain/com/example/Book.groovy
package com.example
import org.bson.types.ObjectId
class Book {
ObjectId id
String title
static mapWith = "mongo"
}
I've been successfully using this approach since Grails 3.0.1, and it's still working with 3.0.4.
Dem Pilafian is great and correct. Mine is just slightly different. You can leave out the mapping in your classes and rely on mongodb to directly store your objects. All you need to do is remove hibernate from your project.
Using Grails 3.1.7
build.gradle
dependencies {
compile "org.grails.plugins:mongodb"
//compile "org.grails.plugins:hibernate4"
//compile "org.hibernate:hibernate-ehcache"
//runtime "com.h2database:h2"
}
I've commented out the hibernate and h2 dependencies. You can delete them entirely of course, if you use only mongodb.
grails-app/conf/application.yml
environments:
development:
grails:
mongodb:
host: "hostname"
port: 27017
databaseName: development
In the application.yml you need to remove the hibernate: section and the driverClassName: org.h2.Driver.
For more background information as well as additional configuration options, refer to: GORM Grails MongoDB
This way, you will bypass hibernate completely and don't need to define a mapping in your classes. Your objects will be directly stored as structured documents in mongo.