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.
[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) ...
Created attachment 32651 [details] exc stack trace
Created attachment 32652 [details] zipped project sources
Project sources do not contain ejb-jar.xml in src/conf.
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"
The file is not there because it's not required for Java EE 5 as I was told.
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.
Can we close this? The info I have is that the file is required.
Well, I think that it shouldn't at least throw runtime exception.
Yes, I agree -- changing subject to better match problem and removing INCOMPLETE.
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.
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."
Thanks. The text looks okay except I'd skip the caps in ejb-jar.xml.
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.
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.
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?
Created attachment 33859 [details] diffs of IllegalStateException change.
Created attachment 33911 [details] The real diffs committed for this IllegalStateException change.
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
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
Gah, note the last two comments represent the same thing. Disregard one of them.
... Is the totoal diff http://www.netbeans.org/nonav/issues/showattachment.cgi/33911/82169a_diffs.txt PLUS 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
diffs look good
Committed to release55_dev
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.
Fix committed to release55 branch.
Please, can a QE member verify the fix in latest relase55 build and mark this issue as verified?
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.