0

While I am trying to deploy a new application into the domain using BW Agent REST API, it requires the ear file to be uploaded first. when I am trying to upload an .ear file generated, but this POST call is failing with HTTP 415 error. This REST API is trying to POST an EAR file for which something is wrong about the headers.

http://localhost:8079/bw/v1/domains/MYDOMAIN/archives?replace=true

Content-type=application/octet-stream

the error in the bwagent log file is

2019-04-01 10:10:37.732 WARN [qtp2022768790-59] o.g.jersey.servlet.WebComponent - A servlet request to the URI http://localhost:8079/bw/v1/domains/Test/archives?file=file%3AC%3A%5CUsers%5Ceilmmpw%5CDocuments%5CProcess.Stub.application_1.0.0.ear contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.

I tried with Content-Type=multipart/form-data and attaching the ear file, but it failed with HTTP 500 error with errors in the agent log file

2019-04-09 10:18:50.819 WARN [qtp1124804249-81] o.e.jetty.servlet.ServletHandler - javax.servlet.ServletException: java.lang.NullPointerException at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:485) ~[jersey-container-servlet-core-2.21.1.jar:na]

Imrankhan
  • 31
  • 5
  • What kind of error message does the BWAgent give you in the log files? Also, could you add a bit on what you're trying to do (like deploy a new application or upgrade my app to a new version)? – retgits Apr 01 '19 at 16:03
  • edited with the objective and error details – Imrankhan Apr 02 '19 at 11:50

1 Answers1

0

It's been a while since I last used the REST API directly to deploy apps (using the bwadmin cli tool is a much easier way and works across most platforms and CI/CD tools), but I'm not too sure that Content-type=application/octet-stream is the proper content type.

The error message you're seeing comes from the Jersey server and means that you're sending data to an endpoint that expects Form data (Content-Type=multipart/form-data). What you could try to see the proper invocation is:

  • Start the bwagent with the apiserver command (bwserver apiserver)
  • Open a browser and go to http://<hostname>:5555 (unless you set the bw.agent.http.host property to a different number)

This will open the Swagger documentation for the BWAgent and allow you to try the call from there. Using that, it will display both the actual command that is executed, including the HTTP header parameters that need to be set.

retgits
  • 1,323
  • 1
  • 9
  • 14
  • I tried with Content-type=multipart/form-data in Postman looking at the https://stackoverflow.com/questions/16015548/tool-for-sending-multipart-form-data-request, but it also did not work. BWAgent throwed null pointer exception.I am exploring HTTP API than bwadmin CLI as HTTP API commands can be ran from any machine where as bwadmin has to run where BWAgent running – Imrankhan Apr 04 '19 at 12:39
  • uploading archive file is working with below CURL command curl -X POST --form file=@/c/tmp/Process.Sample.application_1.0.0.ear http://localhost:8079/bw/v1/domains/testDom/archives?replace=true with this,I was able to automate complete deployment process of 1.Stop the existing application 2.Upload the new archive 3.Un-deploy if there is an existing application 4.deploy new application with uploaded ear – Imrankhan May 03 '19 at 07:26