when I tried to run grails -Dgrails.env=local run-app, I got the below error
Server failed to start: java.lang.LinkageError: loader constraint violation: loader (instance of ) previously initiated loading for a different type with name "javax/management/MBeanServer"
After analysing I understood that it has something to do with "Two dependencies link the same jar with different versions"
I ran grails dependency-report, and here is the observation:
commons-beanutils by commons-beanutils 1.8.3 release default false 227 kB
commons-beanutils by commons-beanutils 1.8.0 release default true 0 kB(evicted by 1.8.3)
How do I exclude this jar or remove the linkage?
The dependency report should show what is pulling in the problematic jar. Once you have that, explicitly exclude it from the dependencies in your BuildConfig.groovy, like so:
grails.project.dependency.resolution = {
dependencies {
runtime("i-depend-on-beanutils-1.8.3") {
excludes "beanutils"
}
}
}
Related
I updated a plugin to use cxf 2.0.3 - previously the plugin was using cxf 1.4.7.
Following is the updated buildconfig of the plugin.
plugins {
// starting with Grails 2.3 the tomcat plugin is not updated/released along with Grails, so hard code version
build(":tomcat:2.2.5",
":release:2.2.1",) {
export = false
}
compile ":cxf-client:2.0.3"
}
When my application tries to load the plugin, I get the following error.
I tried using the plugin on an existing project and new project and still get the error.
|Loading Grails 2.5.3
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
....
|Compiling 1 source files
..........................................................Error
|
Error: The following plugins failed to load due to missing dependencies: [msApi]
- Plugin: msApi
- Dependencies:
! cxf-client (Required: 1.4.7, Found: 2.0.3) [INVALID]
Process finished with exit code 1
Is there some cache file I need to delete?
Search for string: "1.4.7" in whole plugin project f.e. by grep -rn "1.4.7" and you will find all occurences of this string in project (and then you will decide to change it or to delete such a file from result).
I have the following in my build.gradle of my Grails 3 project.
dependencies {
...
compile "org.grails.plugins:spring-security-core:3.0.3"
// The following line was the true cause of my problem
compile("org.grails.plugins:spring-security-oauth-google:0.3.1")
...
}
Now when I run Gradle I get this error:
Error Error initializing classpath: Could not find spring-security-core.zip (org.grails.plugins:spring-security-core:3.0.3).
Searched in the following locations:
https://repo.grails.org/grails/core/org/grails/plugins/spring-security-core/3.0.3/spring-security-core-3.0.3.zip (Use --stacktrace to see the full trace)
If I go to the specified path I do see the plugin but just as reported there is no zip file.
What am I doing wrong here?
The root for this problem I found in a little bit different place than expected.
I am working on upgrading a Grails 2.5 project to Grails 3 and I had lead myself on a wrong track. I needed to include spring-security-oauth-google and when it did not work as expected I also included spring-security-core which then derailed me.
The cause of this problem is dependencies being loaded from dependencies I have in my own project. In order to avoid loading those dependencies - called transitive dependencies - the following has to be done:
plugins {
compile "org.grails.plugins:spring-security-core:3.0.3"
compile("org.grails.plugins:spring-security-oauth-google:0.3.1") {
exclude group: 'org.grails.plugins', module: 'spring-security-core'
}
}
This will load the spring-security-core 3.0.3 correctly ignoring the dependency from spring-security-oauth-google.
I'm using Grails plugin to execute (war and debug) Grails 2.5.0 project.
It seems one of dependencies contain older dependency than I would like to you. When I war a project correct version is used, but at debug it uses older dependenvy version:
dependencies {
bootstrap "org.grails.plugins:tomcat:7.0.50" // No container is deployed by default, so add this
// plugins for the compile step
compile "joda-time:joda-time:2.3"
compile("org.grails.plugins:spring-security-rest:1.5.2") {
exclude module: 'xml-apis'
exclude module: 'joda-time'
}
compile 'org.grails.plugins:cache:1.1.8'
// plugins needed at runtime but not for compilation
runtime ("org.grails.plugins:hibernate4:4.3.8.1") { exclude module: 'xml-apis' } // or ":hibernate:3.6.10.18"
runtime "org.grails.plugins:database-migration:1.4.0"
}
So at debug I have joda-time 1.6 which is shipped with spring-security-rest:1.5.2. But when war-ed joda-time version is 2.3
i am new in grails..i try to install plugin using the command "install-plugin easygrid:1.5.0" in run. i got the warning as follow
"| Warning The install-plugin command is deprecated and may be removed from a future version of Grails. Plugin dependencies should be expressed in grails-app/conf/BuildConfig.groovy. See http://grails.org/doc/2.2.x/guide/conf.html#pluginDependencies.
| Resolving plugin easygrid:1.5.0. Please wait...
| Error resolving plugin [name:1.5.0, group:easygrid, version:latest.integration]. Plugin not found.
| Error Plugin not found for name [easygrid:1.5.0] and version [not specified]"
how to install-plugins in run or using BuildConfig.grooovy in grails?
thanks in advance
Look at the Dependency section on the Grails' plugin page, it should be located near the top of the page right under the author & licence sections. Copy the text from there into your BuildConfig.groovy file into the plugins block and (re)start Grails.
Your BuildConfig could look like this:
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
//..some other configuration
grails.project.dependency.resolution = {
//..some other configuration and blocks
plugins {
//.. other plugins
compile ":easygrid:1.6.9"
}
}
I'm trying to use the grails-gradle plugin with grails version 2.0. Here is my build script:
buildscript {
repositories {
mavenRepo url: "http://repo.grails.org/grails/core/"
}
dependencies {
classpath "org.grails:grails-gradle-plugin:1.1.1-SNAPSHOT",
"org.grails:grails-bootstrap:2.0.0"
}
grailsVersion="2.0.0"
}
apply plugin: "grails"
repositories {
mavenCentral()
mavenRepo url: "http://repo.grails.org/grails/core/"
}
dependencies {
compile "org.grails:grails:2.0.0",
"org.grails:grails-core:2.0.0",
"org.grails:grails-crud:2.0.0",
"org.grails:grails-datastore-core:1.0.2.RELEASE",
"org.grails:grails-datastore-gorm:1.0.2.RELEASE",
"org.grails:grails-hibernate:2.0.0",
"org.grails:grails-logging:2.0.0"
}
The dependencies at the bottom of the script are different than the original "1.3.4" located here. When I use this script to create a grails project with gradle grails-init it works correctly, creating the project. When I try to use gradle grails-run-app I receive the following errors:
~>gradle grails-run-app
:grails-run-app
| Configuring classpath
| Error log4j:WARN No appenders could be found for logger (org.springframework.core.io.support.PathMatchingResourcePatternResolver).
| Error log4j:WARN Please initialize the log4j system properly.
| Error log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
| Compiling 38 source files
| Compiling 8 source files.....
| Error Error: The following plugins failed to load due to missing dependencies: [hibernate]
- Plugin: hibernate
- Dependencies:
! dataSource (Required: 2.0 > *, Found: Not Installed) [INVALID]
- i18n (Required: 2.0 > *, Found: 2.0.0)
- core (Required: 2.0 > *, Found: 2.0.0)
- domainClass (Required: 2.0 > *, Found: 2.0.0)
I'm assuming that this means I'm missing a dependency, but I have no idea what dependency. It looks like hibernate is the culprit, but I have included the grails hibernate jar above. The list of jars between the two versions of grails are different, so I'm not sure which should be included (or maybe there isn't one and this will not work). The list of dependencies can be see here.
Any help resolving these errors would be much appreciated.
Using:
gradle 1.0, milestone-7 & grails 2.0.0
NOTE: the dependency "org.grails:grails-gradle-plugin:1.1.1-SNAPSHOT" is a local copy of the tip revision from github.
Thanks a lot. This is a very helpful thread, to answer your question, you need to add "org.grails:grails-plugin-datasource:2.0.1" on compile, it solved the problem on my machine.
Looks like you're missing a few dependencies... Check Gradle / Grails application for a complete example of how to do this.
Hope this helps!