I am using rest assured and validating JSON schema using it. I generated the schema using jsonschema.net(draft 7) and saved the generated schema in the file and matched the generated schema against the response of GET API.
But the code throwing the error with output like:
Actual: {"success":true,"message":"FacilityAttributes List","error":{},"result":[{"id":"aa2cdb2e-89cd-4970-a976-42df3349df74","name":"INTERNATIONAL","rank":null,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"BusinessType","description":"Please check if facility is international!"},{"id":"144e7c1c-9df4-4c65-ae7e-685013566731","name":"HEAVY","rank":null,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"BusinessType","description":"Please check if facility can handle heavy goods!"},{"id":"ca20c185-4c9a-425e-82e4-a5b244b5ef9d","name":"B2B","rank":5,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"BusinessType","description":null},{"id":"12a2c7f3-7da7-4682-953c-2e06ab8c8335","name":"B2C","rank":4,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"BusinessType","description":null},{"id":"34ef64ee-33dc-43ea-9ef0-722aeb2377f8","name":"HLD","rank":2,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"BusinessType","description":null},{"id":"5147ec36-59ac-4843-9f46-a881548e33aa","name":"dock_count","rank":null,"data_type":"INTEGER","default_value":"0","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Attributes","description":"Dock Door count in Facility!"},{"id":"1bdd7e0f-3a47-4d57-b641-439ba8790e48","name":"capacity","rank":null,"data_type":"INTEGER","default_value":"0","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Attributes","description":"Facility Capacity!"},{"id":"16e81b0c-fe3b-4827-bcf0-dbfd6f2cc386","name":"dimention_unit","rank":null,"data_type":"OPTION","default_value":"CM","mandatory":false,"business_unit":"TRA","options":["CM","IN"],"facility_type":null,"group_name":"Facility Attributes","description":"Dimention unit on facility works!"},{"id":"75569bc1-f5f0-40c1-8e36-f3ef88940486","name":"weight_unit","rank":null,"data_type":"OPTION","default_value":"KG","mandatory":false,"business_unit":"TRA","options":["KG","GM","LB"],"facility_type":null,"group_name":"Facility Attributes","description":"Weight unit on facility works!"},{"id":"48b121ba-e142-4f10-955c-12be4c33f787","name":"sort_code","rank":null,"data_type":"TEXT","default_value":null,"mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Attributes","description":"Facility sort code!"},{"id":"dc5cc52c-2f65-4b92-beaa-d8165dfdc157","name":"slab_rate","rank":null,"data_type":"FLOAT","default_value":"0","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Attributes","description":"Slab rate of facility"},{"id":"d6b3ac6d-5f97-46a5-8e71-72b96f2aa419","name":"slab_type","rank":null,"data_type":"OPTION","default_value":"Incentive Based","mandatory":false,"business_unit":"TRA","options":["Incentive Based","Fuel Based"],"facility_type":null,"group_name":"Facility Attributes","description":"Slab rate of facility"},{"id":"03654f31-150f-4420-837c-f22bda1bc476","name":"ProductivityBenchmark","rank":null,"data_type":"INTEGER","default_value":"0","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Productivity","description":"Productivity Benchmark of facility!"},{"id":"ad471316-0858-4ed7-b817-7b554c780536","name":"ReverseDispatchCutoff","rank":null,"data_type":"TIME","default_value":"09:00","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Timings","description":"Reverse Dispatch Cutoff time"},{"id":"18041d87-a88d-4ed3-b457-9c6e96c2c250","name":"ForwardDispatchCutoff","rank":null,"data_type":"TIME","default_value":"12:00","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Timings","description":"Forward Dispatch Cutoff time"},{"id":"c3e677a7-5b21-4c6b-8384-27c936720177","name":"Implant_enabled","rank":13,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check Implant is enabled in Facility!"},{"id":"0fcd0fbe-c448-455a-b825-8b1eb2fcc8b3","name":"DG_enabled","rank":12,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check DG is enabled in Facility!"},{"id":"34067f20-ece0-4775-8596-4447f74c5084","name":"FMODx_enabled","rank":11,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check Odx FM is enabled in Facility!"},{"id":"6237f744-e685-4aca-906a-48bd1bad9160","name":"FEApp_enabled","rank":9,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check FE App is enabled in Facility!"},{"id":"5ceb5fd0-74db-46fc-97a1-afbbaabc3686","name":"PayTM_enabled","rank":8,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if PayTM is enabled in facility!"},{"id":"f69817cb-8662-4f38-b44b-fb875703e9cd","name":"CardOnDelivery_enabled","rank":7,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if Card On Delivery is enabled in facility!"},{"id":"a3bcf54b-d734-4f95-92fd-a15bb2a00be3","name":"BagGuide_enabled","rank":6,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if BagGuide is enabled in facility!"},{"id":"19cfc5d1-f5fb-4666-a13f-7519588e3bb2","name":"LMOdx_enabled","rank":5,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if LMOdx is enabled in facility!"},{"id":"dc99d927-5925-4b09-a686-9c0231259337","name":"Constellation_enabled","rank":4,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if Constellation is enabled in facility!"},{"id":"41ba47fe-ec23-4649-bf0b-51101e631e68","name":"Bagging_enabled","rank":3,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if Bagging is enabled in facility!"},{"id":"7ead8afd-2e98-4330-8e15-40d4cb944a3c","name":"MidMile_enabled","rank":2,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if MidMile is enabled in facility!"},{"id":"4b9ffcab-b5df-4f19-bbd9-52e208168039","name":"Sorter_enabled","rank":1,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if sorter is enabled in facility!"},{"id":"c81e981d-2c44-4bd7-9cc9-5ea20a3eaa3a","name":"Can_Handle_Palletised_Load","rank":null,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Check if facility Can Handle Palletised Load"}]}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure.validate(ResponseSpecificationImpl.groovy:471)
at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure$validate$1.call(Unknown Source)
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.ResponseSpecificationImpl.validateResponseIfRequired(ResponseSpecificationImpl.groovy:643)
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.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at io.restassured.internal.ResponseSpecificationImpl.content(ResponseSpecificationImpl.groovy:94)
at io.restassured.specification.ResponseSpecification$content$0.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
at io.restassured.internal.ResponseSpecificationImpl.body(ResponseSpecificationImpl.groovy:244)
at io.restassured.internal.ValidatableResponseOptionsImpl.body(ValidatableResponseOptionsImpl.java:262)
at com.ums.api.AppTest.GetserData(AppTest.java:46)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:669)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:877)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1201)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:776)
at org.testng.TestRunner.run(TestRunner.java:634)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:425)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:420)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:385)
at org.testng.SuiteRunner.run(SuiteRunner.java:334)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1318)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1243)
at org.testng.TestNG.runSuites(TestNG.java:1161)
at org.testng.TestNG.run(TestNG.java:1129)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
my genereated schema is schema link
Repsonse of the api API repsonse
Maybe the current REST Assured library work until draft 4. I'm using json-schema-generator tool to generate json schema in draft 4 and able to validate the response.
Commands to install and generate schema: -
npm install -g json-schema-generator
json-schema-generator path/to/input_response.json -o path/to/json_schema.json
Reference links:
https://github.com/krg7880/json-schema-generator
I am new to the microservices + Spring Boot combinations and getting the below error while running the code from the link: https://github.com/sqshq/PiggyMetrics . Please guide me what is the nissue ?
java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:110) ~[spring-cloud-config-client-1.1.0.RELEASE.jar:1.1.0.RELEASE]
at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:89) ~[spring-cloud-context-1.1.0.RELEASE.jar:1.1.0.RELEASE]
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:640) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:343) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at com.piggymetrics.statistics.StatisticsApplication.main(StatisticsApplication.java:34) [classes/:na]
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://config:8888/statistics-service/default": config; nested exception is java.net.UnknownHostException: config
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:607) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:475) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.getRemoteEnvironment(ConfigServicePropertySourceLocator.java:130) ~[spring-cloud-config-client-1.1.0.RELEASE.jar:1.1.0.RELEASE]
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:81) ~[spring-cloud-config-client-1.1.0.RELEASE.jar:1.1.0.RELEASE]
... 7 common frames omitted
Caused by: java.net.UnknownHostException: config
at java.net.AbstractPlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_144]
at java.net.PlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_144]
at java.net.SocksSocketImpl.connect(Unknown Source) ~[na:1.8.0_144]
at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_144]
at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_144]
at sun.net.NetworkClient.doConnect(Unknown Source) ~[na:1.8.0_144]
at sun.net.www.http.HttpClient.openServer(Unknown Source) ~[na:1.8.0_144]
at sun.net.www.http.HttpClient.openServer(Unknown Source) ~[na:1.8.0_144]
at sun.net.www.http.HttpClient.<init>(Unknown Source) ~[na:1.8.0_144]
at sun.net.www.http.HttpClient.New(Unknown Source) ~[na:1.8.0_144]
at sun.net.www.http.HttpClient.New(Unknown Source) ~[na:1.8.0_144]
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) ~[na:1.8.0_144]
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source) ~[na:1.8.0_144]
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) ~[na:1.8.0_144]
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) ~[na:1.8.0_144]
at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:80) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:93) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator$BasicAuthorizationInterceptor.intercept(ConfigServicePropertySourceLocator.java:179) ~[spring-cloud-config-client-1.1.0.RELEASE.jar:1.1.0.RELEASE]
at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:85) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:69) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:596) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
... 11 common frames omitted
2017-09-09 19:19:34.861 INFO 4968 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/C:/Learnings/micro-services/PiggyMetrics/statistics-service/target/classes/, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot-starter-security/1.3.5.RELEASE/spring-boot-starter-security-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot-starter/1.3.5.RELEASE/spring-boot-starter-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot/1.3.5.RELEASE/spring-boot-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.3.5.RELEASE/spring-boot-autoconfigure-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/spring-aop/4.2.6.RELEASE/spring-aop-4.2.6.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/security/spring-security-config/4.0.4.RELEASE/spring-security-config-4.0.4.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/security/spring-security-web/4.0.4.RELEASE/spring-security-web-4.0.4.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/spring-expression/4.2.6.RELEASE/spring-expression-4.2.6.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-starter-config/1.1.0.RELEASE/spring-cloud-starter-config-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-starter/1.1.0.RELEASE/spring-cloud-starter-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-context/1.1.0.RELEASE/spring-cloud-context-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/security/spring-security-rsa/1.0.1.RELEASE/spring-security-rsa-1.0.1.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/bouncycastle/bcpkix-jdk15on/1.47/bcpkix-jdk15on-1.47.jar, file:/C:/Users/pashtikar/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.47/bcprov-jdk15on-1.47.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-config-client/1.1.0.RELEASE/spring-cloud-config-client-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.6.6/jackson-annotations-2.6.6.jar, file:/C:/Users/pashtikar/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.6.6/jackson-databind-2.6.6.jar, file:/C:/Users/pashtikar/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.6.6/jackson-core-2.6.6.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/security/oauth/spring-security-oauth2/2.0.9.RELEASE/spring-security-oauth2-2.0.9.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/spring-beans/4.2.6.RELEASE/spring-beans-4.2.6.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/spring-core/4.2.6.RELEASE/spring-core-4.2.6.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/spring-context/4.2.6.RELEASE/spring-context-4.2.6.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/spring-webmvc/4.2.6.RELEASE/spring-webmvc-4.2.6.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/security/spring-security-core/4.0.4.RELEASE/spring-security-core-4.0.4.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/commons-codec/commons-codec/1.9/commons-codec-1.9.jar, file:/C:/Users/pashtikar/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.9.13/jackson-mapper-asl-1.9.13.jar, file:/C:/Users/pashtikar/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.13/jackson-core-asl-1.9.13.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.3.5.RELEASE/spring-boot-starter-web-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.3.5.RELEASE/spring-boot-starter-tomcat-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.0.33/tomcat-embed-core-8.0.33.jar, file:/C:/Users/pashtikar/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.0.33/tomcat-embed-el-8.0.33.jar, file:/C:/Users/pashtikar/.m2/repository/org/apache/tomcat/embed/tomcat-embed-logging-juli/8.0.33/tomcat-embed-logging-juli-8.0.33.jar, file:/C:/Users/pashtikar/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.0.33/tomcat-embed-websocket-8.0.33.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot-starter-validation/1.3.5.RELEASE/spring-boot-starter-validation-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/hibernate/hibernate-validator/5.2.4.Final/hibernate-validator-5.2.4.Final.jar, file:/C:/Users/pashtikar/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/C:/Users/pashtikar/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/C:/Users/pashtikar/.m2/repository/com/fasterxml/classmate/1.1.0/classmate-1.1.0.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/spring-web/4.2.6.RELEASE/spring-web-4.2.6.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-starter-feign/1.1.0.RELEASE/spring-cloud-starter-feign-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-netflix-core/1.1.0.RELEASE/spring-cloud-netflix-core-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-commons/1.1.0.RELEASE/spring-cloud-commons-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/security/spring-security-crypto/4.0.4.RELEASE/spring-security-crypto-4.0.4.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/feign/feign-core/8.16.2/feign-core-8.16.2.jar, file:/C:/Users/pashtikar/.m2/repository/org/jvnet/animal-sniffer-annotation/1.0/animal-sniffer-annotation-1.0.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/feign/feign-slf4j/8.16.2/feign-slf4j-8.16.2.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/feign/feign-hystrix/8.16.2/feign-hystrix-8.16.2.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-starter-ribbon/1.1.0.RELEASE/spring-cloud-starter-ribbon-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/ribbon/ribbon/2.1.5/ribbon-2.1.5.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/ribbon/ribbon-transport/2.1.5/ribbon-transport-2.1.5.jar, file:/C:/Users/pashtikar/.m2/repository/io/reactivex/rxnetty-contexts/0.4.9/rxnetty-contexts-0.4.9.jar, file:/C:/Users/pashtikar/.m2/repository/io/reactivex/rxnetty-servo/0.4.9/rxnetty-servo-0.4.9.jar, file:/C:/Users/pashtikar/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar, file:/C:/Users/pashtikar/.m2/repository/io/reactivex/rxnetty/0.4.9/rxnetty-0.4.9.jar, file:/C:/Users/pashtikar/.m2/repository/io/netty/netty-codec-http/4.0.27.Final/netty-codec-http-4.0.27.Final.jar, file:/C:/Users/pashtikar/.m2/repository/io/netty/netty-codec/4.0.27.Final/netty-codec-4.0.27.Final.jar, file:/C:/Users/pashtikar/.m2/repository/io/netty/netty-handler/4.0.27.Final/netty-handler-4.0.27.Final.jar, file:/C:/Users/pashtikar/.m2/repository/io/netty/netty-transport-native-epoll/4.0.27.Final/netty-transport-native-epoll-4.0.27.Final.jar, file:/C:/Users/pashtikar/.m2/repository/io/netty/netty-common/4.0.27.Final/netty-common-4.0.27.Final.jar, file:/C:/Users/pashtikar/.m2/repository/io/netty/netty-buffer/4.0.27.Final/netty-buffer-4.0.27.Final.jar, file:/C:/Users/pashtikar/.m2/repository/io/netty/netty-transport/4.0.27.Final/netty-transport-4.0.27.Final.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/ribbon/ribbon-core/2.1.5/ribbon-core-2.1.5.jar, file:/C:/Users/pashtikar/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/ribbon/ribbon-httpclient/2.1.5/ribbon-httpclient-2.1.5.jar, file:/C:/Users/pashtikar/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/netflix-commons/netflix-commons-util/0.1.1/netflix-commons-util-0.1.1.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/ribbon/ribbon-loadbalancer/2.1.5/ribbon-loadbalancer-2.1.5.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/netflix-commons/netflix-statistics/0.1.1/netflix-statistics-0.1.1.jar, file:/C:/Users/pashtikar/.m2/repository/io/reactivex/rxjava/1.1.5/rxjava-1.1.5.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-starter-archaius/1.1.0.RELEASE/spring-cloud-starter-archaius-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/archaius/archaius-core/0.7.4/archaius-core-0.7.4.jar, file:/C:/Users/pashtikar/.m2/repository/com/google/code/findbugs/jsr305/3.0.1/jsr305-3.0.1.jar, file:/C:/Users/pashtikar/.m2/repository/commons-configuration/commons-configuration/1.8/commons-configuration-1.8.jar, file:/C:/Users/pashtikar/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-starter-eureka/1.1.0.RELEASE/spring-cloud-starter-eureka-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-netflix-eureka-client/1.1.0.RELEASE/spring-cloud-netflix-eureka-client-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/eureka/eureka-client/1.4.6/eureka-client-1.4.6.jar, file:/C:/Users/pashtikar/.m2/repository/org/codehaus/jettison/jettison/1.3.7/jettison-1.3.7.jar, file:/C:/Users/pashtikar/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/netflix-commons/netflix-eventbus/0.3.0/netflix-eventbus-0.3.0.jar, file:/C:/Users/pashtikar/.m2/repository/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/servo/servo-core/0.10.1/servo-core-0.10.1.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/servo/servo-internal/0.10.1/servo-internal-0.10.1.jar, file:/C:/Users/pashtikar/.m2/repository/com/sun/jersey/jersey-core/1.19.1/jersey-core-1.19.1.jar, file:/C:/Users/pashtikar/.m2/repository/com/sun/jersey/jersey-client/1.19.1/jersey-client-1.19.1.jar, file:/C:/Users/pashtikar/.m2/repository/com/sun/jersey/contribs/jersey-apache-client4/1.19.1/jersey-apache-client4-1.19.1.jar, file:/C:/Users/pashtikar/.m2/repository/org/apache/httpcomponents/httpclient/4.5.2/httpclient-4.5.2.jar, file:/C:/Users/pashtikar/.m2/repository/org/apache/httpcomponents/httpcore/4.4.4/httpcore-4.4.4.jar, file:/C:/Users/pashtikar/.m2/repository/com/google/inject/guice/4.0/guice-4.0.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/governator/governator-api/1.12.10/governator-api-1.12.10.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/eureka/eureka-core/1.4.6/eureka-core-1.4.6.jar, file:/C:/Users/pashtikar/.m2/repository/com/amazonaws/aws-java-sdk-core/1.10.30/aws-java-sdk-core-1.10.30.jar, file:/C:/Users/pashtikar/.m2/repository/com/amazonaws/aws-java-sdk-ec2/1.10.30/aws-java-sdk-ec2-1.10.30.jar, file:/C:/Users/pashtikar/.m2/repository/com/amazonaws/aws-java-sdk-autoscaling/1.9.3/aws-java-sdk-autoscaling-1.9.3.jar, file:/C:/Users/pashtikar/.m2/repository/com/amazonaws/aws-java-sdk-sts/1.9.3/aws-java-sdk-sts-1.9.3.jar, file:/C:/Users/pashtikar/.m2/repository/com/amazonaws/aws-java-sdk-route53/1.9.3/aws-java-sdk-route53-1.9.3.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/governator/governator/1.12.10/governator-1.12.10.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/governator/governator-core/1.12.10/governator-core-1.12.10.jar, file:/C:/Users/pashtikar/.m2/repository/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar, file:/C:/Users/pashtikar/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.4.1/woodstox-core-asl-4.4.1.jar, file:/C:/Users/pashtikar/.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar, file:/C:/Users/pashtikar/.m2/repository/org/codehaus/woodstox/stax2-api/3.1.4/stax2-api-3.1.4.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/ribbon/ribbon-eureka/2.1.5/ribbon-eureka-2.1.5.jar, file:/C:/Users/pashtikar/.m2/repository/com/thoughtworks/xstream/xstream/1.4.2/xstream-1.4.2.jar, file:/C:/Users/pashtikar/.m2/repository/xmlpull/xmlpull/1.1.3.1/xmlpull-1.1.3.1.jar, file:/C:/Users/pashtikar/.m2/repository/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot-starter-data-mongodb/1.3.5.RELEASE/spring-boot-starter-data-mongodb-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/mongodb/mongo-java-driver/2.13.3/mongo-java-driver-2.13.3.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/data/spring-data-mongodb/1.8.4.RELEASE/spring-data-mongodb-1.8.4.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/spring-tx/4.2.6.RELEASE/spring-tx-4.2.6.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/data/spring-data-commons/1.11.4.RELEASE/spring-data-commons-1.11.4.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.21/jcl-over-slf4j-1.7.21.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/1.3.5.RELEASE/spring-boot-starter-actuator-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot-actuator/1.3.5.RELEASE/spring-boot-actuator-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-starter-bus-amqp/1.1.0.RELEASE/spring-cloud-starter-bus-amqp-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-starter-stream-rabbit/1.0.0.RELEASE/spring-cloud-starter-stream-rabbit-1.0.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-stream-binder-rabbit/1.0.0.RELEASE/spring-cloud-stream-binder-rabbit-1.0.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-stream-codec/1.0.0.RELEASE/spring-cloud-stream-codec-1.0.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot-starter-amqp/1.3.5.RELEASE/spring-boot-starter-amqp-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/amqp/spring-rabbit/1.5.6.RELEASE/spring-rabbit-1.5.6.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/amqp/spring-amqp/1.5.6.RELEASE/spring-amqp-1.5.6.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/com/rabbitmq/http-client/1.0.0.RELEASE/http-client-1.0.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/com/rabbitmq/amqp-client/3.5.7/amqp-client-3.5.7.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/integration/spring-integration-amqp/4.2.5.RELEASE/spring-integration-amqp-4.2.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/integration/spring-integration-jmx/4.2.5.RELEASE/spring-integration-jmx-4.2.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-bus/1.1.0.RELEASE/spring-cloud-bus-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/integration/spring-integration-core/4.2.5.RELEASE/spring-integration-core-4.2.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-netflix-hystrix-stream/1.1.0.RELEASE/spring-cloud-netflix-hystrix-stream-1.1.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.3.5.RELEASE/spring-boot-starter-logging-1.3.5.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar, file:/C:/Users/pashtikar/.m2/repository/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar, file:/C:/Users/pashtikar/.m2/repository/org/slf4j/jul-to-slf4j/1.7.21/jul-to-slf4j-1.7.21.jar, file:/C:/Users/pashtikar/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.21/log4j-over-slf4j-1.7.21.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/cloud/spring-cloud-stream/1.0.0.RELEASE/spring-cloud-stream-1.0.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/spring-messaging/4.2.6.RELEASE/spring-messaging-4.2.6.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/spring-tuple/1.0.0.RELEASE/spring-tuple-1.0.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/com/esotericsoftware/kryo-shaded/3.0.3/kryo-shaded-3.0.3.jar, file:/C:/Users/pashtikar/.m2/repository/com/esotericsoftware/minlog/1.3.0/minlog-1.3.0.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/integration/spring-integration-tuple/1.0.0.RELEASE/spring-integration-tuple-1.0.0.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/org/springframework/retry/spring-retry/1.1.2.RELEASE/spring-retry-1.1.2.RELEASE.jar, file:/C:/Users/pashtikar/.m2/repository/com/netflix/hystrix/hystrix-core/1.5.2/hystrix-core-1.5.2.jar, file:/C:/Users/pashtikar/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.7/HdrHistogram-2.1.7.jar, file:/C:/Users/pashtikar/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar, file:/C:/Users/pashtikar/.m2/repository/org/objenesis/objenesis/2.1/objenesis-2.1.jar, file:/C:/Users/pashtikar/.m2/repository/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar]
Anatoly above sums it pretty clearly and nicely as to what you need to do.
If you are looking for a quick and dirty test try changing the hostnames from
http://config:8888 to http://localhost:8888
in the bootstrap.yml files, for the service you are trying to run.
If you build and run project modules manually (e.g. from IDE) you should rename all "config" hostnames in bootstrap.yml files to "localhost".
The issue is, this project uses Docker Compose to run things
Development mode
If you'd like to build images yourself (with some changes in the code, for example), you have to clone all repository and build artifacts with maven. Then, run docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
docker-compose.dev.yml inherits docker-compose.yml with additional possibility to build images locally and expose all containers ports for convenient development.
and Docker Compose allows you to use service name as hostname.
Setting failsafe to false will just not throw the exception , this is something I would not recommend since this means even if you are not connected to your config server and unable to fetch the configuration your application will run which leads to an uncertain behavior (since you do not know where your properties are loaded), always better to fail fast.
The original cause of the problem is an exception or failing during fetching the remote environment from your config server, probably a timeout issue.
Your configuration is not setup properly. It thinks the hostname is 'config'.
For me it was because the Jhipster Registry was not running
I met this issue as the same, i resolved it by updated configuration below:
cloud:
config:
fail-fast: false
After changing Active profiles to local in "Edit configuration" it started working.
1)
2)
For Jhipster...
The focus is on http://localhost:8761/config, and then I saw that there is a bootstrap-prod.yml based on the production environment in the project. The reason is that the configuration in the production environment is the same as the dev, which leads to an error.
So replace the produced localhost with the domain name/IP of the project registration center
I got something similar, an 500 internal error from a micro service! No cause given.
I looked at the config server, for the service my application was attempting to contact. It had given a parse error when attempting to read a yml file at start up, with the result the entire process was hanging.
So if you get an error, look in the logging data from your config server, there might be some extra information there.
I've got a JUnit-test which is successfull when starting with mvn test but fails when starting from Eclipse (see stack trace below). What I'm trying to do is inserting new elements into the database with entityManager.persist() and entityManager.flush() (when calling flush, I get the error).
My config.properties looks the following:
db.url=jdbc:derby:target/testdb;create=true;territory=en_US;collation=TERRITORY_BASED
db.username=
db.password=
# Hibernate
hibernate.show_sql=true
hibernate.hbm2ddl.auto=create
With that configuration, my test fails in Eclipse, but runs with "mvn test"; if I remove the line "hibernate.hbm2ddl.auto=create", the test is successful from both, "mvn test" and Eclipse. When running the application, it works; it really only fails when running the JUnit-Test with "hibernate.hbm2ddl.auto=create" enabled.
In my Test-class, there's a setup-Method looking the following:
#Before
#Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void setUpDatabase() {
final Resource deleteScript = applicationContext.getResource("delete.sql");
final Resource insertScript = applicationContext.getResource("insert.sql");
SimpleJdbcTestUtils.executeSqlScript(simpleJdbcTemplate, deleteScript, true);
SimpleJdbcTestUtils.executeSqlScript(simpleJdbcTemplate, insertScript, false);
}
delete.sql contains "delete from" statements, insert.sql inserts the statments again.
Java version 1.6.0_16, maven 2.1.0.
Any ideas?
Thanks a lot,
Stefan
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not insert: [ch.netcetera.gisab.masterdata.model.security.RuleTarget]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:307)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:198)
at $Proxy47.flush(Unknown Source)
at ch.netcetera.gisab.masterdata.dao.RuleDAOImpl.updateRuleTargetsOfRule(RuleDAOImpl.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy72.updateRuleTargetsOfRule(Unknown Source)
at ch.netcetera.gisab.masterdata.services.RoleServiceImpl.updateUserRoleTO(RoleServiceImpl.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy74.updateUserRoleTO(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.aop.interceptor.CustomizableTraceInterceptor.invokeUnderTrace(CustomizableTraceInterceptor.java:255)
at org.springframework.aop.interceptor.AbstractTraceInterceptor.invoke(AbstractTraceInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy74.updateUserRoleTO(Unknown Source)
at ch.netcetera.gisab.masterdata.services.RoleServiceTest.testUpdateUserRoleTO(RoleServiceTest.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.hibernate.exception.ConstraintViolationException: could not insert: [ch.netcetera.gisab.masterdata.model.security.RuleTarget]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2295)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2688)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:304)
... 66 more
Caused by: java.sql.SQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL091001075326220' defined on 'RULETARGET'.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2275)
... 75 more
Caused by: java.sql.SQLException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL091001075326220' defined on 'RULETARGET'.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 87 more
Caused by: ERROR 23505: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL091001075326220' defined on 'RULETARGET'.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexChanger.insertAndCheckDups(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexChanger.doInsert(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexChanger.insert(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexSetChanger.insert(Unknown Source)
at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(Unknown Source)
at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(Unknown Source)
at org.apache.derby.impl.sql.execute.InsertResultSet.open(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
... 81 more
Edit:
I forgot: no error during startup, but during the failing test method, I get the following warning in the log:
2009-10-01 10:16:38,924 | main | WARN | JDBCExceptionReporter | SQL Warning: 10000, SQLState: 01J01
2009-10-01 10:16:38,924 | main | WARN | JDBCExceptionReporter | Database 'target/testdb' not created, connection made to existing database instead.
Hibernate: insert into RuleTarget (ruleid, targetid, type, version, id) values (?, ?, ?, ?, ?)
2009-10-01 10:16:38,939 | main | WARN | JDBCExceptionReporter | SQL Error: 20000, SQLState: 23505
2009-10-01 10:16:38,939 | main | ERROR | JDBCExceptionReporter | The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL091001101631840' defined on 'RULETARGET'.
2009-10-01 10:16:38,939 | main | ERROR | AbstractFlushingEventListener | Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: could not insert: [ch.netcetera.gisab.masterdata.model.security.RuleTarget]
Based on the SQLIntegrityConstraintViolationException it looks like your delete statements are not being executed, do you perhaps have two delete.sql files or not have src/test/resources configured as a source location in Eclipse?
The applicationContext.getResource("delete.sql") call will expect to find delete.sql in the output directory. In a Maven build the contents of src/test/resources will be copied to target/test-classes, this will only be done in an Eclipse build if the source location is defined.
The true at the end of the first executeSqlScript call means the process will continue without throwing an exception in the event of an error, so it may be that the resource is not found, and the delete statements not executed. If you run the build with the option set to false (and existing content) does it fail?
Note you can configure the Eclipse .classpath file to output test content to target/test-classes to avoid conflicts.
The steps to do this are:
Open the project properties (alt-enter)
SelectJava Build Path
Select the Source tab
Click on Allow output folders for source folders. This adds a new entry to the source folder tree.
Expand the source folder tree.
Double-click on the Output folder: entry.
A dialog asks you if you want to use the project's default output folder or a specific output folder. Choose the second option and click Browse...
Select the folder you want and click OK and then Finish.
You should end up with the following entries in the .classpath file:
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
What I've noticed that sometimes my unit test outputs change depending on the level of sandboxing done by the used testing tool. For example Eclipse seems to sandbox current selection(class, package, project) to a single setup-test-teardown cycle in same context while our CI seems to sandox every single unit test as setup-test-teardown cycle.
What this means is that if your test1 has a side effect which is then used in test2, it may work in Eclipse but it also may fail elsewhere. If this is the case, you need to rewrite your unit tests at least partly to decouple them from each other.
My remarks/question:
when you remove line "hibernate.hbm2ddl.auto" - the default action is none
what base test class you use? Try extends class org.springframework.test.jpa.AbstractJpaTests - it does rollback after each method
from exception stack trace seems to tables aren't clean before inserts
where your database (file) is stored? Maybe maven build clean database file.
do you use any maven plugins that are run in maven and not in eclipse (like hibernate3-maven-plugin)?
EDIT:
In my opinion test should be run in clean database and leave database clean, so each test/method should rollback after execution. Look at my qestion and responses. I think that using hibernate3-maven-plugin is optional.
This was happening to me for months, and I eventually realized the code under test wasn't quite as deterministic as I thought:
My code was susceptible to returning the wrong things if its inputs were in a different order
The code was iterating over a Set, not a List.
So in any given session, JVMs from Eclipse and Maven would usually order the set in a consistent way, but not always the same as each other.