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 143603 - API for JNDI name creation for different J2EE servers
Summary: API for JNDI name creation for different J2EE servers
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@javaee
URL:
Keywords: API
Depends on:
Blocks: 134983 134984
  Show dependency tree
 
Reported: 2008-08-12 12:43 UTC by pslechta
Modified: 2016-07-07 08:52 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pslechta 2008-08-12 12:43:25 UTC
It seems that JNDI naming is not part of J2EE specification and different J2EE servers use different conventions for
JNDI names. Thus JNDI lookup code generated by NetBeans does not work for all application servers. A need for new API
that can be used by code generation to generate proper JNDI lookup code for selected application server is required.

See Issue 134983 and Issue 134984 for details.
Comment 1 Vince Kraemer 2008-08-12 16:17:25 UTC
I think we have such an api already...

I noticed that the user is working with GF in the two issues that you cite.

Those issues may be a bug in the server integration plugin and/or a bug in the code that calls the server spi...

I will start to investigate.
Comment 2 pslechta 2008-10-20 12:36:27 UTC
This API should be considered for 7.0. NB do generate wrong code for the user, this is visible problem reported by
several users...
Comment 3 pslechta 2008-11-20 14:14:49 UTC
Petre, will you have a time to work on this? If not, please reassign to someone else. This enhancement will improve
quality of generated code, so I believe it should be part of NB 7.0. Thanks!
Comment 4 Petr Hejl 2008-11-20 14:23:41 UTC
I doubt I'll get to this. Anyway I think the new team should handle this.
Comment 5 Vince Kraemer 2008-12-04 00:21:02 UTC
I have been trying to replicate this issue... but I haven't been able to.

Is there a sample project that demonstrates the issue?

here is what I have tried:

create a j2ee 1.4 ent app with an ejb-jar and a web app
create an ejb with a simple echo business method.
create a servlet in the web app
call the ejb directly in the web app
   this works
create a class that uses the InitialContext.lookup to find the bean and call its echo
call the method in the new class to call teh echo method.
   this also works.

I did the same thing for a java ee 5 ent app, web-app, ejb-jar combination....

Without a set of sample projects and/or detailed valid steps that produce an invalid app, it will be very difficult to
make progress on this issue.
Comment 6 pslechta 2008-12-10 23:01:59 UTC
I tried it one more time with NB 6.5. I created enterprise app (Java EE 5) with ejb and war modules. (I can attach the
app if required).

IMHO, I believe, that the problem is the following:

1) When user generates code via Insert code > Call enterprise bean, the code does not work, because reference to the
bean is not created in web.xml. User has to edit web.xml and has to insert one record into Rererences > EJB references.
After this modification, the app works fine. So this may be automated and when the code is generated, the reference can
be added into web.xml too...

2) When the user calls EJB on remote machine, then s/he can use global JNDI names, that Glassfish provides for EJBs with
remote interfaces. This JNDI mapping is not standardized and each server does it its own way (AFAIK). See
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html for the following section:

     4. If no global JNDI name has been specified, a default global
     JNDI name will be generated according to the following table :

Bean has 2.x | Total # of 3.0  |                                                |
Home/Remote  | Remote Business | default JNDI name                              | example
interfaces   | interfaces      |                                                |
=============+=================+================================================+=====================
 No          |    0            |   n/a                                          |    n/a
 Yes         |    0            | fully-qualified name of Home interface         | com.acme.FooHome
 No          |    1            | fully-qualified name Remote Business interface | com.acme.FooBusiness
 No          |    2 or more    | No default -- JNDI name must be specified      | n/a
 Yes         |    1 or more    | No default -- JNDI name must be specified      | n/a
======================================================================================================

So when NB generate code for accessing remote EJBs via global JNDI names, the code should be generated in a different
way than in the previous case (local access via references). There should be API for each app server that will allow NB
to generate the global JNDI name in the proper form...

Please let me know what do you think about both use cases. We have around 6 duplicates where external users say that NB
generated wrong lookup code that does not work. In some cases, the problem can be fixed by defining EJB reference in
web.xml. Other cases cannot be solved this way, because user access remote EJBs (from app. client for example)...
Comment 7 David Konecny 2009-05-18 09:48:14 UTC
EJB 3.1 (JEE6) addresses this - see chapter 4.4 Global JNDI Access.
Comment 8 Martin Balin 2016-07-07 08:52:39 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss