wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes JNDI in Enterprise application in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI in Enterprise application in Eclipse" Watch "JNDI in Enterprise application in Eclipse" New topic
Author

JNDI in Enterprise application in Eclipse

playa carmen
Greenhorn

Joined: May 07, 2009
Posts: 1
I just started using Eclipse and is a little puzzled byt the way it sets up a Java Enterprise Application.

The EJB project (ejb beans) works and I packaged it into a jar and deployed it to JBoss - works fine and builds tables in the MySql DB based on the notations. I am experienced in this.

I do have a problem from a client - a seperat project in Eclipse- I create an InitialContext, but it does not seem to construct with the environment from the server. I have tried having a jndi.properties file in the same path and also to put it directly into the constructor using a populated Properties with the right properties.

It keeps giving me an Exception - not that it cannot find the lookup object, but the following:

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

Does anyone here know about Eclipse and how it sets up the JNDI entries, and what it expects here and where?
Thanks
hareendran dileep
Greenhorn

Joined: May 07, 2009
Posts: 6

Did you try adding the server jars in the classpath (runtime)?
Marty Fried
Greenhorn

Joined: Feb 10, 2009
Posts: 18
Pardon me for butting in, but I came to ask about the same problem (I think).

I've been trying to get a simple stateless session bean (EJB3) to work, a calculator that has one function, add, that takes 2 doubles and returns a double. I've tried it using Eclipse and Netbeans, on Windows and linux. I've tried every tip I could find, and I've even resorted to reading the documentation! I'm using Glassfish v2.1, and I can see the JNDI name in the admin page, which changes when I change the directives for JNDI.

I've tried adding some of the jar files I've seen suggested, like appserv-rt.jar and a few others that I've seen recommended, but nothing seems to help. I'm not even sure where the problem is, except that it's triggered by the client's lookup call, and the exceptions are all related to corba, jndi, naming context, iiop, etc. I get lots of exceptions in Eclipse on Windows, although only in NetBeans on linux did I get the one like the original post.

I'll keep trying, and post back if I find out anything, but if anyone thinks they might be able to help, I'd be grateful for any tips. This is basically an assignment for a java ee class I'm taking, but the instructor only told us how to do it in the lab using jBuilder 2005 EE with its own app server, EJB2, and jvm 1.3 or 1.4; and it didn't work due to some problem with the licensing. But I'd like to avoid having to go to the computer lab to do it, as it's primitive; we can't even save our work, so we need to reconfigure everything every time we use it.

Meanwhile, I'm going to try setting up a commandline environment and do it all that way so I'll know exactly what's going on.

-- Marty Fried
Left Coast, USA
Marty Fried
Greenhorn

Joined: Feb 10, 2009
Posts: 18
Solution (?)

A classmate got his working using an article at webagesolutions.com website.

I had used it as a guide without success, but this time, I uninstalled Glassfish v2.1, and installed v1 like they used in the article. Their example worked, so I then loaded my project, and it, too, worked as originally written. I'm not sure if there is a problem with v2.1, or if it was simply something to do with the installation, but I'm pretty happy with the fact that I now understand how to install, start, and stop it from the command line, and I feel more in control. I'm still using jre 6 and Eclipse 3.4 (with a Glassfish plugin), unlike the article.

I also found that I did not have to add anything to the remote client's class path, even though the article said to add javaee.jar and appserv-rt.jar. Also, instead of adding those two jar files to the server project, I added the Glassfish lib directory, which contained those files. This eliminated a warning about the files not being exported as expected (but not required).

Marty Fried
Greenhorn

Joined: Feb 10, 2009
Posts: 18
playa carmen wrote:...
Does anyone here know about Eclipse and how it sets up the JNDI entries, and what it expects here and where?
Thanks

I don't know if this will help, but I'm pretty sure this has nothing to do with Eclipse. It's all either Java or the container (JBoss). You should read the JBoss documentation on how to set it up. It's done with either directives (starting with "@") or by a configuration file, probably xml.

The server I'm learning on, Glassfish, has a JNDI browser in the admin console, where it displays all the JNDI names, confirming that the name you expect is there.

Sorry, I have no experience so far with JBoss.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JNDI in Enterprise application in Eclipse