Java XSLT transform csv to XML - java
Despite lots of thread on this topic, it still doesn't help here....
Is there a working example to illustrate the csv to xml transformation using xslt?
I'm using XSLT 2.0 to convert CSV to XML format
THe source csv file and xslt are all taken from the thread above:
#Test
public void testXSLT() throws IOException, TransformerException
{
Source inputText = new StreamSource(this.getClass().getClassLoader().getResourceAsStream(inputFile));
Source xslt = new StreamSource(this.getClass().getClassLoader().getResourceAsStream(xsltTemplate));
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer(xslt);
transformer.transform(inputText, new StreamResult(new File(outputFile)));
}
But still it says:
ERROR: 'Could not compile stylesheet'
FATAL ERROR: 'Error checking type of the expression 'funcall(unparsed-text-available, [parameter-ref(csv-uri/reference), parameter-ref(csv-encoding/reference)])'.'
:Error checking type of the expression 'funcall(unparsed-text-available, [parameter-ref(csv-uri/reference), parameter-ref(csv-encoding/reference)])'.
javax.xml.transform.TransformerConfigurationException: Error checking type of the expression 'funcall(unparsed-text-available, [parameter-ref(csv-uri/reference), parameter-ref(csv-encoding/reference)])'.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:1018)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:791)
at com.ihsmarkit.product.dtccpvin.csv2xmlFXOutrightTest.testXSLT(csv2xmlFXOutrightTest.java:48)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: Error checking type of the expression 'funcall(unparsed-text-available, [parameter-ref(csv-uri/reference), parameter-ref(csv-encoding/reference)])'.
at com.sun.org.apache.xalan.internal.xsltc.compiler.FunctionCall.typeCheckStandard(FunctionCall.java:461)
at com.sun.org.apache.xalan.internal.xsltc.compiler.FunctionCall.typeCheck(FunctionCall.java:370)
at com.sun.org.apache.xalan.internal.xsltc.compiler.When.typeCheck(When.java:88)
at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(SyntaxTreeNode.java:484)
at com.sun.org.apache.xalan.internal.xsltc.compiler.Instruction.typeCheck(Instruction.java:41)
at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(SyntaxTreeNode.java:484)
at com.sun.org.apache.xalan.internal.xsltc.compiler.LiteralElement.typeCheck(LiteralElement.java:198)
at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(SyntaxTreeNode.java:484)
at com.sun.org.apache.xalan.internal.xsltc.compiler.Template.typeCheck(Template.java:291)
at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(SyntaxTreeNode.java:484)
at com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.typeCheck(Stylesheet.java:654)
at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.createAST(Parser.java:412)
at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:483)
at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:568)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:977)
... 32 more
---------
Error checking type of the expression 'funcall(unparsed-text-available, [parameter-ref(csv-uri/reference), parameter-ref(csv-encoding/reference)])'.
at com.sun.org.apache.xalan.internal.xsltc.compiler.FunctionCall.typeCheckStandard(FunctionCall.java:461)
at com.sun.org.apache.xalan.internal.xsltc.compiler.FunctionCall.typeCheck(FunctionCall.java:370)
at com.sun.org.apache.xalan.internal.xsltc.compiler.When.typeCheck(When.java:88)
at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(SyntaxTreeNode.java:484)
at com.sun.org.apache.xalan.internal.xsltc.compiler.Instruction.typeCheck(Instruction.java:41)
at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(SyntaxTreeNode.java:484)
at com.sun.org.apache.xalan.internal.xsltc.compiler.LiteralElement.typeCheck(LiteralElement.java:198)
at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(SyntaxTreeNode.java:484)
at com.sun.org.apache.xalan.internal.xsltc.compiler.Template.typeCheck(Template.java:291)
at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(SyntaxTreeNode.java:484)
at com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.typeCheck(Stylesheet.java:654)
at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.createAST(Parser.java:412)
at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:483)
at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:568)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:977)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:791)
at com.ihsmarkit.product.dtccpvin.csv2xmlFXOutrightTest.testXSLT(csv2xmlFXOutrightTest.java:48)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
XSLT 2 is not supported by the Xalan XSLT processor you are trying to use, you will need to switch the Saxon 9 (available in the open source HE edition on Sourceforge and Maven). Furthermore the API you use it meant for XSLT 1 with an XML input source, if you want to use that API you would need to pass in a dummy XML input. In the linked example, the CSV file location is supposed to be passed in as the parameter csv-uri. As an alternative, you can use Saxon 9's native s9api (http://saxonica.com/html/documentation/using-xsl/embedding/s9api-transformation.html) and simply start the transformation with the named template, in that case you don't need a dummy XML input.
Related
Deserialize LocalDateTime when it contains zone information
I have received a timestamp from a server and I want to deserialize it to a LocalDateTime instance. The timestamp I received has time zone information and its similar to this string 2022-03-24T22:44:03.241082Z[Etc/UTC] When I try to deserialize it using Gson I get the following exception java.time.format.DateTimeParseException: Text '2022-03-24T22' could not be parsed at index 13 at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949) at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851) at java.time.LocalDateTime.parse(LocalDateTime.java:492) at java.time.LocalDateTime.parse(LocalDateTime.java:477) at myapp.libraries.serialization.decoders.LocalDateTimeDecoder.deserialize(LocalDateTimeDecoder.kt:15) at myapp.libraries.serialization.decoders.LocalDateTimeDecoder.deserialize(LocalDateTimeDecoder.kt:13) at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) at com.google.gson.Gson.fromJson(Gson.java:932) at com.google.gson.Gson.fromJson(Gson.java:897) at com.google.gson.Gson.fromJson(Gson.java:846) at com.google.gson.Gson.fromJson(Gson.java:817) at myapp.libraries.serialization.SerializationSpec.It must deserialize LocalDateTime(SerializationSpec.kt:77) 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58) My deserialization code is class LocalDateTimeDecoder : JsonDeserializer<LocalDateTime> { override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): LocalDateTime { return LocalDateTime.parse(json?.asJsonPrimitive?.asString) } } How can I deserialize this?
Getting IllegalStateException while calling restTemplate.exchange()
Getting the java.lang.IllegalStateException while trying to read the data from json file using RestTemplate.exchange(). Tried many ways, but no success. Any suggestion would be appreciate. Code: ResponseEntity<GetCustomerResponse> customerResponse = restTemplate.exchange("J:\Backup\FILWORKSPACE\tapp100997_accountopeningservice\target\classes\testdata\CustomerEnquiryApiResponse.json",HttpMethod.POST, request, GetCustomerResponse.class); Exception : java.lang.IllegalStateException: Could not create URI object: Illegal character in opaque part at index 2: J:\Backup\FILWORKSPACE\tapp100997_accountopeningservice\target\classes\testdata\CustomerEnquiryApiResponse.json at org.springframework.web.util.DefaultUriTemplateHandler.createUri(DefaultUriTemplateHandler.java:168) at org.springframework.web.util.DefaultUriTemplateHandler.expandInternal(DefaultUriTemplateHandler.java:105) at org.springframework.web.util.AbstractUriTemplateHandler.expand(AbstractUriTemplateHandler.java:106) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:612) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:531) at com.fidintl.bs.accountopening.rulengine.rules.CustomerRule.getCustomerDetails(CustomerRule.java:169) at com.fidintl.bs.accountopening.rulengine.rules.CustomerRule.execute(CustomerRule.java:55) at com.fidintl.bs.accountopening.rulengine.rules.CustomerRuleTest.testCustomerEligibilityWithBlankData(CustomerRuleTest.java:122) 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:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37) at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) Caused by: java.net.URISyntaxException: Illegal character in opaque part at index 2: J:\Backup\FILWORKSPACE\tapp100997_accountopeningservice\target\classes\testdata\CustomerEnquiryApiResponse.json at java.net.URI$Parser.fail(URI.java:2848) at java.net.URI$Parser.checkChars(URI.java:3021) at java.net.URI$Parser.parse(URI.java:3058) at java.net.URI.<init>(URI.java:588) at org.springframework.web.util.DefaultUriTemplateHandler.createUri(DefaultUriTemplateHandler.java:165) ... 33 more Json file Data : {"success":true,"errors":[],"customerDetails":[{"customerReference":{"type":"PARTY_REFERENCE_NUMBER","identifier":"500008713684"},"success":true,"errors":[],"customers":[{"customerType":"INDIVIDUAL_INVESTOR","individualClientDetails":{"personalDetails":{"personName":{"title":"Miss","initials":null,"firstName":"User","lastName":"Payroll","fullName":"Miss User Payroll","printName":"Miss User Payroll"},"dateOfBirth":"1970-12-01","dateOfDeath":null,"gender":"UNKNOWN","maritalStatus":"UNKNOWN","townOfBirth":null,"countryOfBirth":"GB","nationalityDetails":[{"countryCode":"GB","primaryNationalityFlag":null,"reportingNationalityFlag":"Y","reportingDetails":{"nationalIdType":"TAX_IDENTIFIER","nationalId":"AB109999D"}},{"countryCode":"GB","primaryNationalityFlag":"Y","reportingNationalityFlag":null,"reportingDetails":null}],"countriesOfResidence":[{"countryCode":"GB","countryName":"UNITED KINGDOM","primaryCountryOfResidence":"Y"}],"age":"48","niNoIssuedFlag":"Y","anticipatedRetirementAge":null},"crownEmployeeFlag":"N","planParticipantDetails":null,"employerDetails":null,"occupation":null},"institutionalClientDetails":null,"partyReferenceNumber":"500008713684","alternativeReferences":[{"identifierType":"SONATA_CLIENT_ID","identifier":"100668431"},{"identifierType":"INVESTOR_REFERENCE_NUMBER","identifier":"1004664408"}],"lifeCycleStatus":"INVESTOR","inceptionDate":"2019-03-19","dormancyDate":null,"directAdvisedIndicator":"DIRECT_AND_ADVISED","lostContactFlag":"N","probateFlag":"N","courtOfProtectionFlag":"N","languagePreference":"ENG","postalAddresses":[{"contactRole":"CORRESPONDENCE_ADDRESS","nonStructuredAddressDetails":{"line1":"30 Benedict Drive","line2":null,"line3":"FELTHAM","line4":null},"structuredAddressDetails":null,"overrideAddress":"N","administrativeArea":null,"postalTown":"FELTHAM","postalCode":"TW14 8JL","region":"UK","countryCode":"GB","setBy":"500008713684","status":"ACTIVE","validity":{"lastValidatedDate":null,"validFrom":"2019-03-19 18:05:07.000+0000","validTo":null},"countryName":"UNITED KINGDOM"},{"contactRole":"REGISTERED_ADDRESS","nonStructuredAddressDetails":{"line1":"30 Benedict Drive","line2":null,"line3":"FELTHAM","line4":null},"structuredAddressDetails":null,"overrideAddress":"N","administrativeArea":null,"postalTown":"FELTHAM","postalCode":"TW14 8JL","region":"UK","countryCode":"GB","setBy":"500008713684","status":"ACTIVE","validity":{"lastValidatedDate":null,"validFrom":"2019-03-19 18:05:07.000+0000","validTo":null},"countryName":"UNITED KINGDOM"}],"classifications":[{"classificationScheme":"FATCA_US","classificationCode":"INUS05","classificationDescription":"Non US Status"},{"classificationScheme":"OFFICE_CODE","classificationCode":"OAKH","classificationDescription":"FIL Investments International"},{"classificationScheme":"MIFID","classificationCode":"RE","classificationDescription":"Retail"},{"classificationScheme":"GFAS_CUSTOMER_TYPE","classificationCode":"P","classificationDescription":"Private Individual"}],"externalIdentifiers":[{"identifierName":"TAX_IDENTIFICATION_NUMBER","value":"AB109999D","country":"GB","tinNotIssued":"NOT_CONFIRMED"},{"identifierName":"NATIONAL_INSURANCE_NUMBER","value":"AB109999D","country":"GB","tinNotIssued":null}],"salutations":null,"documentDeliveryPreferenceDetails":{"documentDeliveryPreferences":[{"documentType":"COT","deliveryMethod":"POST_AND_ONLINE"},{"documentType":"SAV","deliveryMethod":"POST_AND_ONLINE"},{"documentType":"PLC","deliveryMethod":"POST_AND_ONLINE"},{"documentType":"RRL","deliveryMethod":"POST_AND_ONLINE"},{"documentType":"WPL","deliveryMethod":"POST_AND_ONLINE"},{"documentType":"DTL","deliveryMethod":"POST_AND_ONLINE"},{"documentType":"ITR","deliveryMethod":"POST_AND_ONLINE"},{"documentType":"WL","deliveryMethod":"POST_AND_ONLINE"},{"documentType":"MLC","deliveryMethod":"POST_AND_ONLINE"}],"emailNotificationFlag":"N"},"electronicAddresses":null,"telephones":null,"partyAssociations":null,"amlStatusDetails":null,"bankAccountDetails":null,"w8BenDetails":null,"reportingCurrency":null,"associatedFILEmployee":null,"employmentStatus":null,"marketingSource":null,"partyGenericVariables":{"genericVariables":[{"name":"PLATFORM","values":["SONATA"]},{"name":"PDP_CONSENT","values":["YES"]}]},"restrictions":null,"roleToFIL":null,"marketingPreferences":[],"applicationTerms":[{"applicationTermsAndCondition":{"applicationName":"ISA Declaration","applicationVersion":"1.0","applicationTermsAndConditionsVersion":"2.0","dateAccepted":"2015-03-12 00:00:00.000+0000","applicationType":"DOCUMENT"}},{"applicationTermsAndCondition":{"applicationName":"Doing Business with Fidelity","applicationVersion":"1.0","applicationTermsAndConditionsVersion":"2.0","dateAccepted":"2015-03-12 00:00:00.000+0000","applicationType":"DOCUMENT"}},{"applicationTermsAndCondition":{"applicationName":"Payroll ISA","applicationVersion":"1.0","applicationTermsAndConditionsVersion":"2.0","dateAccepted":"2015-03-12 00:00:00.000+0000","applicationType":"DOCUMENT"}},{"applicationTermsAndCondition":{"applicationName":"Fidelity's Privacy Policy","applicationVersion":"1.0","applicationTermsAndConditionsVersion":"2.0","dateAccepted":"2015-03-12 00:00:00.000+0000","applicationType":"DOCUMENT"}},{"applicationTermsAndCondition":{"applicationName":"US Person","applicationVersion":"1.0","applicationTermsAndConditionsVersion":"2.0","dateAccepted":"2015-03-12 00:00:00.000+0000","applicationType":"DOCUMENT"}},{"applicationTermsAndCondition":{"applicationName":"Client Terms","applicationVersion":"1.0","applicationTermsAndConditionsVersion":"2.0","dateAccepted":"2015-03-12 00:00:00.000+0000","applicationType":"DOCUMENT"}},{"applicationTermsAndCondition":{"applicationName":"Online Terms","applicationVersion":"1.0","applicationTermsAndConditionsVersion":"2.0","dateAccepted":"2015-03-12 00:00:00.000+0000","applicationType":"DOCUMENT"}}],"createdBy":null,"assignedTo":null,"updatedBy":null,"auditDetails":null,"standingPreferences":null,"literaturePreferences":null,"documentDeliveryPreferences":null,"pensionDetails":null,"migration":null,"pensionPlatform":null,"clientRegionDetails":null}]}]}
From docs https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html#exchange-java.lang.String-org.springframework.http.HttpMethod-org.springframework.http.HttpEntity-java.lang.Class-java.lang.Object...-, Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity. You need to use valid hhtp url.
How to resolve Selenium Error After installing latest Java version and appium through npm?
I am running my JUnit code from the particular server and this type of weird error I am facing and I have installed latest appium and java version also through npm commands as well but not able to fix this error. Please help to get out of this error. [1]: https://i.stack.imgur.com/hVpGi.png at utils.app_automation.Automation.startApp(Automation.java:196) at po.Help.setUP(Help.java:251) 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at org.junit.runner.JUnitCore.run(JUnitCore.java:105) at org.junit.runner.JUnitCore.run(JUnitCore.java:94) at com.segue.tm.plugins.testlaunch.junit.ju4support.JU4Helper.executeJunitTest(JU4Helper.java:127) at com.segue.tm.plugins.testlaunch.junit.ju4support.JU4Helper.executeJU4TestClassOrMethodOnly(JU4Helper.java:53) at com.segue.tm.plugins.testlaunch.junit.ju4support.JUnit4CmdLineWrapper.main(JUnit4CmdLineWrapper.java:37).
Using HbaseTestingUtility with hbase-shaded-server and hbase-shaded-client
I am trying to use HBaseTestingUtility 1.2 with hbase-shaded-client & hbase-shaded-server. It is throwing me the below exception. Can someone let me know how can I avoid this or HbaseTestingUtility does not work properly with shaded hbase client & server? java.lang.ClassCastException: org.apache.hadoop.hbase.shaded.org.mortbay.jetty.servlet.Context$SContext cannot be cast to org.mortbay.jetty.handler.ContextHandler$SContext at org.mortbay.jetty.servlet.DefaultServlet.init(DefaultServlet.java:154) at javax.servlet.GenericServlet.init(GenericServlet.java:241) at org.apache.hadoop.hbase.shaded.org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440) at org.apache.hadoop.hbase.shaded.org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263) at org.apache.hadoop.hbase.shaded.org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.apache.hadoop.hbase.shaded.org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:736) at org.apache.hadoop.hbase.shaded.org.mortbay.jetty.servlet.Context.startContext(Context.java:140) at org.apache.hadoop.hbase.shaded.org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282) at org.apache.hadoop.hbase.shaded.org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:519) at org.apache.hadoop.hbase.shaded.org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499) at org.apache.hadoop.hbase.shaded.org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.apache.hadoop.hbase.shaded.org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) at org.apache.hadoop.hbase.shaded.org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156) at org.apache.hadoop.hbase.shaded.org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.apache.hadoop.hbase.shaded.org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.apache.hadoop.hbase.shaded.org.mortbay.jetty.Server.doStart(Server.java:224) at org.apache.hadoop.hbase.shaded.org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.apache.hadoop.http.HttpServer2.start(HttpServer2.java:900) at org.apache.hadoop.hdfs.server.namenode.NameNodeHttpServer.start(NameNodeHttpServer.java:142) at org.apache.hadoop.hdfs.server.namenode.NameNode.startHttpServer(NameNode.java:774) at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:667) at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:838) at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:817) at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1538) at org.apache.hadoop.hdfs.MiniDFSCluster.createNameNode(MiniDFSCluster.java:1114) at org.apache.hadoop.hdfs.MiniDFSCluster.createNameNodesAndSetConf(MiniDFSCluster.java:985) at org.apache.hadoop.hdfs.MiniDFSCluster.initMiniDFSCluster(MiniDFSCluster.java:814) at org.apache.hadoop.hdfs.MiniDFSCluster.<init>(MiniDFSCluster.java:745) at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniDFSCluster(HBaseTestingUtility.java:585) at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster(HBaseTestingUtility.java:987) at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster(HBaseTestingUtility.java:868) at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster(HBaseTestingUtility.java:862) at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster(HBaseTestingUtility.java:806) at com.vnera.storage.metrics.HBaseTestTableFactory.<init>(HBaseTestTableFactory.java:25) at com.vnera.storage.metrics.HBaseTests.testCounterTimetamp(HBaseTests.java:70) 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Right now hbase-testing-util does not work with hbase-shaded-serverand habse-shaded-client because of the below open issue:- https://issues.apache.org/jira/browse/HBASE-15666
org.mockito.exceptions.misusing.WrongTypeOfReturnValue: ArrayList cannot be returned by toString()
In my code i set the return value of a mock: when(spreadSheetHandler.readData("2")) .thenReturn(jsonUtility.fromSpreadSheetJsonFile()); this is readData signature public List<List<String>> readData(String range) throws IOException { and this is public List<List<String>> fromSpreadSheetJsonFile() { List<List<String>> fromJsonFile = null; ObjectMapper mapper = new ObjectMapper(); TypeReference<List<List<String>>> mapType = new TypeReference<List<List<String>>>() {}; try { fromJsonFile = mapper.readValue(new File("/Users/eladb/WorkspaceQa/sdk-service/src/test/resources/spreadsheetList.json"), mapType); } catch (Exception ex) { logger.error("json parsing failure", ex); } return fromJsonFile; } fromSpreadSheetJsonFile finishes successfully but then i get an error: java.lang.reflect.InvocationTargetException 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Caused by: org.mockito.exceptions.misusing.WrongTypeOfReturnValue: ArrayList cannot be returned by toString() toString() should return String *** If you're unsure why you're getting above error read on. Due to the nature of the syntax above problem might occur because: 1. This exception *might* occur in wrongly written multi-threaded tests. Please refer to Mockito FAQ on limitations of concurrency testing. 2. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies - - with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method. at com.waze.sdkClient.servlets.ClientRunner_PublishTest.readFromSpreadsheet3Rows_shouldPublish2Times(ClientRunner_PublishTest.java:51) ... 23 more java.lang.reflect.InvocationTargetException 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Caused by: org.mockito.exceptions.misusing.WrongTypeOfReturnValue: ArrayList cannot be returned by toString() toString() should return String *** If you're unsure why you're getting above error read on. Due to the nature of the syntax above problem might occur because: 1. This exception *might* occur in wrongly written multi-threaded tests. Please refer to Mockito FAQ on limitations of concurrency testing. 2. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies - - with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method. what can cause it? as i return List> as expected?