KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've been trying to set my application up so that I can unit test it's EJBs all day but I can't seem to get past what seems like a really simple problem. I have a standard Maven web application set up in NetBeans 6.9. I've automatically generated a unit test for one of the EJBs but whenever I go to run it I get the error message: Testcase: initializationError(com.example.ExampleTest): 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.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) I've researched this one to death and I'm pretty sure the problem is that my pom currently points to a jar which contains only the API <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> Not and implementation that can be used for running the tests. I'm pretty sure the test is failing in the method marked with @BeforeClass when it tries to execute container = EJBContainer.createEJBContainer(); The standard recommended solution is to add the glassfish-embedded-all artifact as the first project dependency with test scope <dependency> <groupId>org.glassfish.extras</groupId> <artifactId>glassfish-embedded-all</artifactId> <version>3.0.1</version>
Tags (comma-separated)
Save Edits
Cancel