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.
Create a simple J2EE app, with 1 web app and 1 ejbmodule. In the ejbmodule, add a session bean (local or remote) in the web app, add a servlet. In the servlet, use the "call ejb" wizard So far, everythin works: compile, deploy execute... But the verifier (Verify popup on the EAR project) is failing with 2 errors, related to the WAR class loader that does not see the local and locahome interfaces for the ejb... -------------- FAILED TESTS : -------------- Test Name : tests.web.elements.WebEjbReferencesElement Test Assertion : Web archive references to other bean's home interfaces. Please refer to Java Servlet 2.3 Specification Section #SRV.13.3, Java Servlet 2.4 Specification Section 13.4, J2EE 1.4 Platform Specification Section #5.3.1.2, J2EE 1.4 Platform Specification Section #5.3.2 for further information. Test Description : For [ /EnterpriseApplication12-WebModule/.war ] Error: For ejb-ref element [ ejb/NewSessionBean ] the home/component interface class [ f.NewSessionLocalHome ] is not loadable within [ EnterpriseApplication12-WebModule.war ]. Error: For ejb-ref element [ ejb/NewSessionBean ] the home/component interface class [ f.NewSessionLocal ] is not loadable within [ EnterpriseApplication12-WebModule.war ]. Test Name : tests.web.WebArchiveClassesLoadable Test Assertion : All classes in this Web Archive are loadable. Please refer to J2EE 1.4 Specification Section #8.1.2 for further information. Test Description : For [ /EnterpriseApplication12-WebModule/.war ] classes [ f.NewSessionLocalHome f.NewSessionLocal ] referenced by [ fcff.NewServlet] are not found So to be spec compliant, we need to make sure the WAR which is packaged inside the EAR file can see the ejb local and localhome classes. To achieve that, we need to mark the "package" flag when we add the EJB module jar in the complie classpath of the war file... This will add in the MANIFEST file of the war an entry like: Class-Path: EnterpriseApplication12-EJBModule.jar that will make verifier happy... I tested this and it works, both at runtime or at verifier time, so this is mandatory to add in otder to be spec compliant.
Pavel, I tested both with 1 war and 2 wars inside the same EAR accessing the same ejb, and the verifier is OK as well as the 2 servlets that can call the same ejb without nay issue. So I guess you can go ahead and fix the "package" flag when an ejbmodule jar is added to the libraries of a web app, so that the servlets using these ejbs can compile... I checked with the J2EE spec gurus and this is what we need to do. I guess the fix is trivial on your side.
BTW, P1, because of spec compliance requirements
I just watched Ludo go through the workaround. It looks great. The Package "flag" is has very complex semantics, that change depending on whether the a web app is "inside" an Ent App or "stand-alone". That probably needs to be re-examined....
For now I will just set the package tag to include ejbjar into archive. Vince, if you have specific suggetions for how to improve it file a separate issue.
so far I think this is the cleanest solution...
fixed in trunk Checking in src/org/netbeans/modules/web/project/WebContainerImpl.java; /cvs/web/project/src/org/netbeans/modules/web/project/WebContainerImpl.java,v <-- WebContainerImpl.java new revision: 1.14; previous revision: 1.13
Created attachment 21667 [details] diff
Back to your comment, Vince: I see what you mean. The "package" button (originally the text was something like "include in war" if I remember correctly) was included with the standalone war file in mind. It was later reused for ear. When you try this with a Java library project you will see why this makes sense. If you decide that the java library jar should be packaged with war, what this means for ear is that the jar will be added to ear and added to war manifest. If it is not packaged it will not be added to ear at all. With ejb jar it works the same way EXCEPT that ejb jar is added into ear anyway, because you add it there manually. This makes it harder to notice that it is not referenced from the war. So the solution is logical, I think.
Fix verified, both at the J2EE verifier tool level, and the test execution level: the servlet can call local or remote ejbs...
According to Ludo comment, fix is verified in trunk and could be commit to netbeans41. I have only one comment to modules that are not in same J2EE application. Let's think about web module and EJB module that are deployed separately. In web module is servlet that calls bean from EJB. Full Ejb.jar is packaged in web module .war. I think that only interfaces should be packaged in clients module, not all ejb.jar with implementations classes, deployment descriptors,.... This use case should be resolved with new issue or enhencement.
I have reviewed the fix and it seems OK to me.
fixed in release41 /cvs/web/project/src/org/netbeans/modules/web/project/WebContainerImpl.java,v <-- WebContainerImpl.java new revision: 1.13.2.1; previous revision: 1.13 done
This may seem like a silly question... Why isn't Package set by default...
> This may seem like a silly question... Why isn't Package set by default... Vince, that's exactly what my fix does :-)
[Build netbeans41 RC1]