Category Archives: Software Development

Glassfish version 3.1.2: Secure Admin must be enabled to access the DAS remotely.


Firstly, I only install the new Glassfish 3.1.2 only in my laptop and access the administration module locally by using “localhost:4048”. When I install it on the development server and try to access it remotely, by using “http:/my_host:port”. It shows me an error as cannot login with the message as

Secure Admin must be enabled to access the DAS remotely.

The Investigation

I’ve found the nice solution form stack overflow here.

The solution

It’s simple by activate the secure admin by using the following command line: –

asadmin --host [host] --port [port] enable-secure-admin

The host is the host name or IP address for the Glassfish Server which we need to enable the secure admin.

The port is the target Glassfish Server port which wee need to enable the secure admin.


Please take a big note as the following: –

  1. The target Glassfish Server which is the port owner is started before executing the above command.
  2. After executing, the target Glassfish Server need to be restarted for taking effect.


If we would like to disable the secure admin, it can be done easily as the following: –

asadmin --host [host] --port [port] disable-secure-admin

org.glassfish.embeddable.GlassFishException: PlainTextActionReporterFAILURENo configuration found for


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


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.


Java GUI implementation with Eclipse SWT, Eclipse Visual Editor Project and Maven: Part 3


This post will introduce you the end-to-end development with the Maven by using the very simple traditional, the Hello World ! So that you may apply to your own requirement.

The SWT Hello World !

Firstly we need the empty Maven project. All required dependency artifacts which have been mentioned at the previous post should be set at the project POM file as well.

After that we will create the SWT: Shell Visual Class at which you will see File –> New –> Other — > Java –> SWT –> Shell Visual Class. Here is the simple Hello World source which is generated by the visual editor. Please note, it is not a time to make a source code to be beautiful. We just need to see only the big picture.

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class HelloWorldSWT {

    private Shell sShell = null;
    private Text textName = null;
    private Label labelMessage = null;
    private Button buttonSubmit = null;
    private Button buttonCancel = null;
    private Label labelName = null;

     * This method initializes sShell
    private void createSShell() {
        final GridData gridData = new GridData();
        gridData.horizontalSpan = 2;
        final GridLayout gridLayout = new GridLayout();
        gridLayout.numColumns = 2;
        this.sShell = new Shell();
        this.sShell.setSize(new Point(300, 200));
        this.labelName = new Label(this.sShell, SWT.NONE);
        this.textName = new Text(this.sShell, SWT.BORDER);
        this.labelMessage = new Label(this.sShell, SWT.NONE);
        this.labelMessage.setText("I'm waiting for you.");
        this.buttonSubmit = new Button(this.sShell, SWT.NONE);
                new {
                    static final String MESSAGE = "Hello ";
                    public void mouseDown(
                            final e) {
                        final String name = HelloWorldSWT.this.textName.getText();
                        HelloWorldSWT.this.labelMessage.setText(MESSAGE + name);
        this.buttonCancel = new Button(this.sShell, SWT.NONE);

            new {
                public void mouseDown(
                        final e) {

        Display display = null;
        display = Display.getDefault();
        while (!this.sShell.isDisposed()) {
            if (!display.readAndDispatch()) {

    public static void main(final String[] args) {
        final HelloWorldSWT main = new HelloWorldSWT();

The Unit Testing with SWTBot

Normally, we should test all possible scenarios such as the following:-

Table 1: Test case scenario

# Scenario Expected Result
1 When the user enter the name and click submit. The label should displays “Hello <NAME>”.
2 When the user enter the name as an empty String

and click submit.

The label should displays “Hello ”. (There is a space.)
3 When the user enter the name and click cancel. The text and label should be cleared.
Etc. Etc.

I will show you only one case, the case #1. It just create a simple JUnit4 class and put the SWTBot related statements as the following: –

import junit.framework.Assert;

import org.apache.log4j.Logger;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.finders.ControlFinder;
import org.eclipse.swtbot.swt.finder.finders.MenuFinder;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import com.scc.biometric.poc.mock.swt.HelloWorldSWT;

public class HelloWorldSWTTest {
    private static final Logger LOGGER;
    static {
        LOGGER = Logger.getLogger(HelloWorldSWTTest.class);

    private SWTBot bot;

    public static void setUpBeforeClass() throws Exception {

    public static void tearDownAfterClass() throws Exception {

    public void setUp() throws Exception {

    public void tearDown() throws Exception {


    static {
        new Thread(new Runnable() {
            public void run() {
                try {
                    HelloWorldSWT.main(new String[] {});
                } catch (final Exception e) {
                          fatal("Cannot instantiate the Hello.", e);

    public void whenSay() {

    private void initSWTApplication() {

    private void waitForDisplayToAppear(final long time) {
        long    endTime = -1;
        Display display = null;
        try {
            endTime = System.currentTimeMillis() + time;
            while (System.currentTimeMillis() < endTime) { // wait until timeout
                try {
                    display = SWTUtils.display();
                    if (display != null) {
              "The display is found.");
                } catch (final Exception e) {
                          warn("Cannot find display, keep waiting.");
                try {
                } catch (final InterruptedException e) {
                    HelloWorldSWTTest.LOGGER.warn("The thread is interrupted", e);
                } // sleep for a while and try again
        } finally {
            display = null;

    private void initSWTBot() {
        ControlFinder cf = null;
        MenuFinder    mf = null;
        try {
            cf       = new ControlFinder();
            mf       = new MenuFinder();
   = new SWTBot(cf, mf);
        } finally {
            cf = null;
            mf = null;

    private void say(final String name) {
        SWTBotLabel  swtBotLabel  = null;
        SWTBotButton swtBotButton = null;
        SWTBotText   swtBotText   = null;
        String       saidMessage  = null;
        try {
            swtBotText   =
            Assert.assertNotNull("Cannot find the textName.", swtBotText);

            swtBotButton ="Submit");
            Assert.assertNotNull("Cannot find the buttonSubmit.", swtBotButton);

            saidMessage  = "Hello ";

            if (name != null) {
                saidMessage += name;
            } else {
                saidMessage += "null";

            swtBotLabel  =;

            Assert.assertNotNull("Cannot find the said lable.", swtBotLabel);

        } catch (final Exception e) {
            HelloWorldSWTTest.LOGGER.fatal("This is an unexpected error", e);
            throw new RuntimeException(e);
        } finally {
            swtBotLabel  = null;
            swtBotButton = null;
            swtBotText   = null;

Test It !!!

There are 2 way for performing the testing, first is either via the JUnit within the Eclipse IDE or via the command line as “mvn test”.


We have created the big picture, end-to-end classic traditional Hello World SWT application, including with the unit testing with SWTBot inside the Maven environment. The next step is fulfilling the test case so that it covers all the possible scenarios as a good practice.

Since we always be the Maven, then our application can be expanded to the other infrastructure more simply and easily. e.g Maven report, Maven Site, Code quality, Code Coverage, Continuous Integration server and so on. Most of them not only support the Maven project and but also provide120% compatible and cross platform.

Please take note, I’m on the Windows x86 Vista and develop the Maven project. My infrastructure is on the Linux: CentOS x86_64. The CI Server can build and perform the unit testing successfully. I have achieved the cross platform already.

Java GUI implementation with Eclipse SWT, Eclipse Visual Editor Project and Maven: Part 2


Regarding to my previous post, There are three required artifacts which should be installed before we move further, i.e. The Eclipse Visual Editor, The Eclipse SWT runtime and the Eclipse SWTBot. After we have finished installing, then we should deploy the required dependency artifacts to the local repository or the local repository manager, since there is no any internet Maven repository which provides the latest version.

Please note, the assumption is we already have an Eclipse, including Maven and other related artifacts, including with the system software. Anyhow all of them has been posted at my blog as well, you may refer to the series of Java Development with NetBeans and Maven. Please do not worry, since we are in the Maven world, the tools / IDE does not the issue. It is transparent so that you can build them without the IDE, via the command line. It’s a strongest point. I’m loving it.

The Required Artifacts

The Eclipse Visual Editor


It can be installed remotely via the Eclipse update site or offline via the All-In-One Update Site. Please note, I’ve face some difficult due the remotely and only achieve via the offline installation.

Even the required artifacts has been installed at your ECLIPSE_HOME, it is only for your platform. For me, I’m at a Windows, then there is only a WIN32-x86 runtime.

The Eclipse Standard Widget Toolkit (SWT) Runtime


As we have known, there is an OS dependency for the GUI development so that we need to have a specific and correct runtime for each platform. The Eclipse SWT provides us the runtime for every OS already.


You can download them here. You may choose only your decided platform, But I have downloaded all of them.

Deploy the dependency to the Maven

After you have finished installing, you should extract the downloaded artifact and deploy the swt.jar to your local repository or local repository manager. As you have known, I prefer the local repository manager, the Artifactory. Please note, you may deploy the source code for further reference as the src.jar.

The Eclipse SWTBot


You can install them remotely via the Eclipse Update Site. It is a platform independent artifacts.

Deploy the dependency to the Maven

After you have finished installing, the required artifact also have been installed at your ECLIPSE_HOME. You can search them by using the wildcard as “*swtbot*.jar” and deploy them to the Maven repository. The artifacts is as following: –

Table 1: The SWTBot Runtime

# Artifact
1 org.eclipse.swtbot.ant.optional.junit3_2.0.4.20110304_0338-e5aff47-dev-e36.jar
2 org.eclipse.swtbot.ant.optional.junit4_2.0.4.20110304_0338-e5aff47-dev-e36.jar
3 org.eclipse.swtbot.eclipse.core_2.0.4.20110304_0338-e5aff47-dev-e36.jar
4 org.eclipse.swtbot.eclipse.finder_2.0.4.20110304_0338-e5aff47-dev-e36.jar
5 org.eclipse.swtbot.eclipse.gef.finder_2.0.4.20110304_0338-e5aff47-dev-e36.jar
6 org.eclipse.swtbot.eclipse.spy_2.0.4.20110304_0338-e5aff47-dev-e36.jar
7 org.eclipse.swtbot.eclipse.ui_2.0.4.20110304_0338-e5aff47-dev-e36.jar
8 org.eclipse.swtbot.forms.finder_2.0.4.20110304_0338-e5aff47-dev-e36.jar
9 org.eclipse.swtbot.go_2.0.4.20110304_0338-e5aff47-dev-e36.jar
10 org.eclipse.swtbot.junit4_x_2.0.4.20110304_0338-e5aff47-dev-e36.jar
11 org.eclipse.swtbot.swt.finder_2.0.4.20110304_0338-e5aff47-dev-e36.jar


At the moment we already have all required artifact and ready to start the development.

The next post we will see the big picture, end-to-end development with Maven. Please stay tuned as always.

Java GUI implementation with Eclipse SWT, Eclipse Visual Editor Project and Maven: Part 1


My team have been assigned to perform the evaluation and POC for the GUI for Client/Server application. Firstly I focus to other tools instead of Java, since I’ve known that writing the Java GUI is a nightmare. On the other hand, if we use the new tools I need to learn it from the beginning, the new tools, new language, new framework and so on. The new tools may be limited to perform for some environment/OS. Then we have agreed and decided to use our well-known, Java.


My objective for searching the tools is as following: –

1. It should be a visual editor, since it will help us to speed up the GUI development.

2. It should support the Maven, since it is our build tool and support the CI integration.

3. There should be a GUI unit testing based on JUnit, since it can be integrated to the Maven for generate the code coverage and code quality analysis.


After a couple days searching via the internet. I’ve found the Eclipse: Visual Editor Project which supports the Java GUI development in 2 frameworks, Swing/JFC and SWT/RCP.

SWT/RCP !!!??? What is it ?

After reading the Eclipse: RCP and Eclipse: SWT, I thought that the Eclipse: RCP is equal to the JFC and the Eclipse: SWT is equal to the Swing. The SWT binary/runtime also provides the supporting to many OS platform, i.e. Windows, Mac, Linux, Solaris, AIX.

I also found the Eclipse: RAP as well. It is a platform which lets we build rich, Ajax-enabled Web applications by using the Eclipse development model, plug-ins with the well known Eclipse workbench extension points and a widget toolkit with SWT API. Existing RCP applications can be run as Web applications with only minor changes. It also provides the single sourcing, use the same code for multiple platform. It is worth enough to learn the single platform development for creating the GUI which can be executed by the Client/Server through the Web based.

Regarding to the unit testing, I found the Eclipse: SWTBot and the further information. It can be integrated to the JUnit and also provides the GUI functional testing, including with the keyboard/keystroke testing.


I’ve a tool for GUI development which provide the binary/runtime which can be executed in many environment/OS and architecture(Client/Server and Web based), including with the unit testing tool which support the JUnit. Especially, all of them support the Maven. In the next post, I will show you the traditional example “Hello World” for SWT/RCP, including with the unit testing. Please stay tuned.

%d bloggers like this: