This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Follow-up on bug 190670. 1. Create a Java EE 6 Maven Web application 2. Set target server to e.g. GlassFish 3.1 3. Create an EJB and add a business method 4. Generate JUnit tests for this EJB using the action on the class' popup menu 5. Run the tests Running tests will fail with the notorious error: 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) The steps to amend this are described in bug 190670, but the IDE should really do the setup out of the box, when the target server is set. Note that it is still not completely clear how the setup should be done cleanly, as there are several conflicting ways to do it, see: - Arun's blog on the subject http://blogs.sun.com/arungupta/entry/totd_133_jpa2_jpql_criteria - GlassFish bug https://glassfish.dev.java.net/issues/show_bug.cgi?id=13865 - discussion in bug 190670 - Arquillian approach: http://community.jboss.org/en/arquillian/blog/2010/10/04/the-perfect-recipe-for-testing-jpa-2-revisited
Another blog on this subject: http://blog.eisele.net/2010/11/arquillian-test-in-container-with.html
According to an off-line discussion, using the system scope dependency as suggested in GlassFish bug 13865 is the correct approach. The one remaining question is *when* to add this dependency - adding it to all projects by default after the user sets the server seems too intrusive. A compromise approach could be to add the code to the pom file at this time, but make it commented out.
I decided to try to fix this via editor hint. "EJBContainer.createEJBContainer" method call will be underlined as error if its EXECUTE classpath does not contain class "javax.ejb.embeddable.EJBContainer" which can be instantiated. EJBContainer class is stripped of its body in official Java EE APIs and therefore unless user added to runtime classpath some server jars with EE APIs the hint will be shown. The hint says "Implementation of EJBContainer is missing on project's classpath" and the hint has also Fix action. Fix action depends on server registered in IDE and at the moment ignores all other servers than GlassFish. For each GF version 3.* an Fix action is added and labeled as "Use EJBContainer from installation of {ServerDisplayName}". Triggering fix adds "glassfish-embedded-static-shell" artifact to pom.xml in system scope with properly initialized systemPath. If Maven project has GlassFish as associated server only Fix action for that server is shown. Let's test this and see how well it works. dff771970c69
Thanks, works well for me, although I think several improvements still could be done: - would it be possible to display an error badge of the test file in the explorer (and all ancestors of this node), so it is more discoverable? - would it be possible to also display this error in the task list? - after applying the hint, GlassFish location is hardcoded in pom.xml. Jesse suggested a better approach in comment 190670#c23 (this is also displayed as a warning in Maven output).
(In reply to comment #4) > - would it be possible to display an error badge of the test file in the > explorer (and all ancestors of this node), so it is more discoverable? > - would it be possible to also display this error in the task list? I guess this depends on bug #151760? > comment 190670#c23 I guess you mean: bug #190670 comment #23
Integrated into 'main-golden', will be available in build *201101220001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/dff771970c69 User: David Konecny <dkonecny@netbeans.org> Log: #191590 - Testing EJBs in Java EE 6 Maven projects does not work out of the box
(In reply to comment #4) > - after applying the hint, GlassFish location is hardcoded in pom.xml. fixed as cfce248f035f
Integrated into 'main-golden', will be available in build *201101240001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/bc9d94357e80 User: David Konecny <dkonecny@netbeans.org> Log: #191590 - limit the hint to Maven projects only
Integrated into 'main-golden', will be available in build *201101250001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/cfce248f035f User: David Konecny <dkonecny@netbeans.org> Log: #191590 - store local path as a property