在GlassFish Server上运行Java EE应用程序时偶尔会出现java.lang.NullPointerException

时间:2015-07-13 10:57:26

标签: java-ee glassfish java-ee-7 glassfish-4.1

使用

运行Java EE应用程序
  • GlassFish Server 4.1 / Java EE 7
  • 具有JPA 2.1的EclipseLink 2.6.0
  • Mojarra 2.3.0-m02
  • PrimeFaces 5.2 final
  • OmniFaces 2.1 final
  • MySQL 5.6.11
  • JDK 8u45

在重新部署应用程序时,偶尔会发生java.lang.NullPointerException抛出,但不会对应用程序造成任何损害。

Severe:   An exception or error occurred in the container during the request processing
java.lang.NullPointerException
    at org.glassfish.grizzly.http.util.HttpCodecUtils.parseHost(HttpCodecUtils.java:69)
    at org.glassfish.grizzly.http.HttpRequestPacket.doParseHostHeader(HttpRequestPacket.java:723)
    at org.glassfish.grizzly.http.HttpRequestPacket.parseHostHeader(HttpRequestPacket.java:717)
    at org.glassfish.grizzly.http.HttpRequestPacket.serverName(HttpRequestPacket.java:283)
    at org.glassfish.grizzly.http.server.Request.getServerName(Request.java:1246)
    at org.apache.catalina.connector.Request.getServerName(Request.java:1882)
    at org.apache.catalina.connector.RequestFacade.getServerName(RequestFacade.java:535)
    at com.sun.enterprise.web.connector.coyote.PECoyoteConnector.requestEndEvent(PECoyoteConnector.java:1307)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:422)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
    at java.lang.Thread.run(Thread.java:745)

Warning:   GRIZZLY0013: Exception during FilterChain execution
java.lang.NullPointerException
    at org.glassfish.grizzly.attributes.Attribute.remove(Attribute.java:227)
    at org.glassfish.grizzly.http.server.HttpServerFilter.afterService(HttpServerFilter.java:383)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:260)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
    at java.lang.Thread.run(Thread.java:745)

它来自哪里以及为什么?我没有这个例外背后的原因,也没有申请似乎负责。

1 个答案:

答案 0 :(得分:0)

我遇到了这个问题,直到我创建了一个专门用于运行GF的新用户并安装了最新版本的JDK 1.8(我正在运行linux作为我的操作系统)

我创建了一个用户:gfadmin

创建新用户:useradd -d /home/gfadmin -g staff -s /bin/bash gfadmin

然后从oracle下载了JDK 1.8.0_91: (获取适用于您的操作系统和硬件的tar.gz文件) http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

将tar.gz文件放在/home/gfadmin

gunzip并取消tar文件。它应该创建一个目录:

/home/gfadmin/jdk1.8.0_91

编辑gfadmin用户.bash_profile文件并添加以下三行:

JAVA_HOME="/home/gfadmin/jdk1.8.0_91"
PATH="$JAVA_HOME/bin:$PATH"
export JAVA_HOME PATH

来源.bash_profile:

. ./.bash_profile

确认您使用的是刚刚安装的java版本,1.8.0_91:

java -version