1

We have code looking like this.

HeaderCDSForPRForGuidedBuying requisitionHeader =  readHeaderInternal(draftUUID);

try {
  requisitionHeaderAddress = requisitionHeader.getGuidedProcmtReqnDelivAddrOrFetch();
} catch (NullPointerException ex) {
  logger.error("Exception occurred: No Address is associated with the requisition header", ex);
}

As can be seen, we are first fetching one entity(header), and then associated entity(DeliveryAddress), while this code works normally within the app, or within eclipse, it breaks when run as part of a maven execution. We have integration tests which are run with maven so it fails for us. The error is this.

java.lang.VerifyError: Stack map does not match the one at exception handler 275 Exception Details: Location: com/sap/cloud/sdk/odatav2/connectivity/internal/ODataExceptionInternalResultHandler.createError(Ljava/lang/String;Ljava/lang/Object;I)Lcom/sap/cloud/sdk/odatav2/connectivity/internal/ODataExceptionInternal; @275: astore Reason: Type 'org/json/JSONException' (current frame, stack[0]) is not assignable to 'java/lang/RuntimeException' (stack map, stack[0]) Current Frame: bci: @42 flags: { } locals: { 'com/sap/cloud/sdk/odatav2/connectivity/internal/ODataExceptionInternalResultHandler', 'java/lang/String', 'java/lang/Object', integer, integer, 'com/sap/cloud/sdk/odatav2/connectivity/internal/ODataExceptionInternal', 'java/lang/String', 'org/apache/http/HttpResponse', 'java/lang/String', '[Lorg/apache/http/Header;' } stack: { 'org/json/JSONException' } Stackmap Frame: bci: @275 flags: { } locals: { 'com/sap/cloud/sdk/odatav2/connectivity/internal/ODataExceptionInternalResultHandler', 'java/lang/String', 'java/lang/Object', integer, integer, 'com/sap/cloud/sdk/odatav2/connectivity/internal/ODataExceptionInternal', 'java/lang/String', 'org/apache/http/HttpResponse', 'java/lang/String', '[Lorg/apache/http/Header;' } stack: { 'java/lang/RuntimeException' }

This same issue is reported at https://github.com/Wikidata/Wikidata-Toolkit/issues/58. I believe a fix is also mentioned in that link.

Please fix it so that we can run our maven tests without any errors.

Thanks, Sachin

Sachin C Nambiar
  • 135
  • 2
  • 11
  • Can you please provide the dependency tree of your application? This looks for me like a dependency clash between `org.json:json` and `com.vaadin.external.google:android-json`, which both provide a `org.json.JSONException`. The first library has one as RuntimeException, the latter one as a "usualy" `Exception`. This now causes issues in the underlying libraries which need this as a Runtime Exception. Also, can you provide any more insight into the fix in the link you gave? I don't see how this would solve the issue. – Christoph Schubert May 11 '20 at 12:02
  • I checked the dependency tree. Its too big to put entirely. But the dependency com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test seems to come when there is test scope. Which makes sense since maven integration tests probably run with test scope. As for the fix mentioned in that link, I did not really get what is the issue, why it is not detected by compiler etc. But based on the changes in the code, it looks that a multi catch is changed to multiple individual catch blocks. That seems to have solved this problem for the reporter of that error. – Sachin C Nambiar May 11 '20 at 13:40
  • When I search for the error message, I do find a (already fixed) bug report from [Javassist](https://issues.redhat.com/browse/JASSIST-190?page=com.docminer.jira.issue-links%3Acom.kintosoft.jira.links.tab-panel) from 2013. It sounds like a stretch, but can you check whether there is a dependency somewhere to javassist? Or to be more precise, are there plugins during your maven build that could have a reference to this dependency? – Alexander Dümont May 12 '20 at 12:22
  • I found [this question](https://stackoverflow.com/questions/54804355/java-lang-verifyerror-stack-map-does-not-match-the-one-at-exception-handler) where it's suggested to set `-Xverify:none`. I haven't looked deeper into what that actually does but maybe you can try it. – MatKuhr May 12 '20 at 22:09

1 Answers1

2

The error is caused by a clash of dependencies as Christoph Schubert pointed out. To quote from his comment:

Both org.json:json and com.vaadin.external.google:android-json provide a org.json.JSONException. The first library has one extending RuntimeException while the latter provides a checked Exception.

The only solution I can think of is to exclude one of the two libraries in your dependency tree.

MatKuhr
  • 505
  • 4
  • 13