• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB 3.0 JNDI Exception

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jitendra,

I recommend you try using "java:comp/env/ejb/Account" in the lookup instead of just "Account".
 
reply
    Bookmark Topic Watch Topic
  • New Topic