Category Archives: Unit Testing

org.glassfish.embeddable.GlassFishException: PlainTextActionReporterFAILURENo configuration found for server.network-config.network-listeners.network-listener.http-listener

Overview

When I upgrade the Glassfish Server to be a version 3.1.2 from  here, the Glassfish Embedded Server should be upgraded as well. Anyhow when I perform the unit test, it is failed as

org.glassfish.embeddable.GlassFishException: PlainTextActionReporterFAILURENo configuration found for server.network-config.network-listeners.network-listener.http-listener

Investigation

I’ve put the whole exception mentioned above to sear via Google and found the useful information at Glassfish Jira issue #18452 . They mention about the configuration at the domain.xml is not completed. I’ve been noticed that the Glassfish Embeded Server has some limitation about the HTTP listener port and need to be applied the additional configuration as it is mentioned here.

The Root Cause

The root cause is I’ve configured the HTTP port explicitly as

props.put("org.glassfish.ejb.embedded.glassfish.web.http.port", 14080);
ejbContainer = EJBContainer.createEJBContainer(props);

The Solution

It is a very easy step by removing the explicitly configured HTTP port. Anyhow, the domain.xml should be configured for all related ports properly. We can download the starter domain.xml from here and start configure all related ports and/or further jdbc/datasource resources as well.

 

The EJB Session Bean Unit Testing with JUnit (Extended)

Even the Glassfish Application Server is not to be started and your application also is not to be deployed. You should firstly configure the other required resources, the connection pool for example, by using the Glassfish Application Server Administration console since the configuration is shared between the Glassfish Application Server and EJB embedded container. If not you may face some trouble about the resources missing/absence exception.

Updated on June 29, 2010
My fault. The application should be deployed to the Glassfish Application Server once before running the unit testing. If not you will face some trouble about the JNDI looking up.

The EJB Session Bean Unit Testing with JUnit

The EJB embedded container is introduced by the Glassfish Application Server version 3 and it is a core part for unit testing. It’s light weight and strong enough so that the EJB unit testing can be executed without the starting of Glassfish Application Server. For sure, you may imagine it can be applied for other purpose as same as the embedded database.

Via NetBean, you can create the JUnit test case and test suit simply by right clicking at the node named “Test Packages” of your EJB project and choose the one you want. The following is the simply step for initiating the EJB embedded container: –

Creating the JUnit test case or test suit

1. Declare and initiate the EJB embedded container.

private static EJBContainer ejbContainer = EJBContainer.createEJBContainer();

2. Declare and initiate the JNDI context for looking up the EJB.

private static Context context = ejbContainer.getContext();

3. Simply use the context object for looking up your EJB and another JavaEE resources via JNDI, for example, The connection pool, the EJB and so on.

4. The rest is creating your test respectively to you business, unit or others test case by following the JUnit standard.

Note:

1. The EJBContainer is javax.ejb.embeddable.EJBContainer

2. The Context is javax.naming.Context

Executing the test case with the EJB embedded container

The prerequisite

1. The EJB application is not required to be deployed to the Glassfish Application Server

2. The Glassfish Application Server must not be started since the ports will be clashed since the embedded will share the same ports.

The execution

Just simply right click at your test case or test suit and choose “Run File”.

%d bloggers like this: