lookup problem

Hi,

I just started to use J2EE trying to develop a J2EE application. For getting a better understanding of what happens in the background I try to split the whole process of developing the J2EE application into single steps such as developing, packaging, deploying and running.

Instead of using NetBeans which does all the work in a quite opaque way I am using Eclipse as IDE and the Sun Java Application Server (installed locally) to run my Session Beans and Entity Beans in.

For getting my beans deployed I am creating an EAR library containing the library of my beans (containing EJB classes, remote interface, persistence.xml and sun-ejb-jar.xml) and the required META-INF directory containing the files application.xml (with the name of my library) and sun-application.xml.

I put my EAR file into the autodeploy directory of the application server and the library appears under "Enterprise Applications" as it should. The problem occurs when I try to access the remote interface with the lookup command while running the application client with:

Object ref = jndiContext.lookup("com.titan.travelagent.TravelAgentRemote");

I get an exception:

javax.naming.NameNotFoundException: com.titan.travelagent.TravelAgentRemote not found

I had a look at EAR files created by NetBeans to get an idea what is going on. The structure of those libraries is exactly the same. The only difference is... those work.

Reading the book "Enterprise Beans 3.0" does not give me any more hints. Does anybody know what I am doing wrong?

[1578 byte] By [silverferna] at [2007-11-27 6:24:50]
# 1
Hi,I am sorry not ever having used Sun Java AS. Only JBoss. With JBoss, by default, you will find your EJB as basename of EAR-file plus Classname plus "remote" or "local", e.g. for yourear.ear:java:yourear/YourBean/remote... Michael
michaelhhha at 2007-7-12 17:44:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

The manner in which global JNDI names are assigned to EJBs is vendor-specific.Many

implementations use the fully-qualified name of the Remote interface as the global JNDI name

if no JNDI name has been explicitly configured.Check to see if the code generated by NetBeans

has assigned a JNDI name already.This could be done either by using the mappedName() element

of @Stateless/@Stateful or by using the sun-ejb-jar.xml file.

There's a complete description of how global JNDI names are assigned within SUN's EJB

implementation here :

https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#SessionBeanGlobalJNDINameAssignment

--ken

ksaksa at 2007-7-12 17:44:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

I solved it!

The error did not have any relation to the lookup command. The error was due to a problem in using the entity bean I implemented.

To get to the source of the problem I did the following:

I undeployed the NetBeans Application. Then I took the EAR library of that application and tried to deploy it on my own. - Successful

I tried to use their code to create the NetBeans Application from Eclipse. So I created an EAR file in the way NetBeans did and deployed it ?Successful

Then I tried it with my own application again, taking away all the fancy stuff such as entity bean, persistence.xml and so on. - Successful

Then I activated things that I took away beforehand one by one. As soon as I included the persistence.xml into the EAR file it didn抰 work anymore. The known error message appeared on the screen. Sun Application Server failed to deploy my beans because it was unable to bind the entity bean to its installed JDBC Resource. I didn抰 expect this since it deployed beautifully without a persistence.xml. I was still able to run the application client as long as I didn抰 touch any database access methods.

I should have looked into the log a long time before. It was a little bit tricky because I thought the problem is related to JNDI.

I guess I tricked myself in a quite awful way?br>

Thanks for your help,

Stephan

silverferna at 2007-7-12 17:44:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...