Buggy code:
public class KerberosServerSetupTask implements ServerSetupTask { private static final Logger LOGGER = Logger . getLogger ( KerberosServerSetupTask . class ) ; public static final String SECURITY_CREDENTIALS = "secret" ; public static final String SECURITY_PRINCIPAL = "uid=admin,ou=system" ; private static final String KRB5_CONF_RESOURCE_FILENAME = "krb5.conf" ; private static final String KRB5_CONF_1_FILENAME = "krb5-server1.conf" ; public static final File KRB5_CONF_FILE = new File ( KerberosServerSetupTask . KRB5_CONF_1_FILENAME ) ; public static final int LDAP_PORT = 10389 ; public static final int LDAPS_PORT = 10636 ; public static final int KERBEROS_PORT = 6088 ; public static final String KERBEROS_PRIMARY_REALM = "JBOSS.ORG" ; public static final String [ ] ROLE_NAMES = new String [ ] { "TheDuke" , "Echo" , "Admin" , "SharedRoles" , "RX" } ; public static final String QUERY_ROLES ; private boolean removeBouncyCastle = false ; private String origKrb5Conf ; private String origKrbDebug ; private DirectoryService directoryService1 ; private LdapServer ldapServer1 ; private KdcServer krbServer1 ; public void setup ( ManagementClient managementClient , String containerId ) throws Exception { } @ CreateDS ( name = "JBossDS" , partitions = { @ CreatePartition ( name = "jboss" , suffix = "dc=jboss,dc=org" , contextEntry = @ ContextEntry ( entryLdif = "dn:<seq2seq4repair_space>dc=jboss,dc=org\n" + ( ( "dc:<seq2seq4repair_space>jboss\n" + "objectClass:<seq2seq4repair_space>top\n" ) + "objectClass:<seq2seq4repair_space>domain\n\n" ) ) , indexes = { @ CreateIndex ( attribute = "objectClass" ) , @ CreateIndex ( attribute = "dc" ) , @ CreateIndex ( attribute = "ou" ) } ) } , additionalInterceptors = { KeyDerivationInterceptor . class } ) @ CreateLdapServer ( transports = { @ CreateTransport ( protocol = "LDAP" , port = KerberosServerSetupTask . LDAP_PORT ) } , certificatePassword = "secret" ) @ CreateKdcServer ( primaryRealm = KerberosServerSetupTask . KERBEROS_PRIMARY_REALM , kdcPrincipal = ( ( "krbtgt//" + ( KerberosServerSetupTask . KERBEROS_PRIMARY_REALM ) ) + "@" ) + ( KerberosServerSetupTask . KERBEROS_PRIMARY_REALM ) , searchBaseDn = "dc=jboss,dc=org" , transports = { @ CreateTransport ( protocol = "UDP" , port = KerberosServerSetupTask . KERBEROS_PORT ) , @ CreateTransport ( protocol = "TCP" , port = KerberosServerSetupTask . KERBEROS_PORT ) } ) public void createLdap1 ( ManagementClient managementClient , final String hostname ) throws FileNotFoundException , IOException , ClassNotFoundException , Exception { final Map < String , String > map = new HashMap < String , String > ( ) ; final String cannonicalHost = KerberosServerSetupTask . getCannonicalHost ( managementClient ) ; final String cannonicalIp = KerberosServerSetupTask . getFullCannonicalIp ( managementClient ) ; map . put ( "hostname" , cannonicalHost ) ; map . put ( "hostaddr" , cannonicalIp ) ; map . put ( "realm" , KerberosServerSetupTask . KERBEROS_PRIMARY_REALM ) ; directoryService1 = DSAnnotationProcessor . getDirectoryService ( ) ; final String ldifContent = StrSubstitutor . replace ( IOUtils . toString ( KerberosServerSetupTask . class . getResourceAsStream ( ( ( KerberosServerSetupTask . class . getSimpleName ( ) ) + ".ldif" ) ) , "UTF-8" ) , map ) ; KerberosServerSetupTask . LOGGER . debug ( ldifContent ) ; final SchemaManager schemaManager = directoryService1 . getSchemaManager ( ) ; try { for ( LdifEntry ldifEntry : new LdifReader ( IOUtils . toInputStream ( ldifContent ) ) ) { directoryService1 . getAdminSession ( ) . add ( new org . apache . directory . api . ldap . model . entry . DefaultEntry ( schemaManager , ldifEntry . getEntry ( ) ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; throw e ; } final ManagedCreateLdapServer createLdapServer = new ManagedCreateLdapServer ( ( ( CreateLdapServer ) ( AnnotationUtils . getInstance ( CreateLdapServer . class ) ) ) ) ; fixTransportAddress ( createLdapServer , cannonicalHost ) ; ldapServer1 = ServerAnnotationProcessor . instantiateLdapServer ( createLdapServer , directoryService1 ) ; <START_BUG> krbServer1 = KDCServerAnnotationProcessor . getKdcServer ( directoryService1 , KerberosServerSetupTask . KERBEROS_PORT ) ; <END_BUG> ldapServer1 . start ( ) ; KerberosServerSetupTask . createKrb5Conf ( cannonicalHost , KerberosServerSetupTask . KRB5_CONF_FILE , KerberosServerSetupTask . KERBEROS_PORT ) ; } public static String getHttpServicePrincipal ( ManagementClient managementClient ) { } public static String getFullCannonicalIp ( ManagementClient managementClient ) { } public static String getCannonicalHost ( ManagementClient managementClient ) { } private static void createKrb5Conf ( final String hostname , final File outputFile , int port ) throws FileNotFoundException , IOException { } private void fixTransportAddress ( ManagedCreateLdapServer createLdapServer , String address ) { } public void tearDown ( ManagementClient managementClient , String containerId ) throws Exception { } public static class SystemPropertiesSetup extends AbstractSystemPropertiesServerSetupTask { @ Override protected SystemProperty [ ] getSystemProperties ( ) { } } }

Fix:
krbServer1 = KDCServerAnnotationProcessor . getKdcServer ( directoryService1 , KerberosServerSetupTask . KERBEROS_PORT , cannonicalHost ) ;