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 77626 - NPE followed by IllegalArgumentException in EJB from existing sources
Summary: NPE followed by IllegalArgumentException in EJB from existing sources
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: EJB Project (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords:
: 67776 74297 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-06-09 11:38 UTC by Bernard Halas
Modified: 2006-08-25 12:07 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
messages.log (13.86 KB, text/plain)
2006-06-09 11:39 UTC, Bernard Halas
Details
Stack trace (1.49 KB, text/plain)
2006-07-03 17:51 UTC, Andrei Badea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernard Halas 2006-06-09 11:38:29 UTC
JDK 1.6.0 b86
NB 200606090200

Descritpion:
============
When an user wants to create project "EJB with existing sources" from j2ee 1.4
sources, NetBeans throws a NullPointerException followed by an
IllegalArgumentException. As an example we will try to open sample project from
j2ee 1.4 sdk samples bundle.

Steps to reproduce:
===================
A) prepare sources and NB
  1) download "samples bundle" from http://java.sun.com/j2ee/1.4/download.html
  2) extract to your work folder
  3) add a glassfish server to NB
B) create new project
  1) press Ctrl+Shift+N
  2) select "EJB module with existing sources" from category "Enterprise"
  3) to "Location" field fill "your work folder/ejb/bmp/apps/simple/"
  4) fill "Project Name" and "Project Folder"
  5) select J2EE version to 1.4 and press "Next"
  6) to "Configuration Files Folder" field fill "your work
folder/ejb/bmp/apps/simple/src/conf" (freely do that through "Browse" button)
  7) press "Finish"

Appendix:
=========
It doesn't matter whether the user has NB tied to jdk v1.6.0, or to v1.4.2.
In case we DO NOT SELECT J2EE version to 1.4, the exceptions would not be thrown.
Comment 1 Bernard Halas 2006-06-09 11:39:09 UTC
Created attachment 30912 [details]
messages.log
Comment 2 Martin Adamek 2006-06-09 17:01:39 UTC
Please note, that you are trying to import J2EE 1.4 Enterprise Application as
EJB module. Please use Enterprise Application with Existing Sources wizard for
that. If you really want to import EJB module, you must navigate wizard to
ejb/bmp/apps/simple/simple-ejb directory, it is location of EJB module in this
sample application. If you do that, NetBeans will recognize J2EE version and
also config files folder. Mentioned NPE is in fact throwed because there is no
ejb-ja.xml file in config files folder you pointed to. I wanted to close this
issue as invalid, but NPEs should not appear anyway, so  I am just decreasing to
P3 and changing to right component.
Comment 3 Andrei Badea 2006-06-13 08:26:23 UTC
Sorry, but I can't reproduce it. I used ejb/bmp/apps/simple/src/conf as the
configuration files folder and ejb/bmp/apps/simple/simple-ejb/src/java as the
source folder and I didn't get any NPE. Marking as incomplete because the NPE is
not visible in the attached message log, so I can't tell what went wrong.

Please try to reproduce again and provide more information. Thanks.
Comment 4 Bernard Halas 2006-06-16 09:00:17 UTC
I just sticked to the steps I wrote in my first report and those exception were
fired again (NB 5.5 dev 200606160200, JDK 1.6.0 b87, fresh userdir)
And thanks for the notice about EJB and Enterprise Application. I overlooked that.
Comment 5 Bernard Halas 2006-06-23 10:57:43 UTC
You should use ejb/bmp/apps/simple, not ejb/bmp/apps/simple/simple-ejb/src/java
as a location folder.
Maybe we could just throw out an error about unsuccessfull creating a project
and free the user from those exceptions.
Comment 6 Andrei Badea 2006-07-03 17:51:54 UTC
Created attachment 31601 [details]
Stack trace
Comment 7 Andrei Badea 2006-07-04 10:35:18 UTC
The NPE is caused by EbjJarProvider.getModuleVersion() not checking the EjbJar
for null (which happens when there is no ejb-jar.xml file in a J2EE 1.4
project). Since there is no way to correctly compute the module version in this
case, I suggest returning a default value based on the project's Java EE version
and the module type (EJB in this case). So for J2EE 1.4 it would return 2.1 and
for J2EE 1.3 it would return 2.0. (It already returns 3.0 for Java EE 5.)

The same fix could be also used in the web project, whose getModuleVersion()
returns 2.5 if there is no web.xml file regardless of the Java EE version.

Would need an utility method returning the default module version given the
module type and the Java EE version:

/** 
 * @param  javaEEVersion the Java EE version, e.g. {@link J2eeModule.J2EE_14}.
 * @param  moduleType the module type, e.g {@link J2eeModule.EJB}.
 */
public String getDefaultModuleVersion(String javaEEVersion, String moduleType);

Pavle, does this make sense? Do we already have such a method? Please evaluate
and reassign back to me.
Comment 8 Andrei Badea 2006-08-14 14:58:43 UTC
*** Issue 74297 has been marked as a duplicate of this issue. ***
Comment 9 Andrei Badea 2006-08-16 14:39:43 UTC
*** Issue 67776 has been marked as a duplicate of this issue. ***
Comment 10 Pavel Buzek 2006-08-23 20:39:22 UTC
I am not sure this API is needed. Issue 83114 is fixed - check for null in
getModuleVersion(). For EE 5 you get correct version even if there is not DD bcs
it uses the DD computed from annotations. There is a fallback to 2.1 for ejb
module if it is not EE5 which I think is OK.

I think that web modules should return 2_5 for EE5 and 2_4 otherwise and you can
verify and close this issue.
Comment 11 Martin Krauskopf 2006-08-25 12:07:26 UTC
Pavel is rigth. It was fixed in 83114. I tried the steps and the mentioned ejb
sample is imported without any exceptions or warnings.
dd == null && version != 5.0 -> fallback to 

Was fixed by:
http://j2ee.netbeans.org/source/browse/j2ee/ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProvider.java?r1=1.23.36.6.2.6&r2=1.23.36.6.2.7

However... see issue 83464.