Virtual Box not working

If VirtualBox is not working properly one reason can be the CPU configuration controlled by the BIOS. Try to activate the setting

Intel Virtualization Technology = Enabled

 

Debian – Testing

In Debian werden Paket relativ selten aktualisiert und mit neueren Versionen ausgetauscht. Hier unterscheidet sich Debian deutlich von Ubuntu. Wen man dennoch ein wichtiges Update von einem Kernel benötigt kann man über die Backports diesen meist problemlos nach-installieren. Dies habe ich hier beschrieben.

Darüber hinaus gibt es aber auch die Möglichkeit über die DebianTesting releases neuere Paket zu nutzen. Ich beschreibe im Folgenden das grundsätzliche vorgehen.

Continue reading “Debian – Testing”

JUnit and Glassfish 3.1.1 – remote ejb tests

Trying to run a JUnit Test with remote EJB lookups from a GlassFish server 3.1.1 it is a little bit tricky. It seems to me that it is not possible to get the maven dependencies working. The gf_client.jar can not be included using a dependency, although the artefact can be located using the glassfish repository from java.net :

    .....
      <!-- Glassfish -->
          <repository>
                 <id>glassfish-repository</id>
                 <name>Java.net 
                 Repository for Glassfish</name>
                <url>http://download.java.net/maven/glassfish</url>
          </repository>
.....

..and adding a dependecy:

    ...
    <dependency>
            <groupId>org.glassfish.appclient</groupId>
            <artifactId>gf-client</artifactId>
            <version>3.1.1</version>
            <scope>test</scope>
        </dependency>
....

But after all this wont work for me. So the best way is to add the gf_client.jar directly into your classpath.

The gf_client.jar is located in your Glassfish Installation at

$GLASSFISH_HOME/glassfish/lib/gf-client.jar

 

Now you can write a JUnit test with a remot ejb lookup. See the following example for a remote lookup to Imixs Entity Service

 public class TestEntityService {
    EntityServiceRemote entityService = null;

    @Before
    public void setup() {
        try {
            // set jndi name
            String ejbName = "java:global/imixs-workflow-web-sample-0.0.5-SNAPSHOT/EntityService!org.imixs.workflow.jee.ejb.EntityServiceRemote";
            InitialContext ic = new InitialContext();
            entityService = (EntityServiceRemote) ic.lookup(ejbName);
        } catch (Exception e) {
            e.printStackTrace();
            entityService = null;
        }
    }

    @Test
    @Category(org.imixs.workflow.jee.ejb.EntityServiceRemote.class)
    public void testService() {
        Assert.assertNotNull(entityService);
        //....

    }

Note: To run this JUnit test you have to first deploy your test application. After that you junit test can be run.

TESTING SECURED EJBS

If your remote ejb is annotated with the security annotation @RolesAllowed you need to authenticate your remote lookup.

In GlassFish this can be done using the programmatic Login. To setup a programmatic login in your JUnit test first create a File named ‘auth.conf’. The content of that file should look like this:

default { 
com.sun.enterprise.security.auth.login.ClientPasswordLoginModule required debug=false; 
};

Now you can add the programmatic login into your test setup

     @Before
    public void setup() {

        try {
            // set jndi name
            String ejbName = "java:global/imixs-workflow-web-sample-0.0.5-SNAPSHOT/EntityService!org.imixs.workflow.jee.ejb.EntityServiceRemote";
            // setup programmatic login for GlassFish 3
            System.setProperty("java.security.auth.login.config", "/home/rsoika/eclipse_37/imixs-workflow/imixs-workflow-engine/src/test/resources/auth.conf"); 
            ProgrammaticLogin programmaticLogin = new ProgrammaticLogin(); 
            // set password
            programmaticLogin.login("Anna", "anna"); 
            InitialContext ic = new InitialContext();
            entityService = (EntityServiceRemote) ic.lookup(ejbName);
        } catch (Exception e) {
            e.printStackTrace();
            entityService = null;
        }
    }

Note: the username/password is defined in this case in a file realm which is the default security realm of my GlassFish

Here are some helpful links:

http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB

http://www.coderanch.com/t/476090/EJB-JEE/java/EJB-Realms-Remote-Clients

 

Welcome

Hi,

in this blog I will post my personal technical findings in developing java programs. Some things will be helpfully for other folks some things will not. If you find something wrong or you know better solutions do not hesitate to comment here.

I am a member of the Imixs IX Open Source Workflow Project. If you are interesting in workflow technologies based on Java join our project!

As I am using also Linux ubuntu I will post sometimes things arround ubuntu and java.

In general I beleve in free software as preached by the Free Software Foundaition. So sometimes I will publish also my personal thoughts about open source and free software.