Index: security-spi/common/common-spi.iml
===================================================================
--- security-spi/common/common-spi.iml	(revision 444)
+++ security-spi/common/common-spi.iml	(working copy)
@@ -3,10 +3,10 @@
   <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
     <output url="file://$MODULE_DIR$/target/classes" />
     <output-test url="file://$MODULE_DIR$/target/test-classes" />
+    <exclude-output />
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
-      <excludeFolder url="file://$MODULE_DIR$/../common-spi/target" />
       <excludeFolder url="file://$MODULE_DIR$/target" />
     </content>
     <orderEntry type="inheritedJdk" />
Index: security-spi/common/src/main/java/org/jboss/security/PicketBoxLogger.java
===================================================================
--- security-spi/common/src/main/java/org/jboss/security/PicketBoxLogger.java	(revision 444)
+++ security-spi/common/src/main/java/org/jboss/security/PicketBoxLogger.java	(working copy)
@@ -688,4 +688,7 @@
     @Message(id = 366, value = "Error parsing time out number.")
     void errorParsingTimeoutNumber();
 
-}
\ No newline at end of file
+    @LogMessage(level = Logger.Level.ERROR)
+    @Message(id = 367, value = "Failed to find constructor for default security context class %s")
+    void failedToFindConstructorForDefaultSecurityContextClass(Class defaultSecurityContextClass, @Cause Exception e);
+}
Index: security-spi/spi/src/main/java/org/jboss/security/SecuritySPIActions.java
===================================================================
--- security-spi/spi/src/main/java/org/jboss/security/SecuritySPIActions.java	(revision 444)
+++ security-spi/spi/src/main/java/org/jboss/security/SecuritySPIActions.java	(working copy)
@@ -31,26 +31,39 @@
  *  @version $Revision$
  */
 class SecuritySPIActions
-{  
+{
+
+    public static final PrivilegedAction<ClassLoader> GET_CONTEXT_CLASS_LOADER = new PrivilegedAction<ClassLoader>()
+    {
+        public ClassLoader run()
+        {
+            return Thread.currentThread().getContextClassLoader();
+        }
+    };
+
    static ClassLoader getContextClassLoader()
    {
-      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() 
+      if(System.getSecurityManager() == null) {
+        return Thread.currentThread().getContextClassLoader();
+      } else
       {
-         public ClassLoader run()
-         {
-           return Thread.currentThread().getContextClassLoader();
-         }
-      });
+        return AccessController.doPrivileged(GET_CONTEXT_CLASS_LOADER);
+      }
    }
    
    static ClassLoader getCurrentClassLoader(final Class clazz)
    {
-      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+      if(System.getSecurityManager() == null) {
+          return clazz.getClassLoader();
+      } else
       {
-         public ClassLoader run()
-         {
-            return clazz.getClassLoader();
-         }
-      });
+          return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+          {
+             public ClassLoader run()
+             {
+                return clazz.getClassLoader();
+             }
+          });
+      }
    }
-}
\ No newline at end of file
+}
Index: security-spi/spi/src/main/java/org/jboss/security/SecurityContextFactory.java
===================================================================
--- security-spi/spi/src/main/java/org/jboss/security/SecurityContextFactory.java	(revision 444)
+++ security-spi/spi/src/main/java/org/jboss/security/SecurityContextFactory.java	(working copy)
@@ -35,12 +35,15 @@
  */
 @SuppressWarnings("unchecked")
 public class SecurityContextFactory
-{      
+{
+   private static final Class[] CONSTRUCTOR_TYPES = new Class[]{String.class};
+
    private static String defaultFQN = "org.jboss.security.plugins.JBossSecurityContext";
    
    private static String defaultUtilClassFQN = "org.jboss.security.plugins.JBossSecurityContextUtil";
    
    private static Class<? extends SecurityContext> defaultSecurityContextClass = null;
+   private static Constructor<SecurityContext> defaultSecurityContextConstructor = null;
    private static Class<? extends SecurityContextUtil> defaultUtilClass = null;
    
    /**
@@ -77,6 +80,13 @@
          {
          }
       }
+      if(defaultSecurityContextClass != null) {
+          try {
+              defaultSecurityContextConstructor = (Constructor<SecurityContext>) defaultSecurityContextClass.getConstructor(CONSTRUCTOR_TYPES);
+          } catch (Exception e)
+          {
+          }
+      }
    }
 
    /**
@@ -87,12 +97,14 @@
     */
    public static SecurityContext createSecurityContext(String securityDomain) throws Exception
    {
+      if(defaultSecurityContextConstructor != null)
+         return createSecurityContext(securityDomain, defaultSecurityContextConstructor);
       if(defaultSecurityContextClass != null)
-         return createSecurityContext(securityDomain, defaultSecurityContextClass);
+          return createSecurityContext(securityDomain, defaultSecurityContextClass);
       return createSecurityContext(securityDomain, defaultFQN, SecuritySPIActions.getCurrentClassLoader(SecurityContextFactory.class));
    }
-   
-   /**
+
+    /**
     * Create a security context 
     * @param securityDomain Security Domain driving the context
     * @param classLoader ClassLoader to use
@@ -101,6 +113,8 @@
     */
    public static SecurityContext createSecurityContext(String securityDomain, ClassLoader classLoader) throws Exception
    {
+      if(defaultSecurityContextConstructor != null)
+         return createSecurityContext(securityDomain, defaultSecurityContextConstructor);
       if(defaultSecurityContextClass != null)
          return createSecurityContext(securityDomain, defaultSecurityContextClass);
       return createSecurityContext(securityDomain, defaultFQN, classLoader);
@@ -135,7 +149,8 @@
       if(fqnClass == null)
          throw PicketBoxMessages.MESSAGES.invalidNullArgument("fqnClass");
       defaultSecurityContextClass = getContextClass(fqnClass, classLoader);
-      return createSecurityContext(securityDomain, defaultSecurityContextClass);
+      defaultSecurityContextConstructor = (Constructor<SecurityContext>) defaultSecurityContextClass.getConstructor(CONSTRUCTOR_TYPES);
+      return createSecurityContext(securityDomain, defaultSecurityContextConstructor);
    }
    
    
@@ -156,9 +171,19 @@
        if(clazz == null)
          throw PicketBoxMessages.MESSAGES.invalidNullArgument("clazz");
       //Get the CTR
-      Constructor<? extends SecurityContext> ctr = clazz.getConstructor(new Class[]{String.class});
-      return (SecurityContext) ctr.newInstance(new Object[]{securityDomain}); 
+      Constructor<? extends SecurityContext> ctr = clazz.getConstructor(CONSTRUCTOR_TYPES);
+      return (SecurityContext) ctr.newInstance(securityDomain);
    }
+
+
+   private static SecurityContext createSecurityContext(String securityDomain, Constructor<SecurityContext> constructor) throws Exception
+   {
+       if(securityDomain == null)
+           throw PicketBoxMessages.MESSAGES.invalidNullArgument("security domain");
+       if(constructor == null)
+           throw PicketBoxMessages.MESSAGES.invalidNullArgument("constructor");
+       return (SecurityContext) constructor.newInstance(securityDomain);
+   }
    
    /**
     * Create a security context
@@ -350,4 +375,4 @@
          return (Class<SecurityContext>) tcl.loadClass(className);
       }
    }
-}
\ No newline at end of file
+}
