Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NullPointerException at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:272) while accessing JAX-WS services

I'm getting the following exception while implementing JAX-WS services in a Java EE 7 application.

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)

The exception message appears to be very specific to GlassFish Server (I'm using 4.1).


The test scenario:

A CDI managed 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;
    }
}

The member variable test is just useless. It is taken only for the purpose of testing.

In an XHTML page, just access this test field like so,

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

so that the bean's method marked by @PostConstruct can be invoked.

The exception occurs, when entering an appropriate URL in the browser's address bar.


The testBean.getSum(int, int) is a remote EJB method which is successfully invoked, when the bean is changed to a singleton EJB just for reasons of testing like so,

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));
    }
}

In this case, the the proxy method getSum(int, int) which is actually available in the associated remote EJB is successfully invoked and it returns the sum of the two parameters supplied through it.

What makes GlassFish think about the java.lang.NullPointerException, when the service is accessed via an XHTML page?

like image 630
Tiny Avatar asked Jan 10 '23 11:01

Tiny


1 Answers

This is a bug in GlassFish 4.1 affecting the grizzly-kernel component in the server - the GlassFish Grizzly Embedded Server serving HTTP requests. This requires replacing the nucleus-grizzly-all.jar jar file in GlassFish server (4.1) as suggested here under ${glassfishHome}/glassfish/modules (do not forget to clear osgi-cache under #{glassfishHome}/glassfish/domains/yourDomain before starting/restarting the server).

I visited that link prior to this post but its status was "resolved" according to GlassFish Server 4.1 that made me think something different.

Please note : Someone already posted the same answer a few hours ago but the answer was deleted perhaps by trusted users considering a link-only answer. Despite the fact that it is a link-only answer but in this case, there is no way to get around the issue other than replacing the new jar in the server and even the jar was provided after this question was asked on November 19, 2014. I hope this answer will not be deleted.

like image 177
Tiny Avatar answered Feb 25 '23 22:02

Tiny