【发布时间】:2025-12-15 19:55:02
【问题描述】:
我正在尝试将方法 PUT 用于 REST 服务,但出现错误:
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
服务器日志:
部署应用程序时出现异常 [RestDB]:异常 [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258):org.eclipse.persistence.exceptions.DatabaseException 内部异常:java.sql.SQLException:分配连接时出错。原因:无法分配连接,因为:从网络读取数据时数据不足 - 预计至少需要 6 个字节,但仅接收到 0 个字节。连接已终止。 错误代码:0
我正在尝试在数据库中进行更新。
非常感谢!
【问题讨论】:
-
HTTP 状态 500 - 内部服务器错误 javax.transaction.RollbackException:事务标记为回滚。根本原因 javax.validation.ConstraintViolationException:在回调事件上执行自动 Bean 验证时违反了 Bean 验证约束:'preUpdate'。有关详细信息,请参阅嵌入式 ConstraintViolations。
标签: rest curl derby glassfish-4