rmi

RMI + java reflection

心已入冬 提交于 2019-12-03 16:13:46
I'm using RMI to allow access to my Java application via MATLAB, which runs in another JVM. MATLAB has a nice interface to print the methods of a Java object. But it fails with RMI, because the object it gets is a proxy. So I would like to add my own method to extract/print the capability of a remote interface (RMI obviously can't directly access methods not available in exported remote interfaces). How could I do this with reflection, either on the client end of the RMI connection, or on the server end? I don't have much experience using reflection. Use case below. edit: what I'm getting most

Implications of restricting RMI to one port

我怕爱的太早我们不能终老 提交于 2019-12-03 16:12:41
I'd like to be able to restrict the ports used by my application to some small-as-possible known set. The application uses Java RMI to communicate with a remote server. The registry is exported on port 1099, which is standard. However, it appears that the port used to export the various remote objects is not always consistent, though it does stay the same across multiple connections over a short period of time. My uneducated guess is there is some sort of caching of the server sockets going on behind the scenes which causes this. I'd like to be able to ensure that the connection always occurs

Server via RMI without registry

ε祈祈猫儿з 提交于 2019-12-03 13:55:10
问题 I have a service object that can be connected to via RMI. Currently I'm doing this: Server Registry r = LocateRegistry.createRegistry(1234); r.bind("server", UnicastRemoteObject.exportObject(remoteServer, 0)); Client RemoteServer s = LocateRegistry.getRegistry("example.com", 1234).lookup("server"); The registry on the server has only one use, to link to the single server object. I figured I might just as well do this on the server: UnicastRemoteObject.exportObject(remoteServer, 1234); But

Programmatically grant Permissions without using policy file

点点圈 提交于 2019-12-03 12:10:46
How to programmatically grant AllPermissions to an RMI application without using policy file? UPDATE: After some researching, I have written this custom Policy Class and installed it via Policy.setPolicy(new MyPolicy()) . Now I get the following error: invalid permission: (java.io.FilePermission \C:\eclipse\plugins\org.eclipse.osgi_3.7.0.v20110613.jar read class MyPolicy extends Policy { @Override public PermissionCollection getPermissions(CodeSource codesource) { return (new AllPermission()).newPermissionCollection(); } } Based on @EJP 's advice, I have debugged using -Djava.security.debug

Java RMI - UnicastRemoteObject: what is the difference between UnicastRemoteObject.exportObject() and extends UnicastRemoteObject?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 11:16:54
问题 i'm preparing for an exam and I'm having a question that I hope someone here could answer me. It's about RMI and remote objects. I wonder why there is so much difference between these two implementations. one is extending the UnicastRemoteObject whereas the other is exporting the object as an UnicastRemoteObject. I don't really get the difference Interface: public interface EchoI extends Remote { public String echo() throws RemoteException } This is the server code (version 1): public class

How to have JMX bind to a specific interface?

我的梦境 提交于 2019-12-03 11:06:36
问题 I am currently starting my Java VM with the com.sun.management.jmxremote.* properties so that I can connect to it via JConsole for management and monitoring. Unfortunately, it listens on all interfaces (IP addresses) on the machine. In our environment, there are often cases where there is more than one Java VM running on a machine at the same time. While it's possible to tell JMX to listen on different TCP ports (using com.sun.management.jmxremote.port ), it would be nice to instead have JMX

How to send a message from Server to Client using Java RMI?

社会主义新天地 提交于 2019-12-03 10:04:59
问题 The application is a Project Management application for a LAN, and it has objects such as Project, Task, etc. So RMI seemed like the way to go. But it also has live notifications sent to certain clients as events are triggered by other clients. I read that Servers cannot keep track of the clients that has been connected to it in RMI. So as an option I think the server could connect to the client like the client connected to the server beforehand. Is this how it is done? If not, should I

Cross context communication between two web application deployed on same tomcat server

浪尽此生 提交于 2019-12-03 08:50:40
I have two web application, webAppMaster and webAppSlave , deployed in same tomcat server. Now in webAppMaster application, there is a java class, RequestHandler whose processRequest method takes a customObject1 as parameter and returns customObject2 . Now, from RequestCreator class of webAppSlave application, I want to invoke processRequest method of RequestHandler class of webAppMaster application. How this should be done ? Thanks in advance. walkeros You need to talk between applications as if you were talking between two distant applications. It does not matter that they are on the same

Has anyone ever got a remote JMX JConsole to work?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: It seems that I've never got this to work in the past. Currently, I KNOW it doesn't work. But we start up our Java process: - Dcom . sun . management . jmxremote - Dcom . sun . management . jmxremote . port = 6002 - Dcom . sun . management . jmxremote . authenticate = false - Dcom . sun . management . jmxremote . ssl = false I can telnet to the port, and "something is there" (that is, if I don't start the process, nothing answers, but if I do, it does), but I can not get JConsole to work filling in the IP and port. Seems like it

Forging a stack trace in Java

旧时模样 提交于 2019-12-03 07:15:28
When you use RMI in Java the remote stack trace of an exception will be prepended when you receive it, somewhat like this: ERROR Client received error when doing stuff: myapp.FooBarException: bla at server.myMethod() at rmi.callHandler() // and now, on the next line comes the client at rmi.sendCall(); at client.doServerMethod() at Thread.run() How is that kind of stacktrace "forgery" done? What do I want it for (apart from just being iterested)? Well, it would help me if I could do this: outer() { thread = new Thread(... inner(); // inner() throws // RuntimeException // at inner(); // at