aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB 3.0 JNDI Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB 3.0 JNDI Exception" Watch "EJB 3.0 JNDI Exception" New topic
Author

EJB 3.0 JNDI Exception

Jetendra Ivaturi
Ranch Hand

Joined: Feb 08, 2007
Posts: 159
Hi All...

I am getting a JNDI exception when am I trying to work sample EJB application. Here is the error what I am getting when I am trying to call the client.

javax.naming.NameNotFoundException: Unable to resolve 'Account'. Resolved '' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'Account'. Resolved '']; remaining name 'Account'


The code what I have written is below:

1. package com.common;

import javax.ejb.Remote;

@Remote
public interface Account {
public void printHello();
}


2.Account Bean Class

package com.common;

import javax.ejb.Remote;
import javax.ejb.Stateless;

@Stateless(name="Account")
@Remote(Account.class)
public class AccountBean implements Account {
public AccountBean() {}

public void printHello() {
System.out.println("Hello");
}

}


3. Client Program

package com.intecbilling.dcp.test;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import com.Account;

public class Client {

/**
* @param args
*/
public static void main(String[] args) {
InitialContext ctx;
try {
Hashtable<String,String> env = new Hashtable<String,String>();
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");

System.out.println("Creating InitalContext");
ctx = new InitialContext(env);

/* Account account = (Account) ctx.lookup("Account");
account.printHello();*/

Object obj = ctx.lookup("Account");
Account account = (Account) PortableRemoteObject.narrow(obj, Account.class);
account.printHello();

} catch (NamingException e) {
e.printStackTrace();
}

}
}



Could any one help in this. I am using weblogic 10. To deploy this application.

Thanks and Regards

Jetendra


SCJP 1.4 & 1.5, SCWCD 1.5. Learn and Let Learn.
Shailesh Kini
Ranch Hand

Joined: Oct 17, 2001
Posts: 153
Hi Jitendra,

I recommend you try using "java:comp/env/ejb/Account" in the lookup instead of just "Account".


Shailesh Kini.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB 3.0 JNDI Exception