Java Code Examples for java.rmi.RemoteException#printStackTrace()

The following examples show how to use java.rmi.RemoteException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterUSRTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "bindData")
public void UnicastServerRef(String name, Object obj, int expectedFilterCount) throws RemoteException {
    try {
        RemoteImpl impl = RemoteImpl.create();
        UnicastServerRef ref = new UnicastServerRef(new LiveRef(0), impl.checker);

        Echo client = (Echo) ref.exportObject(impl, null, false);

        int count = client.filterCount(obj);
        System.out.printf("count: %d, obj: %s%n", count, obj);
        Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
    } catch (RemoteException rex) {
        if (expectedFilterCount == -1 &&
                UnmarshalException.class.equals(rex.getCause().getClass()) &&
                InvalidClassException.class.equals(rex.getCause().getCause().getClass())) {
            return; // normal expected exception
        }
        rex.printStackTrace();
        Assert.fail("unexpected remote exception", rex);
    } catch (Exception ex) {
        Assert.fail("unexpected exception", ex);
    }
}
 
Example 2
Source File: FilterUSRTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "bindData")
public void UnicastServerRef(String name, Object obj, int expectedFilterCount) throws RemoteException {
    try {
        RemoteImpl impl = RemoteImpl.create();
        UnicastServerRef ref = new UnicastServerRef(new LiveRef(0), impl.checker);

        Echo client = (Echo) ref.exportObject(impl, null, false);

        int count = client.filterCount(obj);
        System.out.printf("count: %d, obj: %s%n", count, obj);
        Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
    } catch (RemoteException rex) {
        if (expectedFilterCount == -1 &&
                UnmarshalException.class.equals(rex.getCause().getClass()) &&
                InvalidClassException.class.equals(rex.getCause().getCause().getClass())) {
            return; // normal expected exception
        }
        rex.printStackTrace();
        Assert.fail("unexpected remote exception", rex);
    } catch (Exception ex) {
        Assert.fail("unexpected exception", ex);
    }
}
 
Example 3
Source File: FilterUSRTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "bindData")
public void UnicastServerRef(String name, Object obj, int expectedFilterCount) throws RemoteException {
    try {
        RemoteImpl impl = RemoteImpl.create();
        UnicastServerRef ref = new UnicastServerRef(new LiveRef(0), impl.checker);

        Echo client = (Echo) ref.exportObject(impl, null, false);

        int count = client.filterCount(obj);
        System.out.printf("count: %d, obj: %s%n", count, obj);
        Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
    } catch (RemoteException rex) {
        if (expectedFilterCount == -1 &&
                UnmarshalException.class.equals(rex.getCause().getClass()) &&
                InvalidClassException.class.equals(rex.getCause().getCause().getClass())) {
            return; // normal expected exception
        }
        rex.printStackTrace();
        Assert.fail("unexpected remote exception", rex);
    } catch (Exception ex) {
        Assert.fail("unexpected exception", ex);
    }
}
 
Example 4
Source File: GumballMonitor.java    From head-first-design-patterns-Java with MIT License 5 votes vote down vote up
public void report() {
    try {
        System.out.println("Gumball Machine: " + machine.getLocation());
        System.out.println("Current inventory: " + machine.getCount() + " gumballs");
        System.out.println("Current state: " + machine.getState());
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
Example 5
Source File: StatelessEjbObjectTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test06_remove() {
    String str = null;
    try {
        str = ejbObject.remove("Hello");
    } catch (final RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    assertEquals("Hello", str);
}
 
Example 6
Source File: TcpClientEngine.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {

    MethodHolder methodHolder = new MethodHolder(method.getName(),
            (args == null) ? 0 : args.length);

    Object object = hashtable.get(methodHolder);
    if (object != null) {
        return method.invoke(object, args);
    }

    CallParameters parameters = new CallParameters(method.getName(), args);

    try {
        CallResult result;
        result = invocker.invoke(parameters);

        for (EventHolder holder : result.holder.getEvents()) {
            callEvent(holder, true);
        }

        if (result.exception != null)
            throw result.exception;
        return result.result;
    } catch (RemoteException e) {
        e.printStackTrace();
        remoteException(e);
    }
    return null;
}
 
Example 7
Source File: StatefulEjbObjectTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test05_remove() {
    String str = null;
    try {
        str = ejbObject.remove("Hello");
    } catch (final RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    assertEquals("Hello", str);
}
 
Example 8
Source File: RMIClientAccessRules.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean canDeleteQualifier(long qualifierId) {
    try {
        return deligate.canDeleteQualifier(qualifierId);
    } catch (RemoteException e) {
        remoteException(e);
        e.printStackTrace();
        throw new ClientException(e);
    }
}
 
Example 9
Source File: StockToStockWithShareHolderTrendMapperTest.java    From XueQiuSuperSpider with MIT License 5 votes vote down vote up
@Test
public void testRangeFunc() throws RemoteException {
    List<Stock> stocks = TestCaseGenerator.generateStocks();
    StockToStockWithShareHolderTrendMapper mapper = new StockToStockWithShareHolderTrendMapper();

    int count1 = stocks.stream()
            .map(mapper.andThen(Stock::getShareHoldersTrend).andThen(Trend::getHistory))
            .mapToInt(List::size).reduce(Integer::sum).getAsInt();

    Calendar calendar = Calendar.getInstance();
    calendar.set(2014, Calendar.AUGUST, 5);
    Date since = calendar.getTime();

    calendar.set(2015, Calendar.MAY, 28);
    Date until = calendar.getTime();

    StockToStockWithShareHolderTrendMapper rangeMapper =
            null;
    try {
        rangeMapper = new StockToStockWithShareHolderTrendMapper(since, until);
    } catch (RemoteException e) {
        e.printStackTrace();
    }

    int count2 = stocks.stream()
            .map(rangeMapper.andThen(Stock::getShareHoldersTrend).andThen(Trend::getHistory))
            .mapToInt(List::size).reduce(Integer::sum).getAsInt();

    Assert.assertTrue(count2 < count1);

}
 
Example 10
Source File: ChatRoom.java    From ChatRoomFX with MIT License 5 votes vote down vote up
public void setUsername(String username){
    this.username=username;
    System.out.println(this.username);
    try {
        controller.updateClientList();
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
Example 11
Source File: SessionStub.java    From JVoiceXML with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public ErrorEvent getLastError() {
    final RemoteSession session = getSkeleton(sessionID);
    try {
        return session.getLastError();
    } catch (RemoteException e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 12
Source File: TCPEndpointReadBug.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public I echo(I intf) {
    try {
        return  (I)UnicastRemoteObject
            .exportObject(new C(),0, new CSF(), RMISocketFactory.getDefaultSocketFactory());
    } catch (RemoteException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 13
Source File: ClientFactory.java    From core with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Just for debugging.
 * 
 * @param args
 */
public static void main(String args[]) {
	String agencyId = "testProjectId";

	Hello hello = ClientFactory.getInstance(agencyId, Hello.class);
	try {
		String result = hello.concat("s1", "s2");
		System.err.println("result=" + result);
	} catch (RemoteException e) {
		e.printStackTrace();
	}
}
 
Example 14
Source File: TLCServerMXWrapper.java    From tlaplus with MIT License 5 votes vote down vote up
public String getSpecName() {
	if (tlcServer.isRunning()) {
		try {
			return tlcServer.getSpecFileName();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	return "N/A";
}
 
Example 15
Source File: ESBJAVA1857TestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public static void main(String[] ar) {

        ESBJAVA1857TestCase case1 = new ESBJAVA1857TestCase();
        try {
            case1.testSample2();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
 
Example 16
Source File: MapNullValuesTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        int errorCount = 0;

        MapNullValuesTest test = new MapNullValuesTest();

        // Create an RMI registry
        //
        echo("");
        echo(dashedMessage("Start RMI registry"));
        Registry reg = null;
        port = 7500;
        while (port++ < 7550) {
            try {
                reg = LocateRegistry.createRegistry(port);
                echo("\nRMI registry running on port " + port);
                break;
            } catch (RemoteException e) {
                // Failed to create RMI registry...
                //
                echo("\nFailed to create RMI registry on port " + port);
                e.printStackTrace(System.out);
            }
        }
        if (reg == null) {
            System.exit(1);
        }

        // Run tests
        //
        errorCount += test.mapToHashtableTests();
        errorCount += test.jmxConnectorServerFactoryTests();
        errorCount += test.jmxConnectorFactoryTests();
        errorCount += test.nullKeyFactoryTests();

        if (errorCount == 0) {
            echo("\nNull values for key/value pairs in Map Tests PASSED!");
        } else {
            echo("\nNull values for key/value pairs in Map Tests FAILED!");
            System.exit(1);
        }
    }
 
Example 17
Source File: MapNullValuesTest.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        int errorCount = 0;

        MapNullValuesTest test = new MapNullValuesTest();

        // Create an RMI registry
        //
        echo("");
        echo(dashedMessage("Start RMI registry"));
        Registry reg = null;
        port = 7500;
        while (port++ < 7550) {
            try {
                reg = LocateRegistry.createRegistry(port);
                echo("\nRMI registry running on port " + port);
                break;
            } catch (RemoteException e) {
                // Failed to create RMI registry...
                //
                echo("\nFailed to create RMI registry on port " + port);
                e.printStackTrace(System.out);
            }
        }
        if (reg == null) {
            System.exit(1);
        }

        // Run tests
        //
        errorCount += test.mapToHashtableTests();
        errorCount += test.jmxConnectorServerFactoryTests();
        errorCount += test.jmxConnectorFactoryTests();
        errorCount += test.nullKeyFactoryTests();

        if (errorCount == 0) {
            echo("\nNull values for key/value pairs in Map Tests PASSED!");
        } else {
            echo("\nNull values for key/value pairs in Map Tests FAILED!");
            System.exit(1);
        }
    }
 
Example 18
Source File: MapNullValuesTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        int errorCount = 0;

        MapNullValuesTest test = new MapNullValuesTest();

        // Create an RMI registry
        //
        echo("");
        echo(dashedMessage("Start RMI registry"));
        Registry reg = null;
        port = 7500;
        while (port++ < 7550) {
            try {
                reg = LocateRegistry.createRegistry(port);
                echo("\nRMI registry running on port " + port);
                break;
            } catch (RemoteException e) {
                // Failed to create RMI registry...
                //
                echo("\nFailed to create RMI registry on port " + port);
                e.printStackTrace(System.out);
            }
        }
        if (reg == null) {
            System.exit(1);
        }

        // Run tests
        //
        errorCount += test.mapToHashtableTests();
        errorCount += test.jmxConnectorServerFactoryTests();
        errorCount += test.jmxConnectorFactoryTests();
        errorCount += test.nullKeyFactoryTests();

        if (errorCount == 0) {
            echo("\nNull values for key/value pairs in Map Tests PASSED!");
        } else {
            echo("\nNull values for key/value pairs in Map Tests FAILED!");
            System.exit(1);
        }
    }
 
Example 19
Source File: MapNullValuesTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        int errorCount = 0;

        MapNullValuesTest test = new MapNullValuesTest();

        // Create an RMI registry
        //
        echo("");
        echo(dashedMessage("Start RMI registry"));
        Registry reg = null;
        port = 7500;
        while (port++ < 7550) {
            try {
                reg = LocateRegistry.createRegistry(port);
                echo("\nRMI registry running on port " + port);
                break;
            } catch (RemoteException e) {
                // Failed to create RMI registry...
                //
                echo("\nFailed to create RMI registry on port " + port);
                e.printStackTrace(System.out);
            }
        }
        if (reg == null) {
            System.exit(1);
        }

        // Run tests
        //
        errorCount += test.mapToHashtableTests();
        errorCount += test.jmxConnectorServerFactoryTests();
        errorCount += test.jmxConnectorFactoryTests();
        errorCount += test.nullKeyFactoryTests();

        if (errorCount == 0) {
            echo("\nNull values for key/value pairs in Map Tests PASSED!");
        } else {
            echo("\nNull values for key/value pairs in Map Tests FAILED!");
            System.exit(1);
        }
    }
 
Example 20
Source File: MapNullValuesTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        int errorCount = 0;

        MapNullValuesTest test = new MapNullValuesTest();

        // Create an RMI registry
        //
        echo("");
        echo(dashedMessage("Start RMI registry"));
        Registry reg = null;
        port = 7500;
        while (port++ < 7550) {
            try {
                reg = LocateRegistry.createRegistry(port);
                echo("\nRMI registry running on port " + port);
                break;
            } catch (RemoteException e) {
                // Failed to create RMI registry...
                //
                echo("\nFailed to create RMI registry on port " + port);
                e.printStackTrace(System.out);
            }
        }
        if (reg == null) {
            System.exit(1);
        }

        // Run tests
        //
        errorCount += test.mapToHashtableTests();
        errorCount += test.jmxConnectorServerFactoryTests();
        errorCount += test.jmxConnectorFactoryTests();
        errorCount += test.nullKeyFactoryTests();

        if (errorCount == 0) {
            echo("\nNull values for key/value pairs in Map Tests PASSED!");
        } else {
            echo("\nNull values for key/value pairs in Map Tests FAILED!");
            System.exit(1);
        }
    }