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.");
}
}
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);
}
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));
}
}
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
}
}
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);
}
Aggregations