title: Configuring Custom Login Realm and Module on a Standalone Glassfish through DAS
body: <p>I have a working custom login realm (provided by a third-party) for Glassfish 3.1.1. I've successfully deployed and configured it through the admin console on a single Glassfish instance on my workstation by dropping the loginmodule jar into domains/domainname/lib folder. Works with the webapp and everything.</p>
  
  <p>Now I'm trying to deploy the application onto a bit more complicated setup. Consider the following three servers:</p>
  
  <pre><code>DAS: Admin server instance with domain
  
  FRONT1: Standalone node instance configured through DAS
  
  SERVICE1: Standalone node instance configured through DAS
  </code></pre>
  
  <p>I have dropped the loginmodule jar into nodes/front1/lib folder (on FRONT1 server). I have separate Configurations for each instance on DAS named front1_config and service1_config. I'm trying to add a new Realm with admin console through Configurations -> front1_config -> Security -> Realms but I get the following error:</p>
  
  <p>Web:</p>
  
  <pre><code>Creation of Authrealm custom-realm failed. java.lang.NullPointerException
  </code></pre>
  
  <p>The DAS server log:</p>
  
  <pre><code>[#|2011-11-01T14:22:18.258+0200|SEVERE|glassfish3.1.1|org.glassfish.admingui|_ThreadID=23;_ThreadName=Thread-2;|RestResponse.getResponse() gives FAILURE.  endpoint = 'https://localhost:4848/management/domain/configs/config/front1-config/security-service/auth-realm'; attrs = '{classname=com.mycompany.loginmodule.MyLoginRealm, name=custom-card, target=front1-config, property=}'|#]
  </code></pre>
  
  <p>I suspect this might be a problem with the placement of loginmodule.jar. Or maybe the NullPointerException is thrown from the loginmodule itself? I have tried numerous approaches, even copying the jar into glassfish/lib on both FRONT1 and DAS but nothing seems to work.</p>
  
  <p>I'm at my wit's end here.</p>
  
  <p>EDIT: I found out a bit more. I'd appeared to have copied the loginmodule jar also to the DAS servers domain/lib. When I removed the loginmodule jar from there, the NullpointerException did not appear and I just get a ClassNotFoundException:</p>
  
  <pre><code>Creation of Authrealm custom-realm failed.
  com.sun.enterprise.security.auth.realm.BadRealmException:
  java.lang.ClassNotFoundException:
  com.mycompany.loginmodule.MyLoginRealm not found by org.glassfish.security [117]
  </code></pre>