title: 401 exception in java code
body: <p>I am working on drools and my following code </p>
  
  <pre><code>import org.drools.RuleBase;
  import org.drools.agent.RuleAgent;
  import org.drools.definition.type.FactType;
  
  public class MortgageApplicationTest {
      /**
       * @param args
       * @throws IllegalAccessException
       * @throws InstantiationException
       */
      public static void main(String[] args) throws InstantiationException, IllegalAccessException {
  
          RuleAgent agent = RuleAgent.newRuleAgent("/mortgageapproval.properties");
          RuleBase rb = agent.getRuleBase();
  
          FactType appType = rb.getFactType("mortgages.LoanApplication");
          FactType incomeType = rb.getFactType("mortgages.IncomeSource");
  
          Object application = appType.newInstance();
          Object income = incomeType.newInstance();
  
          appType.set(application, "amount", 25000);
          appType.set(application, "deposit", 1500);
          appType.set(application, "lengthYears", 20);
  
          incomeType.set(income, "type", "Job");
          incomeType.set(income, "amount", 65000);
  
  
          rb.newStatelessSession().execute(new Object[] {application, income});
  
          System.out.println(application);
      }
  
  }
  </code></pre>
  
  <p>Following is my mortgageapproval.properties file </p>
  
  <pre><code>url=http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST
  userName=admin
  password=admin
  </code></pre>
  
  <p>This whole code setup Is throwing following 401 error</p>
  
  <pre><code>RuleAgent(default) INFO (Tue Apr 26 11:03:25 IST 2011): Configuring with newInstance=true, secondsToRefresh=-1
  RuleAgent(default) INFO (Tue Apr 26 11:03:25 IST 2011): Configuring package provider : URLScanner monitoring URLs:  http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST
  RuleAgent(default) EXCEPTION (Tue Apr 26 11:03:25 IST 2011): Server returned HTTP response code: 401 for URL: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST. Stack trace should follow.
  java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1403)
      at org.drools.agent.HttpClientImpl.fetchPackage(HttpClientImpl.java:50)
      at org.drools.agent.URLScanner.readPackage(URLScanner.java:148)
      at org.drools.agent.URLScanner.getChangeSet(URLScanner.java:120)
      at org.drools.agent.URLScanner.loadPackageChanges(URLScanner.java:96)
      at org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:410)
      at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:362)
      at org.drools.agent.RuleAgent.configure(RuleAgent.java:347)
      at org.drools.agent.RuleAgent.init(RuleAgent.java:247)
      at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:187)
      at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:147)
      at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:256)
      at com.notidiots.MortgageApplicationTest.main(MortgageApplicationTest.java:19)
  Exception in thread "main" java.lang.NullPointerException
  </code></pre>
  
  <p>.... I have given authentication only at tomcat's component.xml file which is as follows</p>
  
  <pre><code>&lt;role rolename="manager-gui"/&gt;
  &lt;user username="tomcat" password="tomcat" roles="manager-gui"/&gt;
  
  &lt;role rolename="admin"/&gt;
  &lt;user username="admin" password="admin" roles="admin"/&gt;
  </code></pre>
  
  <p>In my drools' component.xml following line shows I have not given any authentication</p>
  
  <pre><code>&lt;!-- NO authentication. This will bypass the login screen when you hit the app. Everyone is "guest" --&gt;
  
  &lt;security:identity authenticate-method="#{nilAuthenticator.authenticate}"/&gt;
  </code></pre>
  
  <p>Please help me out since there are not many drools developer are there... I am not getting required help.... </p>
  
  <p>thanks in advance</p>