Search in sources :

Example 11 with NoSuchObjectException

use of java.rmi.NoSuchObjectException in project camel by apache.

the class DefaultManagementAgent method doStop.

protected void doStop() throws Exception {
    // close JMX Connector, if it was created
    if (cs != null) {
        try {
            cs.stop();
            LOG.debug("Stopped JMX Connector");
        } catch (IOException e) {
            LOG.debug("Error occurred during stopping JMXConnectorService: " + cs + ". This exception will be ignored.");
        }
        cs = null;
    }
    // Unexport JMX RMI registry, if it was created
    if (registry != null) {
        try {
            UnicastRemoteObject.unexportObject(registry, true);
            LOG.debug("Unexported JMX RMI Registry");
        } catch (NoSuchObjectException e) {
            LOG.debug("Error occurred while unexporting JMX RMI registry. This exception will be ignored.");
        }
    }
    if (mbeansRegistered.isEmpty()) {
        return;
    }
    // Using the array to hold the busMBeans to avoid the CurrentModificationException
    ObjectName[] mBeans = mbeansRegistered.keySet().toArray(new ObjectName[mbeansRegistered.size()]);
    int caught = 0;
    for (ObjectName name : mBeans) {
        try {
            unregister(name);
        } catch (Exception e) {
            LOG.info("Exception unregistering MBean with name " + name, e);
            caught++;
        }
    }
    if (caught > 0) {
        LOG.warn("A number of " + caught + " exceptions caught while unregistering MBeans during stop operation." + " See INFO log for details.");
    }
}
Also used : NoSuchObjectException(java.rmi.NoSuchObjectException) IOException(java.io.IOException) NoSuchObjectException(java.rmi.NoSuchObjectException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) RemoteException(java.rmi.RemoteException) JMException(javax.management.JMException) ObjectName(javax.management.ObjectName)

Example 12 with NoSuchObjectException

use of java.rmi.NoSuchObjectException in project camel by apache.

the class JmxInstrumentationWithConnectorTest method testRmiRegistryUnexported.

public void testRmiRegistryUnexported() throws Exception {
    Registry registry = LocateRegistry.getRegistry(registryPort);
    // before we stop the context the registry is still exported, so list() should work
    Exception e;
    try {
        registry.list();
        e = null;
    } catch (NoSuchObjectException nsoe) {
        e = nsoe;
    }
    assertNull(e);
    // stop the Camel context
    context.stop();
    // stopping the Camel context unexported the registry, so list() should fail
    Exception e2;
    try {
        registry.list();
        e2 = null;
    } catch (NoSuchObjectException nsoe) {
        e2 = nsoe;
    }
    assertNotNull(e2);
}
Also used : NoSuchObjectException(java.rmi.NoSuchObjectException) LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry) NoSuchObjectException(java.rmi.NoSuchObjectException)

Example 13 with NoSuchObjectException

use of java.rmi.NoSuchObjectException in project wildfly by wildfly.

the class StubStrategy method writeParams.

/**
     * Marshals the sequence of method parameters into an output stream.
     *
     * @param out    a CDR output stream
     * @param params an object array with the parameters.
     */
public void writeParams(OutputStream out, Object[] params) {
    int len = params.length;
    if (len != paramWriters.length) {
        throw IIOPLogger.ROOT_LOGGER.errorMashalingParams();
    }
    for (int i = 0; i < len; i++) {
        Object param = params[i];
        if (param instanceof PortableRemoteObject) {
            try {
                param = PortableRemoteObject.toStub((Remote) param);
            } catch (NoSuchObjectException e) {
                throw new RuntimeException(e);
            }
        }
        paramWriters[i].write(out, RemoteObjectSubstitutionManager.writeReplaceRemote(param));
    }
}
Also used : Remote(java.rmi.Remote) PortableRemoteObject(javax.rmi.PortableRemoteObject) NoSuchObjectException(java.rmi.NoSuchObjectException) PortableRemoteObject(javax.rmi.PortableRemoteObject)

Example 14 with NoSuchObjectException

use of java.rmi.NoSuchObjectException in project wildfly by wildfly.

the class ReferenceAnnotationDescriptorTestCase method testStatefulRemove.

@Test
public void testStatefulRemove() throws Exception {
    InitialContext jndiContext = new InitialContext();
    StatefulSession30Home home = (StatefulSession30Home) jndiContext.lookup("java:module/StatefulSession30!" + StatefulSession30Home.class.getName());
    Assert.assertNotNull(home);
    StatefulSession30 session = home.create();
    Assert.assertNotNull(session);
    session.setValue("123");
    String value = session.getValue();
    Assert.assertEquals("123", value);
    EJBObject ejbObject = session;
    Handle handle = session.getHandle();
    Assert.assertNotNull(handle);
    home.remove(handle);
    try {
        session.getValue();
        Assert.assertTrue(false);
    } catch (NoSuchObjectException nsoe) {
    // OK: EJB3.1 7.5.3
    }
    session = home.create();
    Assert.assertNotNull(session);
    session.setValue("123");
    value = session.getValue();
    Assert.assertEquals("123", value);
    session.remove();
    try {
        session.getValue();
        Assert.assertTrue(false);
    } catch (NoSuchObjectException nsoe) {
    // OK: EJB3.1 7.5.3
    }
}
Also used : EJBObject(javax.ejb.EJBObject) NoSuchObjectException(java.rmi.NoSuchObjectException) InitialContext(javax.naming.InitialContext) HomeHandle(javax.ejb.HomeHandle) Handle(javax.ejb.Handle) Test(org.junit.Test)

Example 15 with NoSuchObjectException

use of java.rmi.NoSuchObjectException in project wildfly by wildfly.

the class RemoveMethodUnitTestCase method testExplicitExtensionEjbObjectInProxy.

@Test
public void testExplicitExtensionEjbObjectInProxy() throws Exception {
    // Obtain stub
    Object obj = ctx.lookup("java:app/" + ANNOTATION_BASED_MODULE_NAME + "/" + Ejb21ViewBean.class.getSimpleName() + "!" + Ejb21ViewHome.class.getName());
    Ejb21ViewHome home = (Ejb21ViewHome) PortableRemoteObject.narrow(obj, Ejb21ViewHome.class);
    Ejb21View session = home.create();
    // Ensure EJBObject
    Assert.assertTrue(session instanceof EJBObject);
    // Cast and remove appropriately, ensuring removed
    boolean removed = false;
    String result = session.test();
    Assert.assertEquals(Ejb21ViewBean.TEST_STRING, result);
    session.remove();
    try {
        session.test();
    } catch (Exception e) {
        if (e instanceof NoSuchObjectException || e.getCause() instanceof NoSuchObjectException) {
            removed = true;
        } else {
            Assert.fail("Exception received, " + e + ", was not expected and should have had root cause of " + NoSuchObjectException.class);
        }
    }
    Assert.assertTrue("SFSB instance was not removed as expected", removed);
}
Also used : EJBObject(javax.ejb.EJBObject) EJBObject(javax.ejb.EJBObject) PortableRemoteObject(javax.rmi.PortableRemoteObject) NoSuchObjectException(java.rmi.NoSuchObjectException) NoSuchObjectException(java.rmi.NoSuchObjectException) Test(org.junit.Test)

Aggregations

NoSuchObjectException (java.rmi.NoSuchObjectException)22 Test (org.junit.Test)8 PortableRemoteObject (javax.rmi.PortableRemoteObject)7 RemoteException (java.rmi.RemoteException)5 InitialContext (javax.naming.InitialContext)5 IOException (java.io.IOException)4 Properties (java.util.Properties)4 EJBObject (javax.ejb.EJBObject)4 EJBAccessException (javax.ejb.EJBAccessException)3 ApplicationException (org.apache.openejb.ApplicationException)3 BeanContext (org.apache.openejb.BeanContext)3 OpenEJBException (org.apache.openejb.OpenEJBException)3 SystemException (org.apache.openejb.SystemException)3 EjbTransactionUtil.createTransactionPolicy (org.apache.openejb.core.transaction.EjbTransactionUtil.createTransactionPolicy)3 TransactionPolicy (org.apache.openejb.core.transaction.TransactionPolicy)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Remote (java.rmi.Remote)2 ActivationException (java.rmi.activation.ActivationException)2 EJBException (javax.ejb.EJBException)2 EntityBean (javax.ejb.EntityBean)2