0 Replies Latest reply on Sep 1, 2005 2:15 AM by Kurt Jia

    java.lang.NullPointerException at org.jboss.ejb.plugins.loca

    Kurt Jia Newbie

      Hi all,
      my environment is :
      os:windowxp
      jboss:jboss4.0.2
      tomcat:jboss-4.0.2\server\default\deploy\jbossweb-tomcat55.sar

      i depoyed web application on jboss-4.0.2\server\default\deploy\test.war
      when i access the ejb use localhome have the follow exception:

      09:41:22,577 INFO [STDOUT] at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:118)
      09:41:22,577 INFO [STDOUT] at $Proxy79.create(Unknown Source)
      09:41:22,577 INFO [STDOUT] at com.d3.common.ejbproxy.impl.ServiceProxyEJBLocalImpl.getService(ServiceProxyEJBLocalImpl.java:107)
      09:41:22,577 INFO [STDOUT] at com.d3.common.ejbproxy.impl.ServiceProxyEJBLocalImpl.doService(ServiceProxyEJBLocalImpl.java:51)

      follow is my source code:

      public EventResponse doService(D3biValueObject valueObject,String serviceNameID, String methodName)
      {
      logger.info("doService begin. ");
      BaseEvent baseEvent = new BaseEvent();

      baseEvent.setBeanKeyRef(serviceNameID);
      baseEvent.setMethodName(methodName);
      baseEvent.setValueObject(valueObject);

      EventResponse responseEvent = null;
      D3biServiceLocal d3biServiceLocal = getService("d3bi/ejb/D3biServiceBeanLocal") ;
      responseEvent = d3biServiceLocal.doBusiness(baseEvent);

      //responseEvent = Util.doService(baseEvent, Constants.beanFactory);
      logger.info("doService end. ");
      return responseEvent;
      }

      public EJBLocalHome getLocalHome(String s)
      {
      logger.info("getLocalHome begin. ");
      logger.info("getLocalHome jndi is " + s);
      EJBLocalHome ejblocalhome = null;
      try
      {
      Hashtable properties = new Hashtable();
      properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      properties.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");

      ejblocalhome = (EJBLocalHome) new InitialContext(properties).lookup(s);

      } catch (NamingException namingexception)
      {
      namingexception.printStackTrace() ;
      throw new ServiceException(namingexception.getMessage());
      } catch (Exception exception)
      {
      exception.printStackTrace() ;
      throw new ServiceException(exception.getMessage());
      }
      logger.info("getLocalHome end. ");
      return ejblocalhome;
      }

      public D3biServiceLocal getService(String s)
      {
      logger.info("getService begin. ");
      D3biServiceLocal obj = null;
      try
      {
      D3biServiceLocalHome ejblocalhome = (D3biServiceLocalHome)getLocalHome(s);
      logger.info("Service Local Home JNDI: " + s);
      logger.info("Service Local Home: " + ejblocalhome.getClass().getName());
      logger.info("Service Local Home create before ");

      //Method method = ejblocalhome.getClass().getDeclaredMethod("create", null);
      // obj = (D3biServiceLocal)method.invoke(ejblocalhome, null);

      if(ejblocalhome == null)
      {
      logger.info("###############ejblocalhome is null ");
      }else
      {
      logger.info("###############ejblocalhome is not not not null ");
      }
      obj = ejblocalhome.create() ;
      logger.info("Service Local Home create end ");
      if(obj == null)
      {
      logger.info("###############Service Local is null ");
      }
      }
      catch(Exception ex)
      {
      logger.info("###############error : " + ex.getMessage());
      ex.printStackTrace() ;
      throw new ServiceException("Exception", ex);
      }
      logger.info("getService end. ");
      return obj;
      }

      expected reply,tanks!