使用ClientResponse发布时,Jersey客户端MessageBodyProviderNotFoundException(Jersey client MessageBodyProviderNotFoundException when posting using ClientResponse)
我正尝试使用Jersey客户端来调用REST服务(不使用Jersey / JAX-RS)。 以下代码正常工作以发布我的表单数据并收到回复:
Form form = new Form(); form.param("email", email); form.param("password", password); String clientResponse = target.request(MediaType.TEXT_PLAIN) .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), String.class);
代码运行良好,clientResponse变量包含来自服务器的纯文本响应。
现在,我需要检查服务器返回的状态码。 据我的理解,我需要检索作为ClientResponse对象而不是字符串的响应。 所以,我将我的代码更改为:
Form form = new Form(); form.param("email", email); form.param("password", password); ClientResponse clientResponse = target.request(MediaType.TEXT_PLAIN) .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), ClientResponse.class);
当我运行这个新代码时,我得到以下异常:
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException:未找到媒体类型= text / plain,type = class org.glassfish.jersey.client.Client.ClientResponse,genericType = class org.glassfish.jersey.client.ClientResponse的MessageBodyReader。
为什么我得到这个异常?
I am trying to use the Jersey client to call a REST service (which doesn't use Jersey / JAX-RS). The following code works fine to POST my form data and receive a response:
Form form = new Form(); form.param("email", email); form.param("password", password); String clientResponse = target.request(MediaType.TEXT_PLAIN) .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), String.class);
The code runs fine and the clientResponse variable contains the plain text response from the server.
Now, I need to inspect the status code returned by the server. To my understanding, I need to retrieve the response as a ClientResponse object instead of a String. So, I changed my code to:
Form form = new Form(); form.param("email", email); form.param("password", password); ClientResponse clientResponse = target.request(MediaType.TEXT_PLAIN) .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), ClientResponse.class);
When I run this new code, I get the following exception:
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=text/plain, type=class org.glassfish.jersey.client.ClientResponse, genericType=class org.glassfish.jersey.client.ClientResponse.
Why am I getting this exception?
原文:https://stackoverflow.com/questions/48054073
最满意答案
你可以验证A)你确实可以ssh到服务器,B)存储库是否完全在指定的路径?
您可以使用ssh username @ host ls / home / shared / g_quoll / repos /并查看是否有itko-ext.git目录。
Can you verify that that A) you indeed can ssh into the server, and B) that the repository is exactly at the path specified?
You can do ssh username@host ls /home/shared/g_quoll/repos/ and see if there is a itko-ext.git directory there.
相关问答
更多-
GIT扩展 - 推 - “致命:远程端意外挂断”(GIT Extensions - Push - “fatal: The remote end hung up unexpectedly”)[2022-07-01]
我有同样的问题。 我通过进入Git Extensions中的设置 - >设置来修复它。 然后,我单击了SSH选项卡,并在“指定要使用的SSH客户端”中选择了openSSH。 我原本把它设置为PuTTY。 I had this same problem. I fixed it by going into the Settings -> Settings in Git Extensions. I then clicked on the SSH tab and selected openSSH in the "S ... -
快速解决方案 有了这样的错误,我通常会通过以下方式提高postBuffer大小: git config --global http.postBuffer 524288000 (以下报告中的一些评论必须使该值翻倍): git config --global http.postBuffer 1048576000 更多信息: 从git config手册页 , http.postBuffer是关于: 当向远程系统发送数据时,智能HTTP传输使用的缓冲区的最大大小(以字节为单位)。 对于大于此缓冲区大小的请求,使 ...
-
git克隆超过ssh错误'致命:远程端意外挂断'(git clone over ssh error 'fatal: The remote end hung up unexpectedly')[2023-07-14]
你可以验证A)你确实可以ssh到服务器,B)存储库是否完全在指定的路径? 您可以使用ssh username @ host ls / home / shared / g_quoll / repos /并查看是否有itko-ext.git目录。 Can you verify that that A) you indeed can ssh into the server, and B) that the repository is exactly at the path specified? You can d ... -
如果您克隆到具有用户权限的目录(/ home / user / git),它将正常工作。 Checked almost every option posted here .. but what I found useful is backing up database from cpanel and files from file manager and then restoring it .
-
Git远程端意外挂断了(Git remote end hung up unexpectedly)[2022-05-18]
问题可能是由许多问题引起的: Git安装在服务器上一些奇怪的地方,“git”用户以交互方式登录时获取的环境(您通过PuTTY或其他方式手动执行此操作)与非交互式登录时获得的环境不同( git客户端为你做这个)。 这是因为在这些情况下Unix shell会读取不同的启动文件,当git使用SSH生成远程git实例时,它仍会生成服务器上的默认shell(对于用户而言)。 你有一个本地问题(比如,你配置Git使用plink.exe访问服务器,它要求你通过输入“y”或“n”(你不能这样做)接受主机的密钥。 无论如何, ... -
git clone导致:“致命:远程端意外挂断”(git clone results in: “fatal: The remote end hung up unexpectedly”)[2022-03-17]
试试这些: git clone user@host:/path/to/repository/project_name.git git clone ssh://user@host/path/to/repository/project_name.git Try these: git clone user@host:/path/to/repository/project_name.git git clone ssh://user@host/path/to/repository/project_name.git -
你应该做的是: git clone git://android.git.kernel.org/platform/packages/apps/Browser.git 产出 : Cloning into Browser... remote: Counting objects: 10361, done. remote: Compressing objects: 100% (2394/2394), done. remote: Total 10361 (delta 5024), reused 10254 (delt ...
-
致命:远程端通过连接到GitHub意外挂断(fatal: The remote end hung up unexpectedly by connectiong to GitHub)[2023-11-29]
当GitHub正确记录您的公共ssh密钥时,弹出该错误消息的唯一实例是 你试图用错误的案例或不正确的ssh url克隆一个repo。 它应该是: git clone git@github.com:user/repo.git 您尝试克隆您没有写访问权限(公共存储库)或任何访问权限(私人存储库)的存储库。 从GitHub页面“ 我应该使用哪个远程URL? ” 要使用这些URL, 您必须具有对公共存储库的写访问权限或对私有存储库的任何访问权限 。 这些URL不适用于您没有写入权限的公共仓库。 私钥受密码保护,您的 ... -
这意味着负责收听请求的http服务器(这里是一个git push over http)无法完成。 要么是因为服务器上的问题: 只有所述http服务器的日志包含根本原因(例如,它可能是服务器处理过大的消息,或者是正确的问题,或者......)。 这些日志可以在etc/httpd/httpd.conf (Apache)或/var/log/nginx/error.log )中,甚至可以在gitlab中。 或者因为它从未收到过请求, OP jesktop在此确认如下: 我找到了所有日志,但错误日志是空的。 问题是网 ...
-
事实证明我太仓促了,这是我现在收到的错误信息(发布后约5分钟): ERROR: Storage server temporarily offline. See http://status.github.com for GitHub system status. status.github.com报道: 21:36 UTC We are investigating issues with a single fileserver cluster. A small number of repositories m ...