Decoding Base58 public keys back into PublicKey instances doesn't seem to work:
parsePublicKeyBase58("DLG9nscvKPbgagoLP7jr4oc5FygazKr7pdADZMGFizmpV8")
Exception in thread "main" java.lang.IllegalArgumentException: failed to construct sequence from byte[]: unknown tag 9 encountered
at org.bouncycastle.asn1.ASN1Sequence.getInstance(Unknown Source)
at org.bouncycastle.asn1.x509.SubjectPublicKeyInfo.getInstance(Unknown Source)
at net.corda.core.crypto.Crypto.decodePublicKey(Crypto.kt:343)
at net.corda.core.utilities.EncodingUtils.parsePublicKeyBase58(EncodingUtils.kt:81)
at test.Program$Companion.main(Program.kt:15)
at test.Program.main(Program.kt)
What's wrong here?
What error are you getting with that – Sneha Damle?
parsePublicKeyBase58("G9nscvKPbgagoLP7jr4oc5FygazKr7pdADZMGFizmpV8")
Exception in thread "main" java.lang.IllegalArgumentException: failed to construct sequence from byte[]: DEF length 31 object truncated by 1
at org.bouncycastle.asn1.ASN1Sequence.getInstance(Unknown Source)
at org.bouncycastle.asn1.x509.SubjectPublicKeyInfo.getInstance(Unknown Source)
at net.corda.core.crypto.Crypto.decodePublicKey(Crypto.kt:343)
at net.corda.core.utilities.EncodingUtils.parsePublicKeyBase58(EncodingUtils.kt:81)
at test.ProgramKt.main(Program.kt:6)
You are probably using an incorrect Base58 string. I did the following and it worked.
Encoded a Public Key to Base58
Base58.encode(party.getOwningKey().getEncoded()).toString();
This gave me the String GfHq2tTVk9z4eXgyH7WThpV3Qn7zdCm4cKw8J5x8kVGnVkGtgAmh3KKE7EN4
Decoded it:
PublicKey publicKey = EncodingUtils.parsePublicKeyBase58("GfHq2tTVk9z4eXgyH7WThpV3Qn7zdCm4cKw8J5x8kVGnVkGtgAmh3KKE7EN4");
Related
My Android Studio gives me this fatal error.
So Far, I did ivalidated cache, I restored to default settings, I even configured VM acceleration but nothing worked.
I also getting syntax highlighting has been temporarily turned off because of an internal error in my mainActivity.kt, and it doesn't show any preview despite the #Preview tag.
The stacktrace is as follows:
java.lang.NullPointerException
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenComponentFactory.lambda$createEventLink$1(WelcomeScreenComponentFactory.java:303)
at com.intellij.util.messages.impl.MessageBusImpl.invokeMethod(MessageBusImpl.java:645)
at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:624)
at com.intellij.util.messages.impl.MessageBusImpl.deliverMessage(MessageBusImpl.java:417)
at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:390)
at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:372)
at com.intellij.util.messages.impl.MessageBusImpl.access$200(MessageBusImpl.java:33)
at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.invoke(MessageBusImpl.java:179)
at com.sun.proxy.$Proxy96.notificationsChanged(Unknown Source)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl.updatePopup(WelcomeBalloonLayoutImpl.java:181)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl$3.dispose(WelcomeBalloonLayoutImpl.java:124)
at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:139)
at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:169)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:217)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:205)
at com.intellij.ui.BalloonLayoutImpl.dispose(BalloonLayoutImpl.java:84)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl.dispose(WelcomeBalloonLayoutImpl.java:51)
at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:139)
at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:169)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:217)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:205)
at com.intellij.openapi.wm.impl.welcomeScreen.FlatWelcomeFrame.dispose(FlatWelcomeFrame.java:232)
at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:139)
at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:169)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:217)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:205)
at com.intellij.openapi.wm.impl.welcomeScreen.FlatWelcomeFrame$1.projectOpened(FlatWelcomeFrame.java:124)
at com.intellij.util.messages.impl.MessageBusImpl.invokeMethod(MessageBusImpl.java:645)
at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:624)
at com.intellij.util.messages.impl.MessageBusImpl.access$300(MessageBusImpl.java:33)
at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.executeOrAddToQueue(MessageBusImpl.java:208)
at com.intellij.util.messages.impl.CompositeMessageBus$ToDirectChildrenMessagePublisher.publish(CompositeMessageBus.java:105)
at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.invoke(MessageBusImpl.java:166)
at com.sun.proxy.$Proxy128.projectOpened(Unknown Source)
at com.intellij.openapi.project.impl.ProjectManagerExImplKt$openProject$1.run(ProjectManagerExImpl.kt:468)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeAndWait$7(ApplicationImpl.java:450)
at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:134)
at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:951)
at com.intellij.openapi.progress.util.ProgressWindow.lambda$startBlocking$6(ProgressWindow.java:221)
at com.intellij.openapi.application.impl.ApplicationImpl.runUnlockingIntendedWrite(ApplicationImpl.java:831)
at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:217)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$execFromEDT$6(ProgressRunner.java:321)
at java.base/java.util.concurrent.CompletableFuture.uniAcceptNow(CompletableFuture.java:753)
at java.base/java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:731)
at java.base/java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2108)
at com.intellij.openapi.progress.impl.ProgressRunner.execFromEDT(ProgressRunner.java:318)
at com.intellij.openapi.progress.impl.ProgressRunner.submit(ProgressRunner.java:259)
at com.intellij.openapi.progress.impl.ProgressRunner.submitAndGet(ProgressRunner.java:185)
at com.intellij.openapi.project.impl.ProjectUiFrameAllocator.run(ProjectFrameAllocator.kt:116)
at com.intellij.openapi.project.impl.ProjectManagerExImpl.doOpenAsync(ProjectManagerExImpl.kt:119)
at com.intellij.openapi.project.impl.ProjectManagerExImpl.openProjectAsync(ProjectManagerExImpl.kt:110)
at com.intellij.openapi.project.impl.ProjectManagerExImpl.openProject(ProjectManagerExImpl.kt:72)
at com.intellij.ide.impl.ProjectUtil.tryOpenOrImport(ProjectUtil.java:172)
at com.intellij.ide.impl.ProjectUtil.openOrImport(ProjectUtil.java:131)
at com.intellij.ide.impl.ProjectUtil.openOrImport(ProjectUtil.java:127)
at com.android.tools.idea.actions.AndroidOpenFileAction.openOrImportProject(AndroidOpenFileAction.java:179)
at com.android.tools.idea.actions.AndroidOpenFileAction.doOpenFile(AndroidOpenFileAction.java:149)
at com.android.tools.idea.actions.AndroidOpenFileAction.lambda$actionPerformed$0(AndroidOpenFileAction.java:111)
at com.intellij.openapi.fileChooser.ex.FileChooserDialogImpl.choose(FileChooserDialogImpl.java:146)
at com.intellij.openapi.fileChooser.FileChooser.chooseFiles(FileChooser.java:102)
at com.intellij.openapi.fileChooser.FileChooser.chooseFiles(FileChooser.java:80)
at com.android.tools.idea.actions.AndroidOpenFileAction.actionPerformed(AndroidOpenFileAction.java:101)
at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:239)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:260)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:239)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenActionsUtil.performAnActionForComponent(WelcomeScreenActionsUtil.java:96)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenActionsUtil$LargeIconWithTextWrapper.lambda$new$0(WelcomeScreenActionsUtil.java:125)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:270)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6654)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345)
at java.desktop/java.awt.Component.processEvent(Component.java:6419)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5029)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2790)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:820)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:757)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:498)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)```
What happens on line 303 of WelcomeScreenComponentFactory.java:303 ?
In general a NPE or null pointer exception happens when you attempt to reference a method or property of an variable in code and that variable is not initialized or is pointing at null. if on line 303 you have someObject.someMethod() then can infer that someObject was null when the line was run. Sounds like when you're calling that library method the object being passed to it is null, but can maybe run in debug mode and step back through the stack trace to see what call/setup your app made before the exception is thrown as well.
On Ubuntu with groovy:
$ groovy --version
Groovy Version: 2.1.9 JVM: 11.0.10 Vendor: Oracle Corporation OS: Linux
I have this script:
myScript.groovy
import org.apache.commons.lang.RandomStringUtils
String charset = (('A'..'Z') + ('0'..'9')).join()
Integer length = 9
String randomString1 = RandomStringUtils.random(length, charset.toCharArray())
String randomString2 = RandomStringUtils.random(length, charset.toCharArray())
String randomString3 = RandomStringUtils.random(length, charset.toCharArray())
From terminal I run it:
$ groovy sampleScript.groovy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass$3$1 (file:/home/user/.sdkman/candidates/groovy/current/lib/groovy-2.1.9.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass$3$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/home/samples/myScript.groovy: 3: unable to resolve class org.apache.commons.lang.RandomStringUtils
# line 3, column 1.
import org.apache.commons.lang.RandomStringUtils
^
If I search for that in maven central I get:
https://search.maven.org/search?q=org.apache.commons.lang.RandomStringUtils
<dependency>
<groupId>io.github.showthat</groupId>
<artifactId>DHStringUtils</artifactId>
<version>0.1.5</version>
<type>aar</type>
</dependency>
I have then tried to update my script with:
#Grab(group='io.github.showthat', module='DHStringUtils', version='0.1.5')
import org.apache.commons.lang.RandomStringUtils
String charset = (('A'..'Z') + ('0'..'9')).join()
Integer length = 9
String randomString1 = RandomStringUtils.random(length, charset.toCharArray())
String randomString2 = RandomStringUtils.random(length, charset.toCharArray())
String randomString3 = RandomStringUtils.random(length, charset.toCharArray())
But that gives:
General error during conversion: Error grabbing Grapes -- [unresolved dependency: io.github.showthat#DHStringUtils;0.1.5: not found]
java.lang.RuntimeException: Error grabbing Grapes -- [unresolved dependency: io.github.showthat#DHStringUtils;0.1.5: not found]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAc
Based on:
https://search.maven.org/search?q=org.apache.commons.lang
I have also tried with:
#Grab(group='org.apache.directory.studio', module='org.apache.commons.lang', version='2.6')
But that gives:
General error during conversion: Error grabbing Grapes -- [unresolved dependency: org.apache.directory.studio#org.apache.commons.lang;2.6: not found]
java.lang.RuntimeException: Error grabbing Grapes -- [unresolved dependency: org.apache.directory.studio#org.apache.commons.lang;2.6: not found]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
Any suggestions?
Guessing from your very old Groovy version you inherited some old
scripts. The packages of apache-commons has changed over time. The
RandomStringUtils are now part of
#Grab(group='org.apache.commons', module='commons-lang3', version='3.12.0')
And the package changed to:
import org.apache.commons.lang3.RandomStringUtils
(note the 3 at the end of lang).
I'd advise to update the deps and adjust the code. If you have to have
to stick with the old code, you might have to search for the file via
findjar or other sites and only take groups/artifacts that clearly state
"apache commons". Anything else might just have copied it and might
not even be complete. So I'd stay clear of anything non-apache-commons.
I am trying to run a RESTClient in Groovy to perform a HTTP PUT request usingthe below code, I am however facing the an issue
def jsonObj = JsonOutput.toJson(version)
println(jsonObj)
def jsonObjtrim = jsonObj.trim()
println("**** FIND 1ST CHAR *******")
println((int)jsonObjtrim.charAt(0))
def response = client.put(path: "/cli/snapshot/createSnapshot",
contentType: "application/json",
body: "$jsonObjtrim",
headers: [Accept: 'application/json'])
println("JSON value is $jsonObj")
I've made the above code print the JSON value after i construct the JSON just to be sure that i am passing the right value and it can be seen in output below. In the error printed below, the 1st line is the JSON that i constructed, the 3rd line confirms my 1st character of the JSON object is a { as that is what the error is as per the logs.
OUTPUT LOGS
{"name":"RESTSnapshot3","application":"JKEBank","description":"Requesting deployment","versions":[{"Mortgage":"448.20170828-1755250845"},{"Mortgage":"845.20190507-1820230086"}]}
**** FIND 1ST CHAR *******
123
Nov 11, 2019 2:39:02 PM groovyx.net.http.HTTPBuilder$1 handleResponse
WARNING: Error parsing 'text/plain;charset=UTF-8' response
groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'E' with an int value of 69
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
Error processing command: A JSONObject text must begin with '{' at character 1 of ?????z???????????k???????????z?????k???????????z?????????#??????????k????????z?????????z???K????????`???????????k????????z???K????????`????????????
at org.apache.groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:202)
at org.apache.groovy.json.internal.JsonParserCharArray.decodeValue(JsonParserCharArray.java:153)
at org.apache.groovy.json.internal.JsonParserCharArray.decodeFromChars(JsonParserCharArray.java:42)
at org.apache.groovy.json.internal.JsonParserCharArray.parse(JsonParserCharArray.java:380)
at org.apache.groovy.json.internal.BaseJsonParser.parse(BaseJsonParser.java:131)
at groovy.json.JsonSlurper.parse(JsonSlurper.java:218)
at groovyx.net.http.ParserRegistry.parseJSON(ParserRegistry.java:280)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:507)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1080)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at groovy.lang.Closure.call(Closure.java:414)
at groovy.lang.Closure.call(Closure.java:430)
at groovyx.net.http.HTTPBuilder.parseResponse(HTTPBuilder.java:560)
at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:489)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
at groovyx.net.http.RESTClient.put(RESTClient.java:163)
at groovyx.net.http.RESTClient$put$0.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 groovy_script_7303971688153863540.run(groovy_script_7303971688153863540.groovy:146)
at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
at groovy.lang.GroovyShell.run(GroovyShell.java:518)
at groovy.lang.GroovyShell.run(GroovyShell.java:507)
at groovy.ui.GroovyMain.processOnce(GroovyMain.java:653)
at groovy.ui.GroovyMain.run(GroovyMain.java:384)
at groovy.ui.GroovyMain.process(GroovyMain.java:370)
at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)
at groovy.ui.GroovyMain.main(GroovyMain.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:507)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
Caught: groovyx.net.http.ResponseParseException: status code: 400, reason phrase: Bad Request
groovyx.net.http.ResponseParseException: status code: 400, reason phrase: Bad Request
at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:495)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
at groovyx.net.http.RESTClient.put(RESTClient.java:163)
at groovyx.net.http.RESTClient$put$0.call(Unknown Source)
at groovy_script_7303971688153863540.run(groovy_script_7303971688153863540.groovy:146)
Caused by: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
^
Please note that this works perfectly on Groovy 2.5.6 on my IntellIJ but doesnt when i execute it on Linux based OMVS on Mainframe z/OS that currently runs on Groovy 2.4.12. Also, i tried HTTPBuilder 0.5.0/0.5.2/0.7.1 and still the same response.
I am trying to connect ADS1015 ADC with my Pico Pro Maker. Unfortunately, I got folowing error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.cililing.harvbox.thingsapp, PID: 1855
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:448)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: com.google.android.things.pio.PioException: android.os.ServiceSpecificException: I2C2 is already in use (code 16)
at com.google.android.things.pio.I2cDeviceImpl.<init>(I2cDeviceImpl.java:43)
at com.google.android.things.pio.PeripheralManager.openI2cDevice(PeripheralManager.java:246)
at com.google.android.things.contrib.driver.adc.ads1xxx.Ads1xxx.<init>(Ads1xxx.java:200)
at com.google.android.things.contrib.driver.adc.ads1xxx.Ads1xxx.<init>(Ads1xxx.java:187)
at com.cililing.harvbox.thingsapp.thingscontroller.controllers.ADS1015ControllerImpl.<init>(ADS1015Controller.kt:12)
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2CController$2.invoke(MainActivity.kt:40)
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2CController$2.invoke(MainActivity.kt:33)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.cililing.harvbox.thingsapp.ui.MainActivity.getI2CController(Unknown Source:25)
at com.cililing.harvbox.thingsapp.ui.MainActivity.access$getI2CController$p(MainActivity.kt:33)
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2cLogger$1.run(MainActivity.kt:47)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.os.ServiceSpecificException: I2C2 is already in use (code 16)
at android.os.Parcel.readException(Parcel.java:2027)
at android.os.Parcel.readException(Parcel.java:1959)
at com.google.android.things.pio.IPeripheralManagerClient$Stub$Proxy.OpenI2cDevice(IPeripheralManagerClient.java:1243)
at com.google.android.things.pio.I2cDeviceImpl.<init>(I2cDeviceImpl.java:41)
at com.google.android.things.pio.PeripheralManager.openI2cDevice(PeripheralManager.java:246)
at com.google.android.things.contrib.driver.adc.ads1xxx.Ads1xxx.<init>(Ads1xxx.java:200)
at com.google.android.things.contrib.driver.adc.ads1xxx.Ads1xxx.<init>(Ads1xxx.java:187)
at com.cililing.harvbox.thingsapp.thingscontroller.controllers.ADS1015ControllerImpl.<init>(ADS1015Controller.kt:12)
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2CController$2.invoke(MainActivity.kt:40)
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2CController$2.invoke(MainActivity.kt:33)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.cililing.harvbox.thingsapp.ui.MainActivity.getI2CController(Unknown Source:25)
at com.cililing.harvbox.thingsapp.ui.MainActivity.access$getI2CController$p(MainActivity.kt:33)
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2cLogger$1.run(MainActivity.kt:47)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
I am using following driver:
https://github.com/androidthings/contrib-drivers/tree/master/adc
What I've already done:
uninstall all apps
reinstall whole AndroidThings
I tired both, I2C1 and I2C2
try to read value on new app (only example from library).
I have no idea what can I do more. I am pretty sure that device is connected properly (scl-scl, sda-sda, addr-gnd, a0-other_analog_output) to main board and error is actually kind of strange, as I am sure that none other app uses those pins.
code responsible for connecting with peripheral:
class ADS1015ControllerImpl(val i2cName: String,
val range: Int) : ADS1015Controller {
private val instance: Ads1xxx = Ads1xxx(i2cName, Ads1xxx.Configuration.ADS1015)
init {
instance.inputRange = range
}
override fun read(channel: Int, logger: (Int) -> Unit) {
logger.invoke(
instance.readSingleEndedInput(channel)
)
}
override fun release() {
instance.close()
}
}
The error message I2C2 is already in use (code 16) means you are trying to open more than one connection to the same I2C bus without closing the previous instance. The code to open the I2C connection lives within the Ads1xxx constructor. You must either manage a single instance of this class in your code, or be certain that you call close() on the current Ads1xxx before initializing another one.
Based on the stack trace, it also looks like this device is being initialized by a lazy load when the value it first accessed, so it's possible that this constructor is not getting invoked at the point you expected, causing things to come out of order.
In fact, the problem was a badly soldered plug. :)
Can someone please advise how to remove a test step in SoapUI using groovy?
In my project, I have a REST test request that gets generated and executed on the fly. Once the request has been submitted, I would like to automatically remove this step using groovy script.
I tried something like:
testRunner.testCase.removeTestStep( "Trigger_REST_Request" );
But this returns error:
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.removeTestStep()
is applicable for argument types: (java.lang.String) values: [Trigger_REST_Request]
Possible solutions:
removeTestStep(com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep),
moveTestStep(int, int) groovy.lang.MissingMethodException
Thanks!
Well that worked....sort of. When I added the suggested two lines, I can see that the test step is removed, however, I'm also receiving a NullPointerException now. As a result the test suite exits after NPE is returned. This is the NPE error I get:
Wed Sep 21 09:27:11 EST 2016:ERROR:java.lang.NullPointerException
java.lang.NullPointerException
at com.eviware.soapui.model.support.ModelSupport.dependsOn(ModelSupport.java:196)
at com.eviware.soapui.impl.wsdl.teststeps.actions.ShowMessageExchangeAction$MessageExchangeDesktopPanel.dependsOn(ShowMessageExchangeAction.java:203)
at com.eviware.soapui.ui.desktop.AbstractSoapUIDesktop.closeDependantPanels(AbstractSoapUIDesktop.java:101)
at com.eviware.soapui.ui.desktop.AbstractSoapUIDesktop$InternalTestSuiteListener.testStepRemoved(AbstractSoapUIDesktop.java:190)
at com.eviware.soapui.impl.wsdl.WsdlTestSuite.fireTestStepRemoved(WsdlTestSuite.java:277)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.removeTestStep(WsdlTestCase.java:577)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase$removeTestStep.call(Unknown Source)
at Script9.run(Script9.groovy:19)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:92)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:211)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:138)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:46)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:129)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
If you need to remove the test step, use the following code:
def tc = testRunner.testCase
def tbr = tc.getTestStepByName('ToBeRemoved')
if (tbr != null) {
tc.removeTestStep(tbr)
}
The script handles also the case when the ToBeRemoved test step does not exist.