Search in sources :

Example 41 with NameNotFoundException

use of javax.naming.NameNotFoundException in project wildfly by wildfly.

the class EEConcurrentManagementTestCase method testManagedExecutorServiceManagement.

@Test
public void testManagedExecutorServiceManagement() throws Exception {
    final PathAddress pathAddress = EE_SUBSYSTEM_PATH_ADDRESS.append(EESubsystemModel.MANAGED_EXECUTOR_SERVICE, RESOURCE_NAME);
    // add
    final ModelNode addOperation = Util.createAddOperation(pathAddress);
    final String jndiName = "java:jboss/ee/concurrency/executor/" + RESOURCE_NAME;
    addOperation.get(ManagedExecutorServiceResourceDefinition.JNDI_NAME).set(jndiName);
    addOperation.get(ManagedExecutorServiceResourceDefinition.CORE_THREADS).set(2);
    final ModelNode addResult = managementClient.getControllerClient().execute(addOperation);
    Assert.assertFalse(addResult.get(FAILURE_DESCRIPTION).toString(), addResult.get(FAILURE_DESCRIPTION).isDefined());
    try {
        // lookup
        Assert.assertNotNull(new InitialContext().lookup(jndiName));
    } finally {
        // remove
        final ModelNode removeOperation = Util.createRemoveOperation(pathAddress);
        removeOperation.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
        final ModelNode removeResult = managementClient.getControllerClient().execute(removeOperation);
        Assert.assertFalse(removeResult.get(FAILURE_DESCRIPTION).toString(), removeResult.get(FAILURE_DESCRIPTION).isDefined());
        try {
            new InitialContext().lookup(jndiName);
            Assert.fail();
        } catch (NameNotFoundException e) {
        // expected
        }
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 42 with NameNotFoundException

use of javax.naming.NameNotFoundException in project wildfly by wildfly.

the class SimpleSLSB method isUnInjectedIntEnvEntryPresentInEnc.

public boolean isUnInjectedIntEnvEntryPresentInEnc() {
    Context ctx = null;
    try {
        ctx = new InitialContext();
        ctx.lookup("java:comp/env/missingEnvEntryValIntResource");
        return true;
    } catch (NameNotFoundException nnfe) {
        return false;
    } catch (NamingException ne) {
        throw new RuntimeException(ne);
    }
}
Also used : InitialContext(javax.naming.InitialContext) DirContext(javax.naming.directory.DirContext) SessionContext(javax.ejb.SessionContext) Context(javax.naming.Context) LdapContext(javax.naming.ldap.LdapContext) NameNotFoundException(javax.naming.NameNotFoundException) NamingException(javax.naming.NamingException) InitialContext(javax.naming.InitialContext)

Example 43 with NameNotFoundException

use of javax.naming.NameNotFoundException in project wildfly by wildfly.

the class SimpleSLSB method isUnInjectedStringEnvEntryPresentInEnc.

public boolean isUnInjectedStringEnvEntryPresentInEnc() {
    Context ctx = null;
    try {
        ctx = new InitialContext();
        ctx.lookup("java:comp/env/missingEnvEntryValStringResource");
        return true;
    } catch (NameNotFoundException nnfe) {
        return false;
    } catch (NamingException ne) {
        throw new RuntimeException(ne);
    }
}
Also used : InitialContext(javax.naming.InitialContext) DirContext(javax.naming.directory.DirContext) SessionContext(javax.ejb.SessionContext) Context(javax.naming.Context) LdapContext(javax.naming.ldap.LdapContext) NameNotFoundException(javax.naming.NameNotFoundException) NamingException(javax.naming.NamingException) InitialContext(javax.naming.InitialContext)

Example 44 with NameNotFoundException

use of javax.naming.NameNotFoundException in project wildfly by wildfly.

the class AbstractCustomDescriptorTests method test1.

@Test
public void test1() throws NamingException {
    final InitialContext ctx = new InitialContext();
    try {
        final DescriptorGreeterBean bean = (DescriptorGreeterBean) ctx.lookup("java:global/ejb-descriptor-test/DescriptorGreeter!org.jboss.as.test.integration.ejb.descriptor.DescriptorGreeterBean");
        final String name = "test1";
        final String result = bean.greet(name);
        assertEquals("Hi test1", result);
    } catch (NameNotFoundException e) {
        fail(e.getMessage());
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 45 with NameNotFoundException

use of javax.naming.NameNotFoundException in project wildfly by wildfly.

the class CustomDescriptorTestCase method testAnnotated.

//    @EJB
//    private DescriptorGreeterBean bean;
@Test
public void testAnnotated() throws NamingException {
    final InitialContext ctx = new InitialContext();
    try {
        final AnnotatedGreeterBean bean = (AnnotatedGreeterBean) ctx.lookup("java:global/ejb-descriptor-test/AnnotatedGreeter!org.jboss.as.test.integration.ejb.descriptor.AnnotatedGreeterBean");
        final String name = "testAnnotated";
        final String result = bean.greet(name);
        assertEquals("Hi testAnnotated", result);
    } catch (NameNotFoundException e) {
        fail(e.getMessage());
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

NameNotFoundException (javax.naming.NameNotFoundException)112 InitialContext (javax.naming.InitialContext)56 Context (javax.naming.Context)51 NamingException (javax.naming.NamingException)51 Test (org.junit.Test)36 Name (javax.naming.Name)33 Reference (javax.naming.Reference)27 NotContextException (javax.naming.NotContextException)24 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)23 CompositeName (javax.naming.CompositeName)22 Binding (javax.naming.Binding)21 OperationNotSupportedException (javax.naming.OperationNotSupportedException)21 CompoundName (javax.naming.CompoundName)16 NamingContext (org.eclipse.jetty.jndi.NamingContext)12 IOException (java.io.IOException)11 InvalidNameException (javax.naming.InvalidNameException)7 ContainerSystem (org.apache.openejb.spi.ContainerSystem)7 ArrayList (java.util.ArrayList)6 LinkRef (javax.naming.LinkRef)6 Properties (java.util.Properties)5