context没有初始化好,你用的应用服务器是什么的?

解决方案 »

  1.   

    WEBLOGIC6.1啊
    是不是我的JNDI的命名没在System.getProperties里呢,还是要找WEBLOGIC的。象这样
     
      private AccountHome lookupHome()
        throws NamingException
      {
        Context ctx = getInitialContext();
       
        try {
          Object home = ctx.lookup("beanManaged.AccountHome");
          return (AccountHome) PortableRemoteObject.narrow(home, AccountHome.class);
     
        } catch (NamingException ne) {
          log("The client was unable to lookup the EJBHome.  Please make sure " +
          "that you have deployed the ejb with the JNDI name " + 
          "beanManaged.AccountHome on the WebLogic server at "+url);
     
          throw ne;
        }
      }
     
      /**
       * Get an initial context into the JNDI tree.
       *
       * Java2 clients can use the jndi.properties file to set the
       * INITIAL_CONTEXT_FACTORY and the PROVIDER_URL
       *  private Context getInitialContext() throws NamingException {
       *    return new InitialContext();
       *  }
       *
       *
       * Using a Properties object will work on JDK 1.1.x and Java2
       * clients
       */
      private Context getInitialContext() throws NamingException {
        
        try {
          // Get an InitialContext
          Properties h = new Properties();
          h.put(Context.INITIAL_CONTEXT_FACTORY,
            "weblogic.jndi.WLInitialContextFactory");
          h.put(Context.PROVIDER_URL, url);
          return new InitialContext(h);
        } catch (NamingException ne) {
          log("We were unable to get a connection to the WebLogic server at "+url);
          log("Please make sure that the server is running.");
          throw ne;
        }
      }
      private String url;
      
      private AccountHome home;
     
      public Client(String url)
        throws NamingException
      {
     
        this.url       = url;
        
        home = lookupHome();
      }    String url       = "t3://localhost:7001";
     
      

  2.   

    context 没有初始化好,具体是不是weblogic没有配置好啊 ,我以前也碰见这样的 情况,好好 检查你的 连接池什么的配置。
      

  3.   

    to    wjmmml(笑着悲伤) (  ) 
    按你说的做拉,还是有问题啊,
    javax.naming.NameNotFoundException: Unable to resolve h. Resolved: '' Unresolved:'h' ; remaining name '' at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:85) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:253) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:220) at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35) at $Proxy0.lookup(Unknown Source) at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323) at javax.naming.InitialContext.lookup(InitialContext.java:350) at test.hClient.main(hClient.java:43)Exception in thread "main" 
    我的是这么写的Object obj = ctx.lookup("hHome");而且在WEB下,EJB的图标和叙述都很正常