title: Error : Need to specify class name in environment or system property
body: <p>I'm new in development of Java EE applications and I'm really confused about this. I've found so many answers but I can't resolve my problem.</p>
  
  <p>This is the error:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>And this is my code : </p>
  
  <pre><code>public class Test {
  
      public static void main(String[] args) {
          List&lt;Auto_2G&gt; auto2 = new ArrayList&lt;Auto_2G&gt;();
          GestionCellRef2GRemote t = null;
          Context contxt=null ;
          //GestionCellRefDualmodeRemote p = null;
          //Auto_Dualmode autodualmode = new Auto_Dualmode();
          FileInputStream file=null;
          HSSFWorkbook classeur=null ;
          HSSFSheet feuille=null;
          Row roww=null;
  
          try {
              try {
                  contxt = new InitialContext();
              } catch(NamingException e) {
  
              }
              t = (GestionCellRef2GRemote) contxt.lookup("/webpfe/GestionCellRef2G!tn.orange.pfe.services.GestionCellRef2GR emote");
              file= new FileInputStream(new File("test.xls"));
              classeur = new HSSFWorkbook(file);
              feuille = classeur.getSheetAt(0);
              int i=1;
  
              while(roww!=null) {
                  roww=feuille.getRow(i);
  
                  for (Auto_2G auto2g:auto2) {
                      auto2g.setBSC_Name(roww.getCell(0).getStringCellValue());
                      auto2g.setBTS_NAME(roww.getCell(2).getStringCellValue());
                      auto2g.setCELL_NAME(roww.getCell(4).getStringCellValue());
  
                      t.ajout2G(auto2g);
                  }
                  i++;
              }
              file.close();
          } catch (Exception e) {
              System.out.println("erreur"+e);
          }
  
          for(Auto_2G auto2g:auto2){
          System.out.println(auto2g.getId());
      }
  </code></pre>
  
  <p>And this is my <em>JNDI.properties</em> file:</p>
  
  <pre><code>java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
  java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
  java.naming.provider.url=http-remoting://localhost:8181
  jboss.naming.client.ejb.context=true
  jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
  </code></pre>
  
  <hr>
  
  <pre><code>log4j:WARN No appenders could be found for logger (org.jboss.logging).
  log4j:WARN Please initialize the log4j system properly.
  log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
  javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.IllegalArgumentException: XNIO001001: No XNIO provider found]
      at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:51)
      at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:152)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
      at javax.naming.InitialContext.init(InitialContext.java:244)
      at javax.naming.InitialContext.&lt;init&gt;(InitialContext.java:216)
      at tn.orange.pfe.test.Test.main(Test.java:41)
  Caused by: java.lang.IllegalArgumentException: XNIO001001: No XNIO provider found
      at org.xnio.Xnio.doGetInstance(Xnio.java:226)
      at org.xnio.Xnio.getInstance(Xnio.java:192)
      at org.jboss.naming.remote.client.EndpointCache.get(EndpointCache.java:47)
      at org.jboss.naming.remote.client.InitialContextFactory.createEndpoint(InitialContextFactory.java:226)
      at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateEndpoint(InitialContextFactory.java:207)
      at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:170)
      at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:146)
      ... 5 more
  java.lang.NullPointerException
      at tn.orange.pfe.test.Test.main(Test.java:46)
  erreurjava.lang.NullPointerException
  </code></pre>