Geb driver issue after upgrading to Grails 2.4.5 - grails

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.

Related

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

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.

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

Grails - Database Reverse Engineer plugin not found

Environment
Grails 2.4.4
PostgreSQL 9.4
JDK 1.7
I've been trying to get this plugin to work. (I'm still a grails newbie, not to mention programming.)
I tried to do everything I can find out there but still get this untimate error message.
Loading Grails 2.4.4
|Configuring classpath
|Running pre-compiled script
|Script 'DbReverseEngineer' not found, did you mean:
1) SetVersion
2) GenerateRestfulController
3) GenerateViews
4) GenerateController
5) DbmGenerateChangelog
Please make a selection or enter Q to quit:
This is what I have right not in my config files. (I've tried to change a lot of them, such as Hibernate, plugin version etc, but always end up with that message.)
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
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://repo.grails.org/grails/repo/"
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.29'
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
runtime "org.postgresql:postgresql:9.4-1205-jdbc41"
compile "org.grails.plugins:db-reverse-engineer:4.0.0"
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
compile ":asset-pipeline:1.9.9"
compile ":postgresql-extensions:4.6.1"
compile ":jquery:1.11.1"
compile ":joda-time:1.5"
compile "org.grails.plugins:db-reverse-engineer:4.0.0"
// 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"
runtime ":db-reverse-engineer:4.0.0"
}
Thanks in advance.
EDIT 1
So, I changed DbReverseEngineer.groovy under Script folder like this.
mergedConfig.driverClassName = dsConfig.driverClassName ?: 'org.postgresql.Driver'
mergedConfig.password = dsConfig.password ?: ''
mergedConfig.username = dsConfig.username ?: 'postgres'
mergedConfig.url = dsConfig.url ?: 'jdbc:postgresql://localhost:5432/myApp'
And I changed plugin and dependency per Burt's and Emmanuel's advice. And when I run grails db-reverse-engineer command I get this error.
Compilation error: startup failed:
Compile error during compilation with javac.
/home/Documents/Grails_Workspace/myApp/target/work/plugins/cache-1.1.8/src/java/grails/plugin/cache/web/GenericResponseWrapper.java:203: error: method does not override or implement a method from a supertype
#Override
^
/home/Documents/Grails_Workspace/myApp/target/work/plugins/cache-1.1.8/src/java/grails/plugin/cache/web/filter/PageFragmentCachingFilter.java:389: error: cannot find symbol
contentType = response.getContentType();
^
symbol: method getContentType()
location: variable response of type HttpServletResponse
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
What are those errors mean and how can I get rid of it?
Thanks.
You've got the same plugin set up twice:
compile 'org.grails.plugins:db-reverse-engineer:4.0.0'
runtime ':db-reverse-engineer:4.0.0'
According to the plugin's page it should be configured as a compile time dependency:
compile "org.grails.plugins:db-reverse-engineer:4.0.0"
The plugin does have the command that's claimed to be missing. You can see it here. So you may need to refresh the dependencies by running:
grails refresh-dependencies

Grails stops at "Configuring classpath" even at a helloworld project

I want to learn Grails, so I started with a Hello-World Projekt.
I tried everything in the cmd.exe and in STS. I have Windows7.
First i wrote grails create-app helloworld command
Then i swaped in the new helloworld\ directory and wrote grails run-app
But the command-line doesn't go furthen then Configuring classpath
I watched in other forums but nothing helped.
I am sitting in a companys-internet. Does this cause the fault ?
Fault if log level is set on verbose (only the last few lines - before were about 500 other lines)
| Error Failed to resolve dependencies (Set log level to 'warn' in BuildConfig.groovy for more information):
org.apache.tomcat.embed:tomcat-embed-core:7.0.42
org.apache.tomcat.embed:tomcat-embed-logging-log4j:7.0.42
org.eclipse.jdt.core.compiler:ecj:3.7.2
org.apache.tomcat:tomcat-catalina-ant:7.0.42
org.apache.tomcat.embed:tomcat-embed-logging-juli:7.0.42
org.apache.tomcat.embed:tomcat-embed-jasper:7.0.42
Edit: I use Grails 2.2.4 and heres my BuildConfig.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'
}
}
Be sure you are not behind a proxy.
Check on the command line grails list-plugins.
If this call fails: add and set the proxy and check the correct entries in the ProxySettings.groovy.
May this helps.
Please check internet and plugin download links are accessible or not..
I am sitting in a companys-internet
I faced the same problems with my company's proxy server.
On a Windows machine in grails-version_number\bin\ there is a startGrails.bat. Here the settings for your proxy server could be set via JAVA_OPTS (towards the bottom of the file). But it would not be a good to do so, because when you upgrade Grails a year or so from now your customs settings will be lost. And you'll be scratching your head about why Grails no longer works and/or you cannot remember the syntax for setting the proxy server info.
So, in the same bin\ directory make a new file called setenv.bat. In that add
#rem Java proxy properties for connecting to proxy server
set JAVA_OPTS=%JAVA_OPTS% -Dhttp.proxySet=true -Dhttp.proxyHost="proxyServerName" -Dhttp.proxyPort="0123" -Dhttp.username="userName" -Dhttp.password="userPassWord"
I would remove the helloworld directory you just created and then again run
grails create-app helloworld

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