访问JAX-WS服务时,org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:272)中的java.lang.NullPointerException

时间:2014-11-12 12:04:16

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

在Java EE 7应用程序中实现JAX-WS服务时,我遇到以下异常。

Warning:   Internal Server error: /Test-war/Test.xhtml
java.lang.NullPointerException
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:272)
    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)

异常消息似乎非常特定于GlassFish Server(我正在使用4.1)。


测试场景:

CDI托管bean:

@Named
@ViewScoped    
public class TestManagedBean implements Serializable
{
    private String test;
    private static final long serialVersionUID=1L;

    public TestManagedBean() {}

    @PostConstruct
    private void init() {
        TestBean_Service testBean_Service=new TestBean_Service();
        TestBean testBean = testBean_Service.getTestBeanPort();
        System.out.println("testBean sum = "+testBean.getSum(5, 10));
    }

    public String getTest() {
        return test;
    }
}

成员变量test没用。它仅用于测试目的。

在XHTML页面中,只需访问此test字段即可,

<h:outputText value="#{testManagedBean.test}"/>

以便可以调用由@PostConstruct标记的bean的方法。

在浏览器的地址栏中输入适当的URL时会发生异常。


testBean.getSum(int, int)是一个成功调用的远程EJB方法,当bean因为这样的测试原因而被改为单例EJB时,

import client.web.services.TestBean;
import client.web.services.TestBean_Service;
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;

@Startup
@Singleton
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class TestManagedBean
{
    public TestManagedBean() {}

    @PostConstruct
    private void init() {
        TestBean_Service testBean_Service=new TestBean_Service();
        TestBean testBean = testBean_Service.getTestBeanPort();
        System.out.println("testBean sum = "+testBean.getSum(5, 10));
    }
}

在这种情况下,成功调用在关联的远程EJB中实际可用的代理方法getSum(int, int),并返回通过它提供的两个参数的总和。

当通过XHTML页面访问服务时,GlassFish对java.lang.NullPointerException的看法是什么?

1 个答案:

答案 0 :(得分:9)

这是GlassFish 4.1中影响服务器中grizzly-kernel组件的错误 - 提供HTTP请求的GlassFish Grizzly Embedded Server。这需要按照nucleus-grizzly-all.jar下的建议here替换GlassFish服务器(4.1)中的${glassfishHome}/glassfish/modules jar文件(在开始之前不要忘记在osgi-cache下清除#{glassfishHome}/glassfish/domains/yourDomain /重启服务器。)

我在这篇帖子之前访问了该链接,但根据GlassFish Server 4.1,它的状态已“解决”,这让我觉得有些不同。

请注意:几个小时前有人已经发布了相同的答案,但可疑用户可能会考虑仅限链接的答案删除答案。尽管这是一个仅限链接的答案,但在这种情况下,除了更换服务器中的新jar之外,没有办法解决问题,甚至在2014年11月19日提出这个问题之后提供了jar我希望这个答案不会被删除。