Search in sources :

Example 1 with NoSuchObjectException

use of java.rmi.NoSuchObjectException in project jdk8u_jdk by JetBrains.

the class NotSerializable method main.

public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4460983\n");
    Activatable act = new FakeActivatable();
    try {
        ObjectOutputStream out = new ObjectOutputStream(new ByteArrayOutputStream());
        try {
            out.writeObject(act);
            throw new RuntimeException("TEST FAILED: " + "Activatable instance successfully serialized");
        } catch (NotSerializableException e) {
            System.err.println("NotSerializableException as expected:");
            e.printStackTrace();
        }
        // other exceptions cause test failure
        System.err.println("TEST PASSED");
    } finally {
        try {
            Activatable.unexportObject(act, true);
        } catch (NoSuchObjectException e) {
        }
    }
}
Also used : NotSerializableException(java.io.NotSerializableException) Activatable(java.rmi.activation.Activatable) NoSuchObjectException(java.rmi.NoSuchObjectException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream)

Example 2 with NoSuchObjectException

use of java.rmi.NoSuchObjectException in project jdk8u_jdk by JetBrains.

the class NoIIOP method main.

public static void main(String[] args) throws Exception {
    try {
        Class.forName("javax.management.remote.rmi._RMIConnectionImpl_Tie");
        System.out.println("RMI/IIOP appears to be supported, test skipped");
        return;
    } catch (ClassNotFoundException okay) {
    }
    JMXServiceURL url = new JMXServiceURL("service:jmx:iiop://");
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
    try {
        JMXConnectorFactory.connect(url);
        throw new RuntimeException("connect did not throw MalformedURLException");
    } catch (MalformedURLException expected) {
    }
    try {
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, null);
        throw new RuntimeException("newJMXConnectorServer did not throw MalformedURLException");
    } catch (MalformedURLException expected) {
    }
    // test RMIConnector/RMIConnectorServer
    RMIConnector connector = new RMIConnector(url, null);
    try {
        connector.connect();
        throw new RuntimeException("connect did not throw IOException");
    } catch (IOException expected) {
    }
    RMIConnectorServer server = new RMIConnectorServer(url, null, mbs);
    try {
        server.start();
        throw new RuntimeException("start did not throw IOException");
    } catch (IOException expected) {
    }
    // test RMIIIOPServerImpl
    MyRMIIIOPServerImpl impl = new MyRMIIIOPServerImpl();
    impl.setMBeanServer(mbs);
    System.out.println(impl.getProtocol());
    try {
        impl.export();
        throw new RuntimeException("export did not throw IOException");
    } catch (IOException expected) {
    }
    try {
        impl.newClient(null);
        throw new RuntimeException("newClient did not throw IOException");
    } catch (IOException expected) {
    }
    try {
        impl.toStub();
        throw new RuntimeException("toStub did not throw NoSuchObjectException");
    } catch (NoSuchObjectException expected) {
    }
    try {
        impl.closeServer();
        throw new RuntimeException("closeServer did not throw NoSuchObjectException");
    } catch (NoSuchObjectException expected) {
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) NoSuchObjectException(java.rmi.NoSuchObjectException) IOException(java.io.IOException) MBeanServer(javax.management.MBeanServer)

Example 3 with NoSuchObjectException

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

the class IIOPNamingInContainerTestCase method testStatefulIIOPNamingInvocation.

@Test
@OperateOnDeployment("test")
public void testStatefulIIOPNamingInvocation() throws NamingException, RemoteException, RemoveException {
    final Properties prope = new Properties();
    final InitialContext context = new InitialContext(prope);
    final Object iiopObj = context.lookup("corbaname:iiop:" + managementClient.getMgmtAddress() + ":3528#IIOPStatefulNamingBean");
    final IIOPStatefulNamingHome object = (IIOPStatefulNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPStatefulNamingHome.class);
    final IIOPStatefulRemote result = object.create(10);
    Assert.assertEquals(11, result.increment());
    Assert.assertEquals(12, result.increment());
    result.remove();
    try {
        result.increment();
        Assert.fail("Expected NoSuchObjectException");
    } catch (NoSuchObjectException expected) {
    }
}
Also used : PortableRemoteObject(javax.rmi.PortableRemoteObject) NoSuchObjectException(java.rmi.NoSuchObjectException) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 4 with NoSuchObjectException

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

the class IIOPNamingTestCase method testStatefulIIOPNamingInvocation.

@Test
public void testStatefulIIOPNamingInvocation() throws NamingException, RemoteException, RemoveException {
    final Properties prope = new Properties();
    prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
    prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() + ":3528/NameService");
    final InitialContext context = new InitialContext(prope);
    final Object iiopObj = context.lookup("IIOPStatefulNamingBean");
    final IIOPStatefulNamingHome object = (IIOPStatefulNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPStatefulNamingHome.class);
    final IIOPStatefulRemote result = object.create(10);
    Assert.assertEquals(11, result.increment());
    Assert.assertEquals(12, result.increment());
    result.remove();
    try {
        result.increment();
        Assert.fail("Expected NoSuchObjectException");
    } catch (NoSuchObjectException expected) {
    }
}
Also used : PortableRemoteObject(javax.rmi.PortableRemoteObject) NoSuchObjectException(java.rmi.NoSuchObjectException) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 5 with NoSuchObjectException

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

the class IIOPNamingTestCase method testStatefulIIOPNamingCorbanameInvocation.

@Test
public void testStatefulIIOPNamingCorbanameInvocation() throws NamingException, RemoteException, RemoveException {
    final Properties prope = new Properties();
    prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
    prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() + ":3528");
    final InitialContext context = new InitialContext(prope);
    final Object iiopObj = context.lookup("IIOPStatefulNamingBean");
    final IIOPStatefulNamingHome object = (IIOPStatefulNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPStatefulNamingHome.class);
    final IIOPStatefulRemote result = object.create(10);
    Assert.assertEquals(11, result.increment());
    Assert.assertEquals(12, result.increment());
    result.remove();
    try {
        result.increment();
        Assert.fail("Expected NoSuchObjectException");
    } catch (NoSuchObjectException expected) {
    }
}
Also used : PortableRemoteObject(javax.rmi.PortableRemoteObject) NoSuchObjectException(java.rmi.NoSuchObjectException) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

NoSuchObjectException (java.rmi.NoSuchObjectException)25 Test (org.junit.Test)8 PortableRemoteObject (javax.rmi.PortableRemoteObject)7 RemoteException (java.rmi.RemoteException)6 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