ctx初始化不正确,试试这样
Properties props =new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL,"127.0.0.1:1099");
System.out.println("start to create context!");
Context ctx = new InitialContext(props);
//org.jnp.interfaces.NamingContextFactory这句话是jboss的,如果你用的是weblogic的话换成weblogic的代码

解决方案 »

  1.   

    weblogic的初始化ctx
          Properties h = new Properties();
          h.put(Context.INITIAL_CONTEXT_FACTORY,
            "weblogic.jndi.WLInitialContextFactory");
          h.put(Context.PROVIDER_URL, url);
          ctx = new InitialContext(props);
      

  2.   

    不是<%的错
    楼上上的!
    Properties h = new Properties();
    h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    h.put(Context.PROVIDER_URL, "t3://127.0.0.1:7001");
    ctx = new InitialContext(h);
    LoginSessionLocalHome home = (LoginSessionLocalHome)ctx.lookup("sample.LoginSessionLocalHome");
    LoginSessionLocal loginSessionLocal = home.create();
    也不成,还是那个错误高手们快!
      

  3.   

    是你的ejb没有发布起来,看看配置文件是否正确。ejb-jar.xml,weblogic-ejb-jar.xml
      

  4.   

    怎么没发布起来?
    http://expert.csdn.net/Expert/TopicView1.asp?id=2223563
    这个也是我的帖子,这个是不是就是发布成功了呢?
      

  5.   

    试这样的,你这里是在jsp中调用ejb的本地接口,这样是不可以的
    你如果真的要这样的话,你必须将*.war and *.jar打到一个*.ear中发布
    这样就可在JSP中调用EJB的本地接口了。
    哦----如果不行的话,web.xml你还是要加一些东西的如果你不这样你需要修改web.xml文件,或是使用远程接口
      

  6.   

    我帮你
    LoginSessionLocalHome home = (LoginSessionLocalHome)ctx.lookup("sample.LoginSessionLocalHome");
    then 
    System.out.println("Test home exist =========" + home);
    测试
      

  7.   

    LoginSessionLocalHome home = (LoginSessionLocalHome)ctx.lookup("sample.LoginSessionLocalHome");
    寻找本地接口不是这样的吧??
    LoginSessionLocalHome home = (LoginSessionLocalHome)ctx.lookup("LoginSession");
    // LoginSession 是你的EJB 的名称是在jsp中调用ejb的本地接口,这样是不可以的??
    可以的吧!!只要是在同一个 JVM 中!
      

  8.   

    还有
    请将jar包和war包打入ear包中,发布ear
      

  9.   

    Properties h = new Properties();
    h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    h.put(Context.PROVIDER_URL, "t3://127.0.0.1:7001");
    ctx = new InitialContext(h);
    LoginSessionLocalHome home = (LoginSessionLocalHome)ctx.lookup("sample.LoginSessionLocalHome");
    这个方法也要加入的
    Context ctx = null;
    ctx = new InitialContext();
    不对的