Unit test initialization error
I am a student studying enterprise component architecture. I'm working on a simple EJB project, but I am running into issues with my unit tests. I'm using Netbeans 7.1 with Glassfish 3.1.1. I have a EJB Module project with a @Stateless @LocalBean that implements a @Remote interface from another project. In the unit test I am using an embedded EJB container, and attempt to do a lookup via the context.
The problem is I am getting the following warning:
WARNING: multiple versions of ant detected in path for junit
jar:file:/C:/Program%20Files/NetBeans%207.1/java/ant/lib/ant.jar!/org/apache/tools/ant/Project.class
and jar:file:/C:/glassfish3/glassfish/modules/ant.jar!/org/apache/tools/ant/Project.class
And the following error:
Testcase: initializationError(trefliq.persistence.CredentialEJBTest): 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:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.getDeclaredFields0(Native Method)
I am just wondering if anyone is familiar with this issue, and can perhaps give me some suggestions on how to resolve it?
Thank you for your time.
Thanks for the reply, Marina.
Removing the Ant.jar from Glassfish got rid of the Ant warning. However, I am still getting the initialization error.
I figured out the absent code error. The project that contained the remote interface had the javaee-api-6.0.jar on the classpath. I did not realize this was a problem until I removed it and the error immeadiately went away.
Thanks so much for the help.





You are running into http://java.net/jira/browse/GLASSFISH-16285. It describes the workarounds.
-marina