11

我是休息网络服务的新手。

http://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/中选择示例

在点击 URL http://localhost:8080/RESTfulExample/rest/hello/mkyong 时,我收到了这个奇怪的错误:

在此处输入图像描述

详情如下:

PLATFORM VERSION INFO
    Windows             : 6.1.7601.65536 (Win32NT)
    Common Language Runtime     : 4.0.30319.1022
    System.Deployment.dll       : 4.0.30319.1 (RTMRel.030319-0100)
    clr.dll             : 4.0.30319.1022 (RTMGDR.030319-1000)
    dfdll.dll           : 4.0.30319.1 (RTMRel.030319-0100)
    dfshim.dll          : 4.0.31106.0 (Main.031106-0000)

SOURCES
    Deployment url          : http://localhost:8080/rs1/rest/hello/hi,

ERROR SUMMARY
    Below is a summary of the errors, details of these errors are listed later in the log.
    * Activation of http://localhost:8080/rs1/rest/hello/hi, resulted in exception. Following failure messages were detected:
        + Exception reading manifest from http://localhost:8080/rs1/rest/hello/hi,: the manifest may not be valid or the file could not be opened.
        + Data at the root level is invalid. Line 1, position 1.

COMPONENT STORE TRANSACTION FAILURE SUMMARY
    No transaction error was detected.

WARNINGS
    There were no warnings during this operation.

OPERATION PROGRESS STATUS
    * [9/16/2014 11:30:26 AM] : Activation of `http://localhost:8080/rs1/rest/hello/hi`, has started.

ERROR DETAILS
    Following errors were detected during this operation.
    * [9/16/2014 11:30:26 AM] System.Deployment.Application.InvalidDeploymentException (ManifestParse)
        - Exception reading manifest from http://localhost:8080/rs1/rest/hello/hi,: the manifest may not be valid or the file could not be opened.
        - Source: System.Deployment
        - Stack trace:
            at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
            at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
            at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options)
            at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
            at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)
        --- Inner Exception ---
        System.Xml.XmlException
        - Data at the root level is invalid. Line 1, position 1.
        - Source: System.Xml
        - Stack trace:
            at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
            at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
            at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
            at System.Deployment.Application.ManifestValidatingReader.XmlFilteredReader.Read()
            at System.Xml.XmlCharCheckingReader.Read()
            at System.Xml.XsdValidatingReader.Read()
            at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)

COMPONENT STORE TRANSACTION DETAILS
    No transaction information is available.

我正在使用 eclipse 开普勒和 apache tomcat 6

4

5 回答 5

15

我也在用 IE 遇到这个问题。我正在使用 Tomcat 8,带有 LDAP 安全约束的 REST jersey,它将用户引导到登录页面。登录页面显示正常,但经过身份验证后,此错误仍然存​​在。我们的用户群主要是 IE 用户,因此使用 Chrome、firefox 等并不是一个真正的选择(尽管该网站在他们身上按预期工作)。

请注意,将站点添加到 IE 中的“受信任的站点”可以解决问题。

稍微挖掘一下日志文件,就好像 IE 正在尝试启动一个应用程序 (ClickOnce) 并期待一个清单文件。由于我们的网站上没有应用程序,这令人费解并且可能具有误导性。对此的任何帮助将不胜感激。

更新:我设法解决了这个问题。在查看了我的域类之后,我突然想到我没有为响应指定 MIME 类型。向我的域(rest)类方法添加 @Produces("text/html") 注释解决了这个问题:

例子:

@GET
@Produces("text/html")
public Response welcome()
{
return Response.ok("This should now work in IE").build();
}

我猜如果 IE 没有在响应标头中专门获取此 mimetype,它假定您正在尝试交付应用程序 (ClickOnce)。我希望 IE 更像 Chrome 或 Firefox。

于 2014-12-17T18:49:16.780 回答
3

我有同样的问题。如果您使用其他浏览器,如 Chrome 或 IE,它会工作

于 2014-10-15T05:01:42.513 回答
1

如果您在使用Spring MVC时遇到此问题,则可以通过在 @RequestMapping 注释中添加 producer = mime 类型来解决此问题。结果将与此类似:

...
@RequestMapping(value = "/mapping-address", produces = "text/html;charset=UTF-8")
...

当我使用 @ResponseBody 注释注释一个返回字符串的方法时,我遇到了这个问题。

于 2018-06-27T21:47:38.443 回答
1

我知道我可能迟到了。虽然我是初学者,但我想分享我解决这个问题的方法。所以,我遇到了同样的错误,但我通过以下步骤解决了它:

  1. 打开您的网络浏览器(即我使用的是 Chrome)
  2. 打开apache tomcat的主屏幕

http://localhost :{port} (在 Eclipse 中默认为端口:8080)

  1. 打开“管理器应用程序”。就我而言,我需要修改位于 apache 路径安装中的tomcat-user.xml文件。(因此,您将获得管理员许可)
  2. 当您打开 de Manager App 时,您将连续看到您的 /RESTfulExample。检查它是否正在运行
  3. 最后,在您的网络浏览器中写入

    http://localhost:8080/RESTfulExample/rest/hello/hello%20world

  4. 你会看到

    泽西说:你好世界

我希望你能想到另一个解决方案

于 2015-08-02T22:14:51.060 回答
0

我有同样的问题,这不是答案,只是为了给问题添加更多信息。只有当我的 IE 11 处于该域/url 的兼容模式时,我才会得到它。

如果我关闭兼容模式,响应将按照您的预期进行解释。

于 2016-10-03T13:58:57.143 回答