quality@glassfish.java.net

Unit testing EJB modules with GlassFish Embeddable

From: Richard Kolb <rjdkolb_at_gmail.com>
Date: Tue, 5 Jan 2010 11:54:21 +0200

Hi Cats

I am still struggling down the EJB unit testing path.

I've been going though the manual trying to replicate the ejb-embedded
sample in Maven.
Docs : http://docs.sun.com/app/docs/doc/821-1208/gjlde?l=en&a=view
Sample :
https://glassfish-samples.dev.java.net/source/browse/*checkout*/glassfish-samples/ws/javaee6/ejb/ejb-embedded/docs/index.html

Added this maven dep :
        <dependency>
            <groupId>org.glassfish.extras</groupId>
            <artifactId>glassfish-embedded-all</artifactId>
            <version>3.0</version>
        </dependency>


I call the following code in my JUnit test :
            Map<String, Object> p = new HashMap<String, Object>();
            p.put(EJBContainer.APP_NAME, "sample");

            EJBContainer c = EJBContainer.createEJBContainer(p);


Then I get the below

Please help.
regards
Richard




Testsuite: za.co.enerweb.enygma.businesslogic.staging.TestCustomerCrud
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.15 sec

Testcase:
simple(za.co.enerweb.enygma.businesslogic.staging.TestCustomerCrud):
Caused an ERROR
Absent Code attribute in method that is not native or abstract in class file
javax/ejb/embeddable/EJBContainer
java.lang.ClassFormatError: Absent Code attribute in method that is not
native or abstract in class file javax/ejb/embeddable/EJBContainer
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
        at
za.co.enerweb.enygma.businesslogic.staging.TestCustomerCrud.simple(TestCustomerCrud.java:32)


Test za.co.enerweb.enygma.businesslogic.staging.TestCustomerCrud FAILED