このコードを実行しようとすると、次のエラーが発生します。
import com.jayway.restassured.response.Response;
import static com.jayway.restassured.RestAssured.*;
public class TestRestAssured {
public static void main (String args[]){
// Call the REST service
Response res = get("http://10.213.75.170:5000/bla"); // <--- Crashes on this line.
// Get the JSON payload
String json = res.asString();
}
}
java.lang.NullPointerException
at org.codehaus.groovy.reflection.GeneratedMetaMethod$DgmMethodRecord.loadDgmInfo(GeneratedMetaMethod.java:163)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:155)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:83)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:61)
at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:29)
at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:49)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.createMap(ScriptBytecodeAdapter.java:619)
at com.jayway.restassured.internal.ResponseParserRegistrar.<init>(ResponseParserRegistrar.groovy)
at com.jayway.restassured.RestAssured.<clinit>(RestAssured.java:336)
at TestRestAssured.main(TestRestAssured.java:16)
Exception in thread "main" java.lang.NullPointerException
at org.codehaus.groovy.runtime.callsite.CallSiteClassLoader.loadClass(CallSiteClassLoader.java:45)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.loadClass(ClassLoaderForClassArtifacts.java:58)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.define(ClassLoaderForClassArtifacts.java:42)
at org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts$1.run(ClassLoaderForClassArtifacts.java:86)
at org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts$1.run(ClassLoaderForClassArtifacts.java:84)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.defineClassAndGetConstructor(ClassLoaderForClassArtifacts.java:84)
at org.codehaus.groovy.runtime.callsite.CallSiteGenerator.compilePojoMethod(CallSiteGenerator.java:229)
at org.codehaus.groovy.reflection.CachedMethod.createPojoMetaMethodSite(CachedMethod.java:257)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.createCachedMethodSite(PojoMetaMethodSite.java:159)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.createPojoMetaMethodSite(PojoMetaMethodSite.java:148)
at groovy.lang.MetaClassImpl.createPojoCallSite(MetaClassImpl.java:3015)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createPojoSite(CallSiteArray.java:116)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:150)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.jayway.restassured.internal.ResponseParserRegistrar.<init>(ResponseParserRegistrar.groovy:42)
at com.jayway.restassured.RestAssured.createTestSpecification(RestAssured.java:1094)
at com.jayway.restassured.RestAssured.given(RestAssured.java:746)
at com.jayway.restassured.RestAssured.get(RestAssured.java:776)
at TestRestAssured.main(TestRestAssured.java:16)
私は残りの保証された1.7、groovy 1.8.8を使用しています、残りのすべての保証された依存関係は私のシステムライブラリパスにロードされます。私もjdk1.7を使用しています。これは、同じ.jarファイルで同じコードを実行しても問題がないため、同僚としては、ある種の環境問題です。