Buggy code:
@ RunWith ( Arquillian . class ) @ ServerSetup ( { EjbSecurityDomainSetup . class , GetCallerPrincipalTestCase . JmsQueueSetup . class } ) public class GetCallerPrincipalTestCase { private static final String QUEUE_NAME = "queue//callerPrincipal" ; private static final Logger log = Logger . getLogger ( GetCallerPrincipalTestCase . class ) ; private static final String ANONYMOUS = "anonymous" ; private static final String OK = "OK" ; public static final String LOCAL_USER = "$local" ; @ ArquillianResource Deployer deployer ; @ ArquillianResource private InitialContext initialContext ; static class JmsQueueSetup extends AbstractMgmtServerSetupTask { @ Override protected void doSetup ( final ManagementClient managementClient ) throws Exception { } @ Override public void tearDown ( final ManagementClient managementClient , final String containerId ) throws Exception { } private void createQueue ( String queueName ) throws Exception { } private void destroyQueue ( String queueName ) throws Exception { } } @ Deployment ( managed = true , testable = false , name = "single" , order = 0 ) public static Archive < ? > deploymentSingleton ( ) { } @ Deployment ( managed = false , testable = false , name = "slsb" , order = 100 ) public static Archive < ? > deploymentSlsb ( ) { } @ Deployment ( managed = false , testable = false , name = "sfsb" , order = 101 ) public static Archive < ? > deploymentSfsb ( ) { } @ Deployment ( managed = false , testable = false , name = "mdb" , order = 102 ) public static Archive < ? > deploymentMdb ( ) { } @ Deployment ( managed = false , testable = false , name = "eb" , order = 103 ) public static Archive < ? > deploymentEntityBean ( ) { } @ Deployment ( managed = true , testable = true , name = "test" , order = 3 ) public static Archive < ? > deployment ( ) { } private static ModelNode getQueueAddr ( String name ) { } private ITestResultsSingleton getResultsSingleton ( ) throws NamingException { } private SecurityClient login ( ) throws Exception { } @ Test public void testUnauthenticatedNoSecurityDomain ( ) throws Exception { } @ Test public void testStatelessLifecycle ( ) throws Exception { } @ Test public void testStatefulLifecycle ( ) throws Exception { } @ OperateOnDeployment ( "test" ) @ Test public void testMDBLifecycle ( ) throws Exception { deployer . deploy ( "mdb" ) ; SecurityClient client = this . login ( ) ; ITestResultsSingleton results = this . getResultsSingleton ( ) ; MessageProducer producer = null ; MessageConsumer consumer = null ; QueueConnection conn = null ; Session session = null ; try { <START_BUG> QueueConnectionFactory qcf = ( ( QueueConnectionFactory ) ( new InitialContext ( ) . lookup ( "java://RemoteConnectionFactory" ) ) ) ; <END_BUG> Queue queue = ( ( Queue ) ( new InitialContext ( ) . lookup ( ( "java:jboss//" + ( GetCallerPrincipalTestCase . QUEUE_NAME ) ) ) ) ) ; conn = qcf . createQueueConnection ( "guest" , "guest" ) ; conn . start ( ) ; session = conn . createQueueSession ( false , AUTO_ACKNOWLEDGE ) ; TemporaryQueue replyQueue = session . createTemporaryQueue ( ) ; TextMessage msg = session . createTextMessage ( "Hello<seq2seq4repair_space>world" ) ; msg . setJMSDeliveryMode ( NON_PERSISTENT ) ; msg . setJMSReplyTo ( replyQueue ) ; producer = session . createProducer ( queue ) ; producer . send ( msg ) ; consumer = session . createConsumer ( replyQueue ) ; Message replyMsg = consumer . receive ( 5000 ) ; Object obj = ( ( javax . jms . ObjectMessage ) ( replyMsg ) ) . getObject ( ) ; GetCallerPrincipalTestCase . log . info ( ( "MDB<seq2seq4repair_space>message<seq2seq4repair_space>get:<seq2seq4repair_space>" + obj ) ) ; Assert . assertEquals ( ( ( GetCallerPrincipalTestCase . OK ) + "start" ) , results . getMdb ( "postconstruct" ) ) ; deployer . undeploy ( "mdb" ) ; Assert . assertEquals ( ( ( GetCallerPrincipalTestCase . OK ) + "stop" ) , results . getMdb ( "predestroy" ) ) ; } finally { if ( consumer != null ) { consumer . close ( ) ; } if ( producer != null ) { producer . close ( ) ; } if ( session != null ) { session . close ( ) ; } if ( conn != null ) { conn . stop ( ) ; } client . logout ( ) ; } } @ Test public void testEBActivate ( ) throws Exception { } private < T extends EJBHome > T getHome ( final Class < T > homeClass , final String beanName ) { } private EntityBean setUpEB ( ) throws Exception { } private void tearDownEB ( EntityBean eb ) throws Exception { } }

Fix:
QueueConnectionFactory qcf = ( ( QueueConnectionFactory ) ( new InitialContext ( ) . lookup ( "java://ConnectionFactory" ) ) ) ;