Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

ejb myclipse weblogic error

Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm using ejb 2 with myeclipse 9 and weblogic 9 . i'm learning java ee. was trying to use myeclipse.just testing with ejb2 have not yet started ejb3. getting following error when i run my client app.

Exception in thread "main" 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
at javax.naming.spi.NamingManager.getInitialContext(
at javax.naming.InitialContext.getDefaultInitCtx(
at javax.naming.InitialContext.getURLOrDefaultInitCtx(
at javax.naming.InitialContext.lookup(
at WishClient.main(

my files

import java.rmi.RemoteException;

public interface Wish
extends javax.ejb.EJBObject
public String getMonthName() throws RemoteException;
public String getDayName() throws RemoteException;
public String generateWishMsg(String name) throws RemoteException;

public interface WishHome
extends javax.ejb.EJBHome
// public static final String COMP_NAME="java:comp/env/ejb/Wish";
// public static final String JNDI_NAME="Wish";

public Wish create()
throws javax.ejb.CreateException,java.rmi.RemoteException;


import java.util.*;
import javax.naming.*;
public class WishClient {

public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
Hashtable ht= new Hashtable();

InitialContext ic = new InitialContext();
WishHome hor=(WishHome)ic.lookup("WishJndi");
Wish eor=hor.create();
System.out.println("Week Day Name =" +eor.getDayName());
System.out.println("Month Name =" +eor.getMonthName());
System.out.println("Wish Message =" +eor.generateWishMsg("Raj"));


import java.rmi.RemoteException;

import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import java.util.*;

public class WishBean implements SessionBean {

/** The session context */
private SessionContext context;

public void ejbCreate(){

public WishBean() {
// TODO Auto-generated constructor stub

public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub


public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub


public void ejbRemove() throws EJBException, RemoteException {
// TODO Auto-generated method stub


public void setSessionContext(SessionContext newContext)
throws EJBException {
context = newContext;

public String getMonthName(){
String months[]=new String[]{"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"};
Calendar cl=Calendar.getInstance();
int m=cl.get(Calendar.MONTH);
return months[m];

public String getDayName(){
String weeks[]=new String[]{"","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
Calendar cl=Calendar.getInstance();
int w=cl.get(Calendar.DAY_OF_WEEK);
return weeks[w];

public String generateWishMsg(String name) throws EJBException {
// rename and start putting your business logic here
Calendar cl=Calendar.getInstance();
int h=cl.get(Calendar.HOUR_OF_DAY);
return "Good Morning" + name;
else if(h<=16)
return "Good Afternoon" + name;
return "Good Evening" + name;



<ejb-jar >
<session >









1. can someone please tell me why i'm getting error. how should i resolve it.
2.when i'm using xdoclet to generate bean, home interface and xml files. it automatically generating jndi name. like this

public static final String COMP_NAME="java:comp/env/ejb/Wish";
public static final String JNDI_NAME="Wish";

so i commented them and used my own jndi name in weblogic -ejb-jar.xml. is it wrong to do that?. how come these variables have me declared in my home interface. why and how are they used. and i did not understand the structure --> java:comp/env/ejb/Wish .. what does it mean?. i'm a newbie . so please explain clearly.
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
    Bookmark Topic Watch Topic
  • New Topic