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.

Bug 57917 - J2EE app verrification failure
Summary: J2EE app verrification failure
Status: CLOSED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: EAR (show other bugs)
Version: 4.x
Hardware: All All
: P1 blocker (vote)
Assignee: Pavel Buzek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-14 23:37 UTC by _ ludo
Modified: 2006-05-30 11:19 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
diff (2.96 KB, text/plain)
2005-04-15 02:13 UTC, Pavel Buzek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ ludo 2005-04-14 23:37:30 UTC
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.
Comment 1 _ ludo 2005-04-14 23:40:23 UTC
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.
Comment 2 _ ludo 2005-04-14 23:56:08 UTC
BTW, P1, because of spec compliance requirements
Comment 3 Vince Kraemer 2005-04-15 00:03:01 UTC
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....
Comment 4 Pavel Buzek 2005-04-15 01:19:42 UTC
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.
Comment 5 _ ludo 2005-04-15 01:23:33 UTC
so far I think this is the cleanest solution...
Comment 6 Pavel Buzek 2005-04-15 02:11:47 UTC
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
Comment 7 Pavel Buzek 2005-04-15 02:13:19 UTC
Created attachment 21667 [details]
diff
Comment 8 Pavel Buzek 2005-04-15 02:24:15 UTC
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.
Comment 9 _ ludo 2005-04-15 02:55:57 UTC
Fix verified, both at the J2EE verifier tool level, and the test execution
level: the servlet can call local or remote ejbs...

Comment 10 Petr Blaha 2005-04-15 11:04:54 UTC
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.
Comment 11 Andrei Badea 2005-04-15 14:04:03 UTC
I have reviewed the fix and it seems OK to me.
Comment 12 Pavel Buzek 2005-04-15 16:20:43 UTC
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
Comment 13 Vince Kraemer 2005-04-15 16:47:34 UTC
This may seem like a silly question...  Why isn't Package set by default...
Comment 14 Pavel Buzek 2005-04-15 17:37:45 UTC
> This may seem like a silly question...  Why isn't Package set by default...

Vince, that's exactly what my fix does :-)
Comment 15 Petr Blaha 2005-04-18 10:15:04 UTC
[Build netbeans41 RC1]