Hi Sebastian,
Thanks. I assume this is a bug (or at least a fishy implementation) in Camunda that had been ignored by previous versions of BaseX:
If you use HTTP requests with authentication, two requests will be sent to the server by default:
1. In the first run (in the Challenge), the client will ask the server for the authentication method. 2. In the second run, the client will send the authorization data (user name, password) and all other data.
If I interpret the stack trace correctly, Camunda seems to do some more things in the first step than expected, although the client has not been authorized yet. The NullPointerException in the stack trace …
2022-05-03 13:15:48.707 WARN 27932 --- [nio-8080-exec-3] org.camunda.bpm.engine.rest.exception : ENGINE-REST-HTTP500 java.lang.NullPointerException at org.camunda.bpm.engine.rest.impl.DeploymentRestServiceImpl.extractDeploymentInformation(DeploymentRestServiceImpl.java:123) at org.camunda.bpm.engine.rest.impl.DeploymentRestServiceImpl.createDeployment(DeploymentRestServiceImpl.java:96) at org.camunda.bpm.engine.rest.impl.DeploymentRestServiceImpl.createDeployment(DeploymentRestServiceImpl.java:46)
… seems to be re-interpreted, as a 415 status code will be returned, indicating that the media type (that has simply not been supplied by the challenging request) is not supported. As far as I know, the Content-Type header must only be sent to the server along with the actual payload.
It would be interesting to hear how the Camunda guys comment this NPE. Do you think you could get in contact with them? Maybe I can find a fallback solution in BaseX, but I would be cleaner to see this fixed in the project that causes the original exception.
The error can be circumvented by supplying a send-authorization='true' attribute [1]. This way, only one request will be sent to the server, including the credentials..
Best Christian
[1] http://expath.org/spec/http-client#d2e430
On Mon, May 2, 2022 at 4:52 PM Wiemer, Sebastian Sebastian.Wiemer@adesso.de wrote:
Hi Christian, to recreate the difference:
- download camunda BPMN engine (https://camunda.com/download/) for your
platform
- unzip (it will create the folder "camunda")
- enter directory "camunda" and start "start.bat" or "start.sh" with no
parameters
- wait for camunda to start
- execute the xquery code below in 9.6.4 and 9.7.1
best regards and どういたしまして!
Sebastian
Example code: http:send-request( <http:request method="post" timeout="10" href="http://localhost:8080/engine-rest/deployment/create" username="demo" password="demo"> <http:multipart media-type='multipart/form-data'> <http:header name='accept' value="application/json"/> <http:header name='Content-Type' value="multipart/form-data"/> <http:header name='content-disposition' value="form-data; name='data'; filename='test.bpmn'">{file:read-text("test.bpmn")=>parse-xml()}</http:header> <http:body media-type='multipart/form-data'></http:body> </http:multipart> </http:request>)
Version 9.6.4 result: <http:response xmlns:http="http://expath.org/ns/http-client" status="200" message=""> <http:header name="Keep-Alive" value="timeout=60"/> <http:header name="Access-Control-Allow-Origin" value="*"/> <http:header name="Connection" value="keep-alive"/> <http:header name="Content-Length" value="413"/> <http:header name="Date" value="Mon, 02 May 2022 13:51:36 GMT"/> <http:header name="Content-Type" value="application/json"/> <http:body media-type="application/json"/> </http:response>
<json type="object"> <links type="array"> <_ type="object"> <method>GET</method> <href> http://localhost:8080/engine-rest/deployment/fbd9b0d2-ca1e-11ec-adec-c2a34077f81f </href> <rel>self</rel> </_> </links> <id>fbd9b0d2-ca1e-11ec-adec-c2a34077f81f</id> <name type="null"/> <source type="null"/> <deploymentTime>2022-05-02T15:51:36.482+0200</deploymentTime> <tenantId type="null"/> <deployedProcessDefinitions type="null"/> <deployedCaseDefinitions type="null"/> <deployedDecisionDefinitions type="null"/> <deployedDecisionRequirementsDefinitions type="null"/> </json>
Version 9.7.1 result: <http:response xmlns:http="http://expath.org/ns/http-client" status="415" message=""> <http:header name="Keep-Alive" value="timeout=60"/> <http:header name="Access-Control-Allow-Origin" value="*"/> <http:header name="Connection" value="keep-alive"/> <http:header name="Content-Length" value="76"/> <http:header name="Date" value="Mon, 02 May 2022 13:54:48 GMT"/> <http:header name="Content-Type" value="application/json"/> <http:body media-type="application/json"/> </http:response>
<json type="object"> <type>NotSupportedException</type> <message>HTTP 415 Unsupported Media Type</message> </json>
*Von:* Christian Grün christian.gruen@gmail.com *Gesendet:* Montag, 2. Mai 2022 09:41 *An:* Wiemer, Sebastian Sebastian.Wiemer@adesso.de *Cc:* basex-talk@mailman.uni-konstanz.de < basex-talk@mailman.uni-konstanz.de> *Betreff:* Re: [basex-announce] BaseX 9.7.1: Tweaks, Fixes, Features
Hi Sebastian,
Thanks for your feedback. Could you provide us with a little self-contained example to reproduce the issue?
どうもありがとう, Christian
On Mon, May 2, 2022 at 8:00 AM Wiemer, Sebastian < Sebastian.Wiemer@adesso.de> wrote:
Hi, thank you for your continuing effort to make BaseX better! I eagerly await every new version 🙂
While trying out BaseX 9.7.1, i experienced a different behavior than in BaseX 9.6.4
A POST request sent to any camunda bpm-engine rest endpoint (http:send-request(...) with a POST method) works fine with 9.6.4 but yields a "wrong media-type" 415 error with 9.7.1 The media-type is "multipart/formdata"
I tried changing the media-type of the request, the body, the form fields, ... but always got the 415 error.
Did something change between 9.6.4 and 9.7.1? Is there a new way to set the media-type?
Best regards, Sebastian
*Von:* BaseX-Announce basex-announce-bounces@mailman.uni-konstanz.de im Auftrag von Christian Grün christian.gruen@gmail.com *Gesendet:* Dienstag, 26. April 2022 11:17 *An:* BaseX basex-talk@mailman.uni-konstanz.de; BaseX < basex-announce@mailman.uni-konstanz.de> *Betreff:* [basex-announce] BaseX 9.7.1: Tweaks, Fixes, Features
Dear all,
We provide you with a new version of BaseX, our open source XML framework, database system and XQuery 3.1 processor. Apart from performance tweaks and bug fixes, it comes with the following enhancements [1,2]:
• Backups: support for comments added • RESTXQ: improved caching for unmodified modules • GUI, editor: list opened files (Ctrl-F6) • GUI: improved support for middle mouse button • XQuery: inspect:functions: parse modules only once • XQuery: db:delete: Faster deletion of binary resources • XQuery: jobs:eval: handling of large job numbers revised • XQuery optimizations: rewrite value to general comparisons
All the best to everyone, Christian
[1] https://basex.org/2022/04/26/basex-9.7.1/ [2] https://github.com/BaseXdb/basex/commits/master
https://www.new-school-of-it.com/?pk_campaign=new_school_of_it&pk_source=email&pk_medium=banner&pk_content=new_school_of_it
>>> business. people. technology. <<<
adesso SE mit Sitz in Dortmund Vorstand: Michael Kenfenheuer (Vors.), Dirk Pothen, Andreas Prenneis, Stefan Riedel, Jörg Schroeder, Torsten Wegener Vorsitzender des Aufsichtsrates: Prof. Dr. Volker Gruhn Amtsgericht Dortmund HRB 20663