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.
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.
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.
This API should be considered for 7.0. NB do generate wrong code for the user, this is visible problem reported by several users...
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!
I doubt I'll get to this. Anyway I think the new team should handle this.
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.
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)...
EJB 3.1 (JEE6) addresses this - see chapter 4.4 Global JNDI Access.
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