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 82169 - Should not have NPE when importing EJB prj with missing ejb-jar.xml
Summary: Should not have NPE when importing EJB prj with missing ejb-jar.xml
Status: VERIFIED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: Sun Appserver 8 (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: _ pcw
URL:
Keywords: I18N
Depends on:
Blocks:
 
Reported: 2006-08-08 14:37 UTC by Milan Kubec
Modified: 2006-09-29 02:38 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
exc stack trace (3.11 KB, application/octet-stream)
2006-08-08 14:38 UTC, Milan Kubec
Details
zipped project sources (11.54 KB, application/octet-stream)
2006-08-08 14:40 UTC, Milan Kubec
Details
diffs of IllegalStateException change. (3.07 KB, text/plain)
2006-09-13 00:57 UTC, _ pcw
Details
The real diffs committed for this IllegalStateException change. (1.78 KB, text/plain)
2006-09-14 00:15 UTC, _ pcw
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Kubec 2006-08-08 14:37:17 UTC
[release55-200608080000, JDK 1.6.0]

NullPointerException is thrown to console when creating EJB project from
existing sources.

Steps to reproduce:
1) unzip attached zip file
2) open wizard EJB from ex. sources
3) select unzipped folder
4) browse to unzipped folder for Location, have GF as appserver, click Next
5) select src/conf as configuration folder, Next and Finish

Attached exception is thrown.

java.lang.NullPointerException
        at
com.sun.jdo.modules.persistence.mapping.ejb.EJBDevelopmentInfoHelper.getEjbNames(EJBDevelopmentInfoHelper.java:159)
        at
com.sun.jdo.modules.persistence.mapping.ejb.util.SunOneUtilsCMP.makeMappingsConsistent(SunOneUtilsCMP.java:245)
        at
com.sun.jdo.modules.persistence.mapping.ejb.util.SunOneUtilsCMP.getMappingContext(SunOneUtilsCMP.java:127)
[catch] at
org.netbeans.modules.j2ee.sun.share.configbean.EjbJarRoot.getMappingContext(EjbJarRoot.java:665)
        at
org.netbeans.modules.j2ee.sun.share.configbean.EjbJarRoot.loadCmpMappingsFromPlanFile(EjbJarRoot.java:972)
...
Comment 1 Milan Kubec 2006-08-08 14:38:43 UTC
Created attachment 32651 [details]
exc stack trace
Comment 2 Milan Kubec 2006-08-08 14:40:07 UTC
Created attachment 32652 [details]
zipped project sources
Comment 3 Milan Kubec 2006-08-08 14:41:58 UTC
Project sources do not contain ejb-jar.xml in src/conf.
Comment 4 Rochelle Raccah 2006-08-08 22:54:43 UTC
The problem is that there is no ejb-jar.xml in this project.  Why isn't there? 
I checked with Marina and she said "If it has CMPs, ejb-jar.xml is required"
Comment 5 Milan Kubec 2006-08-09 07:49:41 UTC
The file is not there because it's not required for Java EE 5 as I was told.
Comment 6 Rochelle Raccah 2006-08-09 21:30:27 UTC
Nope, not true if you use cmp beans.  From Ken:

Yes, annotations are not supported for any 2.x or earlier BMP/CMP beans,
so the only way to define them is via ejb-jar.xml.
Comment 7 Rochelle Raccah 2006-08-14 22:50:19 UTC
Can we close this?  The info I have is that the file is required.
Comment 8 Milan Kubec 2006-08-15 07:47:45 UTC
Well, I think that it shouldn't at least throw runtime exception.
Comment 9 Rochelle Raccah 2006-08-15 22:20:15 UTC
Yes, I agree -- changing subject to better match problem and removing INCOMPLETE.
Comment 10 _ pcw 2006-08-15 22:54:09 UTC
I agree with not showing the user an NPE in this case.  The problem is,
sometimes the NPE's represent genuine NetBeans bugs, so how to differentiate?

I'm going to discuss some possibilities offline with Rochelle, but I see two
options --

1) EJBDevelopmentInfoHelper.getEjbNames() throws
IllegalStateException("ejb-jar.xml is required for CMP 2.x entity beans") and we
can catch this in EjbJarRoot and display the message (message should be
localized and "user-friendly").

2) EJBDevelopmentInfoHelper.getEjbNames() returns an empty collection.  Possible
issue here is that it looks like this would cause sun-cmp-mappings.xml to have
it's contents deleted because there appear to be no entity beans (thus there
shouldn't be any mappings).  Certainly there aren't any legal entity beans, but
in the case where the user has done an incomplete migration from J2EE 1.4 to
JavaEE5 and neglected to rebuild ejb-jar.xml, this might not be so friendly.  I
can't imagine any other circumstances where they might reasonably encounter this
scenario.
Comment 11 _ pcw 2006-08-16 02:17:50 UTC
I'm going to implement option A.  Advice on text would be nice.  Right what I've
got is something like : [project name]: Ejb-jar.xml is required when using CMP
Entity beans."
Comment 12 Rochelle Raccah 2006-08-16 02:21:41 UTC
Thanks.  The text looks okay except I'd skip the caps in ejb-jar.xml.
Comment 13 _ pcw 2006-08-19 01:21:20 UTC
I added code to throw an IllegalStateException from
EJBDevelopmentInfoHelper.java in persistence-tools-support.jar when no
ejb-jar.xml state was encountered.

The text for this exception is "ejb-jar.xml is required when using CMP
Entity beans." and is stored in a new bundle file (hence the new I18N keyword on
this issue.)

For display purposes, I still need to update EjbJarRoot.java in sunddui module
to catch and display this exception.  Normally, this would be a one liner. 
However, if such a project is being opened during startup of the IDE, I need to
add code to not display it until after the main window for NetBeans is displayed.
Comment 14 _ pcw 2006-09-12 00:48:50 UTC
The remaining task here is to add a "nice messagebox" instead of displaying an
exception (note that the exception message is a "nice" message).

Defer to next release.
Comment 15 _ pcw 2006-09-13 00:52:05 UTC
Ack -- the patch to persistence-tools-mapping making this an
IllegalStateException is NOT committed to release55 branch of NetBeans, which
means this bug is not fixed in anyway.

Patch is attached -- it is a trivial change, I think this should be upgraded to
P2 and fixed in NB 5.5.  Any dissenting opinions?
Comment 16 _ pcw 2006-09-13 00:57:01 UTC
Created attachment 33859 [details]
diffs of IllegalStateException change.
Comment 17 _ pcw 2006-09-14 00:15:27 UTC
Created attachment 33911 [details]
The real diffs committed for this IllegalStateException change.
Comment 18 _ pcw 2006-09-14 01:50:49 UTC
Change catch block for this new exception so that it is logged as WARNING (and
displayed to user) rather than INFORMATIONAL.  Otherwise, the user was not
informed of the problem.

http://serverplugins.netbeans.org/source/browse/serverplugins/sun/sunddui/src/org/netbeans/modules/j2ee/sun/share/configbean/EjbJarRoot.java?r1=1.1.16.6.2.11.6.1&r2=1.1.16.6.2.11.6.2
Comment 19 _ pcw 2006-09-14 21:49:19 UTC
Addition change required to make the IllegalStateException w/ "missing
ejb-jar.xml" message visible to user (it was just being logged before).

http://serverplugins.netbeans.org/source/browse/serverplugins/sun/sunddui/src/org/netbeans/modules/j2ee/sun/share/configbean/EjbJarRoot.java?r1=1.1.16.6.2.11.6.1&r2=1.1.16.6.2.11.6.2
Comment 20 _ pcw 2006-09-14 21:50:07 UTC
Gah, note the last two comments represent the same thing.  Disregard one of them.
Comment 22 Rochelle Raccah 2006-09-15 23:25:53 UTC
diffs look good
Comment 23 _ pcw 2006-09-16 01:40:39 UTC
Committed to release55_dev
Comment 24 judytang 2006-09-20 22:50:39 UTC
I used 9/20 release55_dev for testing and verified if there is no ejb-jar.xml 
for CMP app, IDE gets IllegalStateException w/ "missing ejb-jar.xml" message

Thanks Peter for showing me how to verify this issue.

Comment 25 _ pcw 2006-09-21 00:25:06 UTC
Fix committed to release55 branch.
Comment 26 Martin Schovanek 2006-09-26 16:03:30 UTC
Please, can a QE member verify the fix in latest relase55 build and mark this
issue as verified?
Comment 27 judytang 2006-09-29 02:38:31 UTC
I used 9/28 release55 for testing and verified if there is no ejb-jar.xml 
for CMP app, IDE gets IllegalStateException w/ "missing ejb-jar.xml" message.

I am marking this issue as verified.