Getting local interface from java:comp/env. Big Problems

A

Anonymous

Hi, im using Websphere studio application developer.

I have an EJB bean HelloWorldEntity (from the websphere j2ee hello
world tutorial) with an interface ive made called
HelloWorldEntityLocalHome.

In the application client descriptor editor I selected references (for
HelloWorldEntity)
added a Local reference, ejb/HelloWorldEntityLocal
in the Websphere Bindings section of the references page I put in
JNDI name: ejb/helloworld/ejb/HelloWorldEntityLocalHome
the source looks like this.
<ejb-local-ref id="EJBLocalRef_1098353324662">
<ejb-ref-name>ejb/HelloWorldEntityLocal</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>helloworld.ejb.HelloWorldEntityLocalHome</local-home>
<local>helloworld.ejb.HelloWorldEntityLocal</local>
<ejb-link>HelloWorldEntity</ejb-link>
</ejb-local-ref>

Then I delete any servers and right click HelloWorldEJB project and
click run on server, generating deployment code, creating a new server
and creating tables and data sources.

Then I try this code from the application client...
System.out.println("Performing the lookup..");
InitialContext initContext = new
InitialContext();
HelloWorldEntityLocalHome helloWorldEntityLocalHome =
(HelloWorldEntityLocalHome)initContext.lookup("java:comp/env/ejb/HelloWorldEntityLocal");
HelloWorldEntityLocal helloWorldEntityLocal =
helloWorldEntityLocalHome.create(3);
System.out.println("lookup successful.");


I get javax.naming.NameNotFoundException: Name
"comp/env/ejb/HelloWorldEntityLocal" not found in context "java:".

The only thing found to be successful is putting a ejbref remote
reference in the application client descriptor and accessing the
remote beans.
But the remote beans dont have the relationship related methods I need
for my other, much larger and more complex project that has multiple
entitys & relationships. Note that you can not add ejb local
references to the client deployment descriptor.

Anyone know how to fix this so I can get the local home interface? ive
tried absolutely everything and any help would be appreciated.

Thanks in advance,
Robbie Cahill
(a very frustrated programmer).








Here is my full application client code.

public class HelloWorldEJBTestClient {

public static void main(String[] args) {

String firstNameParam = "John";
String lastNameParam = "Smith";
int id = 100;

// Perform the lookup
HelloWorldEntityHome helloEntityHome = null;
try {
System.out.println("Performing the lookup..");
InitialContext initContext = new
InitialContext();
HelloWorldEntityLocalHome helloWorldEntityLocalHome =
(HelloWorldEntityLocalHome)
initContext.lookup("java:comp/env/ejb/HelloWorldEntityLocal");
HelloWorldEntityLocal helloWorldEntityLocal =
helloWorldEntityLocalHome.create(3);
System.out.println("lookup successful.");
} catch (javax.naming.NamingException e) {
System.out.println("Whoops! Error retrieving the home interface: "
+ e);
e.printStackTrace();
System.exit(0);
} catch (Exception e) {

System.out.println(e);
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top