0

I am trying to use the method PUT for a REST service and I got an error:

curl -v -H "Content-Type: application/xml" -X PUT --data-binary "@putUsers.xml" http://localhost:8080/RestDB/webresources/User/5

The response is:
Trying ::1... 
* Connected to localhost (::1) port 8080 (#0) 
> PUT /RestDB/webresources/User/5 HTTP/1.1 
> Host: localhost:8080 
> User-Agent: curl/7.46.0 
> Accept: */* 
> Content-Type: application/xml 
> Content-Length: 409 
> 
* upload completely sent off: 409 out of 409 bytes 
< HTTP/1.1 400 Bad Request 
< Server: GlassFish Server Open Source Edition  4.1.1 
< X-Powered-By: Servlet/3.1 JSP/2.3 (GlassFish Server Open Source Edition  4.1.1  Java/Oracle Corporation/1.8) 
< Content-Language: 
< Content-Type: text/html 
< Date: Thu, 03 Aug 2017 09:55:13 GMT 
< Connection: close 
< Content-Length: 1109 
< 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>GlassFish Server Open Source Edition  4.1.1  - Error report</title><style type="text/css"><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 400 - Bad Request</h1><hr/><p><b>type</b> Status report</p><p><b>message</b>Bad Request</p><p><b>description</b>The request sent by the client was syntactically incorrect.</p><hr/><h3>GlassFish Server Open Source Edition  4.1.1 </h3></body></html>* Closing connection 0 

Server log:

Exception while deploying the app [RestDB] : Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only 0 bytes. The connection has been terminated. Error Code: 0

I am trying to do update in the database.

Thanks a lot!

  • HTTP Status 500 - Internal Server Error javax.transaction.RollbackException: Transaction marked for rollback. root cause javax.validation.ConstraintViolationException: Bean Validation constraint(s) violated while executing Automatic Bean Validation on callback event:'preUpdate'. Please refer to embedded ConstraintViolations for details. –  Aug 03 '17 at 10:28

1 Answers1

1

You are mixing to much things, please focus yourself and ask a proper question.

Obviously your app is not even deployed, so you don't need to try to send requests with curl, this cannot work.

Fix your problems step by step (if needed, ask several specific questions), the first step should be to deploy the application properly.

unwichtich
  • 13,712
  • 4
  • 53
  • 66
  • My application was deployed. I resolved. I don't know when I use PUT how it should be XML file. –  Aug 04 '17 at 13:35