Grails plugin dependency pulled into maven cache, but main project can't resolve classes - grails

Using Grails 2.5.4
I have a plugin that uses the Twilio SDK (7+).
The plugin packages without error.
When I run the main project it throws an error saying that the it
cannot resolve the import com.twilio.Twilio class in the plugin
controllers/services.
I confirm that the Twilio SDK has been pulled into the local Maven
cache when the plugin was pulled in, so it knows to get the dependency.
The main project BuildConfig includes mavenLocal() in the dependency
resolution.
Where do I look next to find the cause of this dependency resolution problem?
plugin dependencies.groovy
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
grailsCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
mavenLocal()
mavenCentral()
}
dependencies {
compile 'com.twilio.sdk:twilio:7.8.0'
}
in plugin.xml
<dependencies>
<compile>
<dependency group='com.twilio.sdk' name='twilio' version='7.8.0' />
</compile>
</dependencies>
In main project BuildConfig.gorrcy
plugins{
compile ":twilio-ext:1.0"
}
running grails dependency-report I see
org.grails.plugins:twilio-ext:1.0
But it has no sub dependencies listed.

Related

Grails dependency error-only looks in grailsCentral not other repos

Grails 2.5...
I have a plugin in an SVN repository.
Here is the build config (minus authentication credentials)....
grails.project.dependency.resolver = "maven" // maven or ivy
grails.project.dependency.resolution = {
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "warn" // 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()
mavenRepo "http://repo.grails.org/grails/plugins"
mavenRepo name:"*********", root: "*********************"
}
plugins {
runtime ':org-calendar-viewer:0.7.9'
}
But I always get a dependency resolve error it could not find the plugin at grailsCentral. Of course it couldn't the plugin is in a different repo. Is grailsCentral the last place it looks? Or the first place it looks?
Resolve error obtaining dependencies: Could not find artifact in grailsCentral (https://repo.grails.org/grails/plugins)
I tried commenting out the grails repos and then it fails as
Resolve error obtaining dependencies: Could not find artifact in mavenCentral (https://repo1.maven.org/maven2/)
So it seems it is throwing an error after only checking one(first) location?

move Grails project from older to newest version of Intellij Idea IDE

I've developed my Grails project in a machine that has Idea 13 installed.
Now I've moved in another machine and I've installed the latest version of the IDE.
I've installed Grails (ver. 2.2.1) and Groovy (ver. 2.4.6) giving the path variables as described in their installation instructions. I've created a new project from existing source but when I try to run it, it gives me errors about plugins.
Plugins are missing and I cannot install in the project because the tab in the menu Tools -> Grails -> Plugins (or right click on the root of the project -> Grails -> Plugins) does not exists. I've tried with creating a brand new Grails project and the tab exists, so maybe it depends on the way I've imported the project.
Here it is the BuildConfig.groovy content:
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}.war"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
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 eg.
runtime 'mysql:mysql-connector-java:5.1.20'
}
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.8.0"
runtime ":resources:1.1.6"
// 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.4"
build ":tomcat:$grailsVersion"
runtime ":database-migration:1.1"
compile ':cache:1.0.0'
compile ":ckeditor:4.4.1.0"
}
}
Here it is the error in Grails console:
Error |
Failed to resolve dependencies (Set log level to 'warn' in BuildConfig.groovy for more information):
- org.grails.plugins:cache:1.0.0
- org.grails.plugins:ckeditor:4.4.1.0
How can I import it without receiving errors in building code?
EDIT:
I've created a brand new project. It installs default plugins but does not allow to add new plugins via Tools->Grails->Plugins
The error is (i.e. log4j plugin installation):
|Resolving plugin log4j-xml. Please wait...
|Error resolving plugin [name:log4j-xml, group:org.grails.plugins, version:0.2]. Plugin not found.
Error |
Plugin not found for name [log4j-xml] and version [0.2]
I've solved the problem on my own.
The solution is the same found here: Error Failed to resolve dependencies grails

Geb driver issue after upgrading to Grails 2.4.5

Upon upgrading my Grails version from 2.3.6 to 2.4.5, I am now getting an exception when running Geb Spock tests.
failed to create driver from callback 'script14328041759692122350870$_run_closure1#5fcdf5ea'
geb.driver.DriverCreationException: failed to create driver from callback 'script14328041759692122350870$_run_closure1#5fcdf5ea'
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:85)
at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:32)
at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:84)
at geb.Configuration.createDriver(Configuration.groovy:361)
at geb.Configuration.getDriver(Configuration.groovy:350)
at geb.Browser.getDriver(Browser.groovy:105)
at geb.Browser.clearCookies(Browser.groovy:496)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:54)
at AuthorizationAdminSpec.setupSpec(AuthorizationAdminSpec.groovy:21)
Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/SchemePortResolver
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:234)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(ApacheHttpClient.java:211)
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:88)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:62)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:57)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:93)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:191)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
at script14328041759692122350870.run_closure1(script14328041759692122350870.groovy:12)
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
... 9 more
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.SchemePortResolver
at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:175)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:147)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 23 more
I remember encountering this exception before during my initial Geb setup in Grails 2.3.6, in which the BuildConfig and GebConfig files were not properly configured. However, upon re-checking the necessary plugins and dependencies required of Geb, I did not notice anything different for Grails 2.4.5 Also, I switched my dependency resolution from Ivy to Maven, so I double checked my maven resources to make sure the driver was loaded.
Some more info...
BuildConfig.groovy
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
mavenLocal()
mavenCentral()
mavenRepo "http://repository.jboss.com/maven2/"
mavenRepo "http://google-api-client-libraries.appspot.com/mavenrepo"
mavenRepo "http://mvnrepository.com/artifact/"
mavenRepo "http://repo.jenkins-ci.org/repo"
mavenRepo "http://repo.grails.org/grails/repo"
}
dependencies {
....
compile "org.springframework:spring-test:4.0.9.RELEASE"
test "org.gebish:geb-spock:0.10.0"
test "org.seleniumhq.selenium:selenium-support:2.45.0"
test "org.seleniumhq.selenium:selenium-firefox-driver:2.45.0"
}
plugins {
....
test ":geb:0.10.0"
}
GebConfig.groovy
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxProfile
reportsDir = "target/geb-reports"
baseUrl = "http://localhost:8090/adverity/"
driver = {
//set the firefox locale to 'en-us' since the tests expect english
//see http://stackoverflow.com/questions/9822717 for more details
FirefoxProfile profile = new FirefoxProfile()
profile.setPreference("intl.accept_languages", "en-us")
def driverInstance = new FirefoxDriver(profile)
driverInstance.manage().window().maximize()
driverInstance
}
baseNavigatorWaiting = true
atCheckWaiting = true
autoClearCookies = false
quitCachedDriverOnShutdown = false
Any simple spec that I run will throw the same error.I tried doing the same with Chrome to test if this is a driver issue and got the same results. Both firefox and Chrome drivers work with Grails 2.3.6, but not 2.4.5.
OS: Fedora 20
Browser: Firefox 38
Places I have looked already...
Book of Geb
GebGrails git hub example
StackOverflow
test 'org.apache.httpcomponents:httpclient:4.3.2'
Added to the dependencies section in BuildConfig.groovy
I was not aware of this dependency as I did not see it in any documentation, but a deeper look inside the stack trace told me otherwise.

Grails not picking jars from Maven repository based on pom.xml

I am getting some compilation error because of Grails not picking jars from Maven repository based on pom.xml file.
My BuildConfig.groovy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
//excludes "grails-plugin-log4j"
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
//excludes "grails-plugin-log4j"
pom true
repositories {
inherits true // Whether to inherit repository definitions from plugins
//grailsPlugins()
/// grailsHome()
// grailsCentral()
mavenCentral()
mavenLocal()
// These are for the hudson machine
// mavenRepo "/apps/profiler/ci/hudson/workspace/RMSPortal2/m2_repo"
// mavenRepo "/apps/profiler/ci/hudson/workspace/RMSPortal2/m2_repo"
//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 eg.
runtime 'mysql:mysql-connector-java:5.1.5'
compile 'org.apache.activemq:activemq-core:5.3.0'
test 'org.objenesis:objenesis:1.2'
compile 'org.slf4j:slf4j-log4j12:1.6.6'
//compile "spring-security-config:3.0.1.RELEASE"
}
plugins {
compile ":spring-security-core:1.2.7.3"
compile ":spring-security-ui:0.2"
compile ":jquery-ui:1.8.15"
compile ":jqgrid:3.8.0.1"
compile ":famfamfam:1.0.1"
compile ":mail:1.0"
compile ":jms:1.2"
compile ":calendar:1.2.1"
compile ':gpars:0.3'
compile ":lang-selector:0.3"
compile ":crypto:2.0"
compile ":grails-melody:1.13"
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.7.1"
//runtime ":resources:1.1.6"
runtime ":resources:1.2.RC2"
runtime ":export:1.5"
// 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.4"
build ":tomcat:$grailsVersion"
test ":spock:0.6"
}
}
I am getting error like this:
Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 141 source files.
| Error Compilation error: startup failed:
/mycompany/dev/rmaddidev/wsmavenTest/pro/src/groovy/com/mycompany/rms/common/RMSExportService.groovy: 15: unable to resolve class org.xhtmlrenderer.pdf.ITextRenderer
# line 15, column 1.
import org.xhtmlrenderer.pdf.ITextRenderer
^
1 error
ITextRenderer class exist in core-renderer.jar i specified in maven pom as below.
if i add those jars in BuildConfig.groovy, then it working fine.
compile 'org.xhtmlrenderer:core-renderer:R8'
compile 'com.lowagie:itext:2.0.8'
And My Pom file:
<dependencies>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>core-renderer</artifactId>
<version>R8</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.0.8</version>
</dependency>
You can still use the standard grails commands as long as all your dependencies are referenced in the BuildConfig.groovy.
However, you probably don't want to maintain both the Maven POM and BuildConfig.groovy, unless you have some team members who don't want to use Maven.
Unless the project needs to be 'buildable' using both Maven and the standard Grails command line, avoid the BuildConfig.groovy at all costs, as well as the Grails command line.
Details
When using Maven, you need to do the following :
Do not set dependencies in BuildConfig.groovy, add them to your POM:
The dependencies block from your BuildConfig.groovy move to the POM(with the default implied type tag set to jar).
For non jar dependencies(plugins or non-binary plugins), you need to explicitly set the dependency type to zip in your pom.xml.
Also, remove the repositories block from your BuildConfig.groovy, and set the repositories in your POM.
Do not use the grails command line, use the Grails Maven goals, as implied by #dmahapatro.
When you decide to use Maven and Grails, it implies that you want avoid having settings in your BuildConfig.groovy.
Then you'd have your build settings(all if it were 100% possible) driven by the Maven POM.

Grails 2.0 depedencies NoClassDefFound issue

I've got a problem with NoClassDefFound exception in Grails 2.0 when I tried to use library from external JAR.
I've checked that declared JARs are inside of created WAR, also grials dependecies-report do not marks any issues with that.
Locally added JARs or downloaded from Maven repo seems no difference. I've also tried to clean IVY cache and clean grails project without success.
Did you got any ideas how to fix it?
BuildConfig.groovy (part of)
grails.project.dependency.resolution = {
inherits("global") {
// uncomment 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
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsCentral()
mavenCentral()
mavenLocal()
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 {
compile ( "javax:activation:1.0",
"javax:mail:1.0",
"com.google.gdata:gdata-core:1.0",
"com.google.gdata:gdata-client:1.0",
"com.google.gdata:gdata-media:1.0",
"com.google.gdata:gdata-youtube:2.0"
)
runtime ( "javax:activation:1.0",
"javax:mail:1.0",
"com.google.gdata:gdata-core:1.0",
"com.google.gdata:gdata-client:1.0",
"com.google.gdata:gdata-media:1.0",
"com.google.gdata:gdata-youtube:2.0"
)
}
...
}
LibraryController.groovy
import com.google.gdata.client.youtube.YouTubeService
import com.google.gdata.data.youtube.VideoEntry
import com.google.gdata.util.ServiceException
class LibraryController {
private YouTubeService service
private static final API_URL = "http://gdata.youtube.com/feeds/api/videos/"
def index = {
service = new YouTubeService("app")
}
}
Exception
Class
java.lang.NoClassDefFoundError
Message
Could not initialize class com.google.gdata.client.youtube.YouTubeServiceClass
java.lang.NoClassDefFoundError
Message
Could not initialize class com.google.gdata.client.youtube.YouTubeService
NoClassDefFoundError is not the same as ClassNotFoundException. Getting a ClassNotFoundException means the class isn't there, so you have a straightforward jar/dependency problem. NoClassDefFoundError means that the specified class was found, but that a class that it references wasn't found. It's a much more frustrating issue to track down because the JVM doesn't tell you what's missing.
You need to make sure that you have all of the dependencies of the class that's failing to load, and all of their dependencies, etc.
You have all your dependencies declared both in compile and runtime scope. Each dependency should be declared only once. If you declare a dependency in compile scope, it will also be available runtime. Since you need this class for compilation, you should keep com.google.gdata:gdata-youtube:2.0 under 'compile', and remove it from 'runtime'
A description of the available scopes, taken from the user documentation:
build: Dependencies for the build system only
compile: Dependencies for the compile step
runtime: Dependencies needed at runtime but not for compilation (see above)
test: Dependencies needed for testing but not at runtime (see above)
provided: Dependencies needed at development time, but not during WAR deployment

Resources