0

我使用了 open-liberty 19.0.0.6 。但是这个应用程序服务器不能在 docker container 上使用 ssl 端口(https)。

收到这个 nullPointerException :

java.lang.NullPointerException
    at com.ibm.ws.http.channel.h2internal.hpack.H2HeaderTable.getHeaderEntry(H2HeaderTable.java:41)
    at com.ibm.ws.http.channel.h2internal.hpack.H2Headers.encodeHeader(H2Headers.java:353)
    at com.ibm.ws.http.channel.h2internal.hpack.H2Headers.encodeHeader(H2Headers.java:320)
    at com.ibm.ws.http.channel.internal.HttpRequestMessageImpl.pushNewRequest(HttpRequestMessageImpl.java:2066)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpRequestImpl.pushNewRequest(HttpRequestImpl.java:214)
    at com.ibm.ws.webcontainer40.srt.http.HttpPushBuilder.push(HttpPushBuilder.java:289)
    at org.apache.myfaces.context.servlet.ServletExternalContextImpl.pushResource(ServletExternalContextImpl.java:434)
    at org.apache.myfaces.context.servlet.ServletExternalContextImpl.encodeResourceURL(ServletExternalContextImpl.java:381)
    at javax.faces.context.ExternalContextWrapper.encodeResourceURL(ExternalContextWrapper.java:110)
    at org.apache.myfaces.renderkit.html.HtmlStylesheetRenderer.encodeEnd(HtmlStylesheetRenderer.java:232)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:675)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:555)
    at org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:106)
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:597)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:527)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:551)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1897)
    at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:315)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:73)
    at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:117)
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:266)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:206)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1255)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:743)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:440)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:182)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:93)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:201)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:90)
    at com.ibm.ws.security.jaspi.JaspiServletFilter.doFilter(JaspiServletFilter.java:56)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:201)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:90)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:996)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1134)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4975)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:314)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1007)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:279)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1061)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:417)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:376)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:532)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:466)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:331)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:302)
    at com.ibm.ws.http.channel.h2internal.H2StreamProcessor$Http2Ready.run(H2StreamProcessor.java:1597)
    at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:239)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.lang.Thread.run(Thread.java:818)       

这是我的 server.xml :

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
    <featureManager>
        <feature>javaee-8.0</feature>
        <feature>localConnector-1.0</feature>
        <feature>appSecurity-3.0</feature>
    </featureManager>
    <library id="MySQLLib">
        <fileset dir="${shared.resource.dir}/mysql" includes="*.jar" />
    </library>
    <dataSource jndiName="JTA-Connection" transactional="true">
        <jdbcDriver libraryRef="MySQLLib" />
        <properties databaseName="${database.name}"
                    serverName="${database.hostname}"
                    portNumber="${database.port}"
                    user="${database.username}"
                    password="${database.password}" />
    </dataSource>
    <basicRegistry id="basic" realm="BasicRealm" />
    <httpSession securityIntegrationEnabled="false" />
    <httpEndpoint id="defaultHttpEndpoint"
                  httpPort="8080"
                  httpsPort="9443"
                  host="0.0.0.0"
                  protocolVersion="http/2">
        <httpOptions http2="enabled" />
    </httpEndpoint>
    <webContainer disableXPoweredBy="true" />
    <applicationManager autoExpand="true" />
    <applicationMonitor updateTrigger="mbean" />
    <logging consoleLogLevel="ERROR" />
</server>      

这是我的 bootstrap.properties 文件:

### Server Configuration ###
default.http.port=8080
default.https.port=9443
default.hostname=localhost

### Database Configuration ###
database.name=logmug
database.hostname=mysql.docker.io
database.port=3306
database.username=root
database.password=rootpass

注意:我的应用程序在 http(端口 80)连接上工作没有任何问题,只有 https(端口 443)有这个问题。
注意:此问题仅在 docker 容器上解决,我在本地机器(外部容器)上测试我的应用程序,所有端口都可以正常工作。

这是应用服务器空指针异常

4

1 回答 1

0

据我所知,发生这种 NPE 是因为没有任何值集的 HTTP 标头被传递到 PushBuilder。鉴于堆栈,错误的标头似乎源自 Open Liberty 的 Servlet 4 实现。我已经打开了一个问题来跟踪这个 - 你可以添加你的反馈吗?https://github.com/OpenLiberty/open-liberty/issues/8474

至于为什么您的应用程序在本地工作,我会检查以验证 HTTP/2 是否实际在使用中。如果您使用的是 Java 8,则需要特定环境才能通过 ALPN 在 SSL 上运行 HTTP/2 - 请参阅https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp .doc/ae/cwlp_alpnsupport.html

于 2019-08-05T15:35:26.510 回答