【问题标题】:Undertow request failed HttpServerExchange error loading web pageUndertow 请求失败 HttpServerExchange 错误加载网页
【发布时间】:2018-03-03 02:39:52
【问题描述】:

我正在尝试通过 Maven 和 IntellijIDEA 创建一个 Web 应用程序,它将使用 EJB 和 CDI 在 PostgreSQL 数据库中写入数据。 我的问题是 - 我什至无法启动,因为我的应用程序没有加载 JSF 页面。 我的 pom.xml 中有一个依赖项:

<name>webapp</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

我的 index.xhtml 看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
    WEBAPP
</h:head>
<h:body>
    <h:form>
    <h:commandButton value="Add Entity"/>
    </h:form>
</h:body>
</html>

但是当我尝试加载 localhost:8080/webapp-1.0-SNAPSHOT/index.xhtml 时出现错误:

  00:17:10,782 ERROR [io.undertow.request] (default task-18) UT005071: Undertow request failed HttpServerExchange{ GET /webapp-1.0-SNAPSHOT/index.xhtml request {Connection=[keep-alive], Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8], Accept-Language=[ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4], Cache-Control=[max-age=0], Accept-Encoding=[gzip, deflate, br], User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36 OPR/47.0.2631.80], Upgrade-Insecure-Requests=[1], Host=[localhost:8080]} response {Connection=[keep-alive], X-Powered-By=[Undertow/1], Server=[WildFly/11], Content-Type=[text/html;charset=UTF-8], Content-Length=[639], Date=[Thu, 21 Sep 2017 21:17:10 GMT]}}: java.lang.IllegalArgumentException: UT000173: An invalid control character [1087] was present in the cookie value or attribute
    at io.undertow.util.LegacyCookieSupport.isHttpSeparator(LegacyCookieSupport.java:142)
    at io.undertow.util.LegacyCookieSupport.isHttpToken(LegacyCookieSupport.java:163)
    at io.undertow.util.LegacyCookieSupport.adjustedCookieVersion(LegacyCookieSupport.java:248)
    at io.undertow.server.Connectors.getCookieString(Connectors.java:154)
    at io.undertow.server.Connectors.flattenCookies(Connectors.java:99)
    at io.undertow.server.protocol.http.HttpResponseConduit.processWrite(HttpResponseConduit.java:161)
    at io.undertow.server.protocol.http.HttpResponseConduit.write(HttpResponseConduit.java:596)
    at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.write(AbstractFixedLengthStreamSinkConduit.java:106)
    at org.xnio.conduits.Conduits.writeFinalBasic(Conduits.java:132)
    at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.writeFinal(AbstractFixedLengthStreamSinkConduit.java:175)
    at org.xnio.conduits.ConduitStreamSinkChannel.writeFinal(ConduitStreamSinkChannel.java:104)
    at io.undertow.channels.DetachableStreamSinkChannel.writeFinal(DetachableStreamSinkChannel.java:195)
    at io.undertow.server.HttpServerExchange$WriteDispatchChannel.writeFinal(HttpServerExchange.java:2042)
    at io.undertow.servlet.spec.ServletOutputStreamImpl.writeBufferBlocking(ServletOutputStreamImpl.java:568)
    at io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:603)
    at io.undertow.servlet.spec.ServletPrintWriter.close(ServletPrintWriter.java:117)
    at io.undertow.servlet.spec.ServletPrintWriterDelegate.close(ServletPrintWriterDelegate.java:81)
    at io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:473)
    at io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:568)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:339)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

00:17:11,088 ERROR [io.undertow.request] (default task-19) UT005071: Undertow request failed HttpServerExchange{ GET /webapp-1.0-SNAPSHOT/index.xhtml request {Connection=[keep-alive], Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8], Accept-Language=[ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4], Cache-Control=[max-age=0], Accept-Encoding=[gzip, deflate, br], User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36 OPR/47.0.2631.80], Upgrade-Insecure-Requests=[1], Host=[localhost:8080]} response {Connection=[keep-alive], X-Powered-By=[Undertow/1], Server=[WildFly/11], Content-Type=[text/html;charset=UTF-8], Content-Length=[638], Date=[Thu, 21 Sep 2017 21:17:11 GMT]}}: java.lang.IllegalArgumentException: UT000173: An invalid control character [1087] was present in the cookie value or attribute
    at io.undertow.util.LegacyCookieSupport.isHttpSeparator(LegacyCookieSupport.java:142)
    at io.undertow.util.LegacyCookieSupport.isHttpToken(LegacyCookieSupport.java:163)
    at io.undertow.util.LegacyCookieSupport.adjustedCookieVersion(LegacyCookieSupport.java:248)
    at io.undertow.server.Connectors.getCookieString(Connectors.java:154)
    at io.undertow.server.Connectors.flattenCookies(Connectors.java:99)
    at io.undertow.server.protocol.http.HttpResponseConduit.processWrite(HttpResponseConduit.java:161)
    at io.undertow.server.protocol.http.HttpResponseConduit.write(HttpResponseConduit.java:596)
    at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.write(AbstractFixedLengthStreamSinkConduit.java:106)
    at org.xnio.conduits.Conduits.writeFinalBasic(Conduits.java:132)
    at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.writeFinal(AbstractFixedLengthStreamSinkConduit.java:175)
    at org.xnio.conduits.ConduitStreamSinkChannel.writeFinal(ConduitStreamSinkChannel.java:104)
    at io.undertow.channels.DetachableStreamSinkChannel.writeFinal(DetachableStreamSinkChannel.java:195)
    at io.undertow.server.HttpServerExchange$WriteDispatchChannel.writeFinal(HttpServerExchange.java:2042)
    at io.undertow.servlet.spec.ServletOutputStreamImpl.writeBufferBlocking(ServletOutputStreamImpl.java:568)
    at io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:603)
    at io.undertow.servlet.spec.ServletPrintWriter.close(ServletPrintWriter.java:117)
    at io.undertow.servlet.spec.ServletPrintWriterDelegate.close(ServletPrintWriterDelegate.java:81)
    at io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:473)
    at io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:568)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:339)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

我使用 JBoss(现在是 WildFly)作为应用服务器。

MyCDI.class:

import javax.ejb.EJB;
import javax.faces.bean.SessionScoped;
import javax.inject.Named;

@Named
@SessionScoped
public class MyCDI {

    @EJB
    MyEJB myEJB;

    public void createEntity(){
        myEJB.createEntity();
    }

}

MyEJB.class:

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceUnit;


@Stateless
@LocalBean
public class MyEJB {

    @PersistenceUnit(unitName = "examplePU")
    public EntityManager entityManager;


    public MyEntity createEntity(){
        MyEntity myEntity = new MyEntity();
        myEntity.setName("EntityName");
        entityManager.persist(myEntity);

        return myEntity;
    }
}

MyEntity.class:

import javax.inject.Named;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class MyEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public int id;
    public String name;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

【问题讨论】:

  • 在(不完整的?)堆栈跟踪中没有任何 JSF、没有 maven、没有与 postgress 相关的内容。这只是野蝇的东西。您的“标签”中缺少该标签。我为你更正了。您的 “JSF 页面未加载” 是您的最终用户体验问题(没有 'jsf' 部分)。您的开发人员问题在堆栈跟踪中。我为你纠正了这一切
  • 尝试清除浏览器中的 cookie。那里有一个坏字符串(An invalid control character [1087] was present in the cookie value or attribute
  • 好吧,我从浏览器清除了缓存、cookies(等等)仍然遇到同样的问题(顺便说一句,我在所有浏览器中都有同样的问题)。不幸的是,我添加了完整的堆栈跟踪(或者我认为是这样)这对我来说没什么意义。
  • 您在创建 cookie 吗?看起来它正在查看带有 п 字符的值或属性。我确实看到语言设置为ru-RU,ru;。 AIUI 的 value 属性需要是 US-ASCII,例如32-127.
  • @James 在这一点上,我没有手动创建任何 cookie。我将所有课程都添加到问题中。而且我没有在我的代码中使用任何俄语字符(至少我没有看到它们:))。如果您指定如何将该值更改为 US-ASCII,那就太好了。(我应该将所有编码值替换为ASCII ?)

标签: wildfly


【解决方案1】:

我们今天遇到了类似的问题,发现变音符号 (äöü) 导致了 UT000173 问题。在我们的例子中,我们尝试在 cookie 中记住用户的用户名。通过避免这种情况,我们可以解决它。

我们最近通过从 JBoss EAP v7.0.7 更新到 v7.0.9 引入了这个问题。

【讨论】:

    【解决方案2】:

    如果您使用spring boot和服务器tomcat:在代理网关上打开8080端口(可以直接调用)。 您应该使用私有端口 8080

    【讨论】:

    • 这个答案令人困惑,我不确定它是否解决了问题
    【解决方案3】:

    这周我遇到了同样的问题,但 4 天都无法解决。最后,我发现您的 Windows PC 名称中的西里尔符号可能是导致此问题的原因。

    【讨论】:

      猜你喜欢
      • 2020-04-16
      • 1970-01-01
      • 2017-12-27
      • 2020-04-09
      • 2017-05-13
      • 1970-01-01
      • 2018-01-09
      • 1970-01-01
      • 2018-11-04
      相关资源
      最近更新 更多