Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.restassured.filter.time.TimingFilter cannot be cast to groovy.lang.GroovyObject - RestAssured 3.0.3 #905

Open
piotrbo opened this issue Sep 7, 2017 · 5 comments

Comments

@piotrbo
Copy link

piotrbo commented Sep 7, 2017

We are trying to upgrade RestAssured from 2.9.0 to 3.0.3 in project built with SBT tool (the code is in java)
In runtime we are getting java.lang.NullPointerException: Cannot get property 'name' on null object
and the original ClassCastException message is "io.restassured.filter.time.TimingFilter cannot be cast to groovy.lang.GroovyObject"

in local repository we deleted old groovy version just to make sure it is not used.
The same issue is with restassured on 3.0.2
We are reproduicing this on OSX and on Linux
Any thoughts ?

stacktrace:
java.lang.NullPointerException: Cannot get property 'name' on null object at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60) at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174) at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296) at io.restassured.internal.RequestSpecificationImpl$_sendRequest_closure15.doCall(RequestSpecificationImpl.groovy:1236) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at groovy.lang.Closure.call(Closure.java:414) at groovy.lang.Closure.call(Closure.java:430) at org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(DefaultGroovyMethods.java:3156) at org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(DefaultGroovyMethods.java:3127) at org.codehaus.groovy.runtime.dgm$66.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at io.restassured.internal.RequestSpecificationImpl.sendRequest(RequestSpecificationImpl.groovy:1236) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810) at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy) at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:149) at io.restassured.internal.filter.SendRequestFilter.filter(SendRequestFilter.groovy:30) at io.restassured.filter.Filter$filter$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at io.restassured.filter.Filter$filter.call(Unknown Source) at io.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:72) at io.restassured.filter.time.TimingFilter.filter(TimingFilter.java:56) at io.restassured.filter.Filter$filter.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at io.restassured.filter.Filter$filter$0.call(Unknown Source) at io.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:72) at io.restassured.filter.FilterContext$next.call(Unknown Source) at io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1725) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810) at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy) at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:48) at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:58) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182) at io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1731) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810) at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy) at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:48) at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:58) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182) at io.restassured.internal.RequestSpecificationImpl.get(RequestSpecificationImpl.groovy:168) at io.restassured.internal.RequestSpecificationImpl.get(RequestSpecificationImpl.groovy)

@piotrbo piotrbo changed the title upgrade RestAssured from 2.9.0 to 3.0.3 io.restassured.filter.time.TimingFilter cannot be cast to groovy.lang.GroovyObject - RestAssured 3.0.3 Sep 7, 2017
@johanhaleby
Copy link
Collaborator

Have you also upgraded all the third-party dependencies?

@piotrbo
Copy link
Author

piotrbo commented Sep 8, 2017

build.sbt:

"io.rest-assured" % "rest-assured" % "3.0.3",
"io.rest-assured" % "xml-path" % "3.0.3",
"io.rest-assured" % "json-path" % "3.0.3",
"io.rest-assured" % "scala-support" % "3.0.3",
"io.rest-assured" % "json-schema-validator" % "3.0.3",
"org.codehaus.groovy" % "groovy" % "2.4.12",
"org.codehaus.groovy" % "groovy-json" % "2.4.12",
"org.codehaus.groovy" % "groovy-xml" % "2.4.12"

initially i tried with groovy 2.4.9

@piotrbo
Copy link
Author

piotrbo commented Sep 8, 2017

and dependencie from parent project:
"com.fasterxml.jackson.core.jackson-core" -> "2.8.9",
"com.fasterxml.jackson.core.jackson-databind" -> "2.8.9",
"com.fasterxml.jackson.core.jackson-annotations" -> "2.8.9",
"com.fasterxml.jackson.datatype.jackson-datatype-jdk8" -> "2.8.9",
"com.fasterxml.jackson.datatype.jackson-datatype-jsr310" -> "2.8.9",
"org.hamcrest.hamcrest-core" -> "1.3",
"org.hamcrest.hamcrest-library" -> "1.3", (edited)
"junit.junit" -> "4.12",

actually the only changies where in restassured and groovy

@mkorvas
Copy link

mkorvas commented May 18, 2018

I landed on this page while googling for the same error message (about casting to GroovyObject) which I observed in a somewhat similar scenario. In my case, it occurred when trying to use a Spock version relying on Groovy 2.4 in tests that imported some classes from a library built using Groovy 2.3 (and compatible Spock version with Groovy 2.3).

Some work was already done to overcome such issues in Gradle, it seems -- see https://issues.gradle.org/browse/GRADLE-3455 and the commit linked from there, where, sampling from the changed files, I see mostly added extends GroovyObjectSupport declarations. Perhaps adding that to TimingFilter in your case would help?

@mkorvas
Copy link

mkorvas commented May 18, 2018

FWIW, after some trial-and-error investigation of my use case, I concluded that there is no way for me to run Spock tests using a version of Spock built for Groovy 2.4 which import classes from a library built with Groovy 2.3. We maintain both codebases, so we will just upgrade the library to use Groovy 2.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants