RMI Server : GUI
Is it possible to have the Server side be a GUI application? All of the examples I have seen are just command line applications.
I tried creating a GUI in my Server class but it seems to never create the gui. Does anybody know what I am doing wrong?
Here is my Server class:
import java.util.Vector;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class MyServer extends UnicastRemoteObject
implements MyServerIft {
* The name of an object of this remote class.
private static String myName;
/** Handle to the MyServerGUI class. Through this handle all methods in the MyServerGUI class are accessed.
private MyServerGUI theView;
public MyServer(String name) throws RemoteException {
///// Call our base class to construct our remote object
///// and listen for incoming calls for the remote object
///// on an anonymous port.
super();
////// Set the name for our remote object.
myName = name;
public boolean submitSongs(Vector playList, String username) throws java.rmi.RemoteException {
//Do your stuff
return true;
public static void main(String args[]) {
try {
///// Instantiate ourselve to get things started.
MyServer me = new MyServer("MyServer");
//////// CREATE MY GUI ////////////
new MyServerGUI(me);
System.setSecurityManager(new RMISecurityManager());
Naming.rebind(myName, me);
catch (Exception e) {
System.out.println("MyServer - Exception Caught:\n" +
e.getMessage());
}Thanks,
Andrew
I have the same problem. However, my server is a JFrame implementing a Remote interface. in other words, the server does not extend UnicastRemoteObject. But this is not the issue.
The issue is when the server recieves a method call, the frame does not updates after properties change. For instance, a JTextArea does not append!!
I tried SwingUtilities.invokeLater(), I also tried using the previous method using the main Threadgroup! But nothing went good!
Any help!
Similar Messages
-
How to stop the RMI server?
Hi,
I create a RMI Server, it has no problem to start. And I created a gui for the server, so that when user press the "start" button, it will start the server.
But somehow I want to update the server and restart again, but while the server is running, i press the "start" button again, i got the following error messages:
"Server error: internal error: ObjID already in use"
Is that mean i have to stop the server first? But how should I stop the server? Thx
AdrianHi,
I've tried to unexport the remote object and unbind the registry, but I still got this error message when I try to restart the server on the fly:
"internal error: ObjID already in use"
Does anyone know why?
Thanks.
Regards,
Adrian -
Display server GUIs on remote Unix machines
Hi,
Because of some strategy decisions, I have created an RMI server which creates a form/window on it's own process space.
the client connects to the server, does a lookup and using a factory object, loads a windows. This window will be created in server process space.
But the problem is:
the environment is Sun Solaris and for server to show the window I have to set the DISPLAY environment variable to the IPAddress the server box that has loaded the rmi server. now If a client from another machine with a different IpAddress contacts the server and asks for a windows to gets created, won't see the window because the window is created on the server box and is shown on server machine because of DISPLAY set to IpAddress of server box.
The question is, is there any way to change the display per request in java? is there any way that java can handle the on which target machine to display it's GUI?
Thanks for help and I all 1000 Dukes' to this
S+Thanks for the comments,I'm sure that is the ideal workaround for a regular distributed env but based on our analysis.
Well, to defend myself :) based on what we are doing, this is one of the most intelligent strategies, please accept my appologies that I can not explain what we have here, and based on what analysis we decided this scenario (that was to defend myself) :)
now if you believe that this approach was a good idea, then we have one problem to solve and that is, when we set DISPLAY to one target machine at the startup of the server, then multiple clients will connect to server and of course the factory object and request for a window, now clients can be on different ip addresses, now how server can load each window on different target machines as ip addresses differ, is there anyway in runtime to say to jvm , as where to load the window?
Cheers,
S+ -
Send Message from RMI Server to RMI Client
Hi,
I want to send message to RMI Client throw RMI server to refresh client's data object as it is database application. I guessed i could implement an interface on client side and i can register my client to the server by sending object to the server. It is not helping it is throwing NULL Pointer exception on server side and it is not refreshing. It seems like it is not passing by reference.
Can any one please guide me with how to send messages to clinet. What is the best way to do it?
-A Thakkar.You need to elaborate the object model of your client. When you run into this situiation where you might have to sublass two different objects, then you should take a look at breaking the client itself into more than one object.
Let me put it another way: A JFrame is a GUI object; why would you ever try to callback a GUI object? Can't you create - say - a CallbackHandler, and let it initiate further action in the client? -
Urgent Help Required For Starting RMI server from servlet.
I am currently working on rmi project.
I want to send request to remote machine(Web host) where my application is from desktop client .For that we are using RMI.
I am writing servlet and inside it i am binding object to registry for rmi server.
which will be deployed on remote server.
code ....
Registry reg;
reg=LocateRegistry.createRegistry(1099);
Server server=new Server("server");//class whose remote object to be accessed
//extends unicast remote object.Implement ServerInt interface which extends Remote.
reg.bind("server",server);
When i am trying to access this object i am getting following exception.
javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalExcepti
on: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: ServerModule.ServerInt]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at RequstReplication.main(RequstReplication.java:27)
Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested excep
tion is:
java.lang.ClassNotFoundException: ServerModule.ServerInt
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
... 4 more
Caused by: java.lang.ClassNotFoundException: ServerModule.ServerInt
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
... 5 more
I can access naming enumeration of registry and object bound to it.
by following program.I shows corect objects.
Context namingContext=new InitialContext();
NamingEnumeration<NameClassPair> e=namingContext.list("rmi:");
while(e.hasMore())
System.out.println(e.next().getName());
While when i start RMI server from simple java program i can access these objects from registry.
I am not getting what is problem problem.Is there any other way to send request?
Plese give quick response.I am currently working on rmi project.
I want to send request to remote machine(Web host) where my application is from desktop client .For that we are using RMI.
I am writing servlet and inside it i am binding object to registry for rmi server.
which will be deployed on remote server.
code ....
Registry reg;
reg=LocateRegistry.createRegistry(1099);
Server server=new Server("server");//class whose remote object to be accessed
//extends unicast remote object.Implement ServerInt interface which extends Remote.
reg.bind("server",server);
When i am trying to access this object i am getting following exception.
javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalExcepti
on: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: ServerModule.ServerInt]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at RequstReplication.main(RequstReplication.java:27)
Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested excep
tion is:
java.lang.ClassNotFoundException: ServerModule.ServerInt
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
... 4 more
Caused by: java.lang.ClassNotFoundException: ServerModule.ServerInt
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
... 5 more
I can access naming enumeration of registry and object bound to it.
by following program.I shows corect objects.
Context namingContext=new InitialContext();
NamingEnumeration<NameClassPair> e=namingContext.list("rmi:");
while(e.hasMore())
System.out.println(e.next().getName());
While when i start RMI server from simple java program i can access these objects from registry.
I am not getting what is problem problem.Is there any other way to send request?
Plese give quick response. -
Attempting to use SSL over RMI from a web application to a RMI server
Hi,
I am attempting to use SSL over RMI to a server. The client is the web
application that is hosted on WebLogic and that attempts to connect to the
server. There is no client or server verification at either the client or
the server end. The code works outside of WebLogic 7/8 but has the following
issues when running the web application inside weblogic:
java.rmi.ConnectException: Connection refused to host: gkhanna1; nested
exception is:
java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:350)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:137)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:124)
at java.net.Socket.<init>(Socket.java:268)
at java.net.Socket.<init>(Socket.java:95)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketF
actory.java:20)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketF
actory.java:115)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:494)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:169)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:79)
at
com.hyperion.css.spi.impl.ntlm.NTLMConnectionClient.initConnection(NTLMConne
ctionClient.java:59)
at
com.hyperion.css.spi.impl.ntlm.NTLMConnectionClient.getUsers(NTLMConnectionC
lient.java:197)
at com.hyperion.css.CSSAPIImpl.getUsers(Unknown Source)
at com.hyperion.css.CSSAPIImpl.initialize(Unknown Source)
at com.hyperion.css.CSSAPIImpl.initialize(Unknown Source)
at jsp_servlet._jsp._app1.__app1signin._jspService(__app1signin.java:133)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(Servle
tStubImpl.java:1058)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:401)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:445)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:306)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(W
ebAppServletContext.java:5445)
at
weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
r.java:780)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:3105)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:2588)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
The code at the client that initiates the connection:
socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) socketFactory.createSocket(host, port);
socket.setEnabledCipherSuites(CIPHERS);
socket.setEnableSessionCreation(true);
Any ideas?
ThanksI don't see anything that indicates SSL was directly a factor in the
failure.
From the exception stack it looks like a more basic connectivity issue,
maybe the URL for the
RMI server is incorrect for some reason or the server was down.
It looks like you are doing something like this:
SSL client -> WLS server with servletA, servletA RMI client
(com.hyperion.css) -> RMI server
The connection failure appears to be the connection from servletA RMI client
to the RMI server.
Is that a correct picture?
Tony
"Gaurav Khanna" <[email protected]> wrote in message
news:[email protected]...
Hi,
I am attempting to use SSL over RMI to a server. The client is the web
application that is hosted on WebLogic and that attempts to connect to the
server. There is no client or server verification at either the client or
the server end. The code works outside of WebLogic 7/8 but has thefollowing
issues when running the web application inside weblogic:
java.rmi.ConnectException: Connection refused to host: gkhanna1; nested
exception is:
java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:350)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:137)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:124)
at java.net.Socket.<init>(Socket.java:268)
at java.net.Socket.<init>(Socket.java:95)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketF
actory.java:20)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketF
actory.java:115)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:494)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:169)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:79)
at
com.hyperion.css.spi.impl.ntlm.NTLMConnectionClient.initConnection(NTLMConne
ctionClient.java:59)
at
com.hyperion.css.spi.impl.ntlm.NTLMConnectionClient.getUsers(NTLMConnectionC
lient.java:197)
at com.hyperion.css.CSSAPIImpl.getUsers(Unknown Source)
at com.hyperion.css.CSSAPIImpl.initialize(Unknown Source)
at com.hyperion.css.CSSAPIImpl.initialize(Unknown Source)
at jsp_servlet._jsp._app1.__app1signin._jspService(__app1signin.java:133)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(Servle
tStubImpl.java:1058)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:401)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:445)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:306)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(W
ebAppServletContext.java:5445)
at
weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
r.java:780)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:3105)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:2588)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
The code at the client that initiates the connection:
socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) socketFactory.createSocket(host, port);
socket.setEnabledCipherSuites(CIPHERS);
socket.setEnableSessionCreation(true);
Any ideas?
Thanks -
Error while registering RMI Server
Hi
I have a system connected to bradband with a static ip. I am planning to use this as the RMI server and any system connected to the internet as the client. Is this possible....?
I tried to bind the name to the registry and I get the following error.
C:\PROGRA~1\Java\jre1.5.0_06\bin>java -Djava.security.policy=policy HelloServer
HelloServer error: Connection refused to host: 59.144.28.215; nested exception i
s:
java.net.ConnectException: Connection refused: connect
java.rmi.ConnectException: Connection refused to host: 59.144.58.215; nested exc
eption is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at HelloServer.main(HelloServer.java:18)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
... 7 moreCan anyone help me by resolving this error.....what do you mean by intranet address?
If you use some NAT device (e.g, DSL, cable) that it is likely you won't be able to access the registry using the external IP address. In such case you need to open the registry port in the firewall. -
Not able to run a simple RMI server
I am running an RMI program like follwing
import java.rmi.* ;
import java.rmi.registry.* ;
import java.rmi.server.* ;
public class CallBeanServer extends UnicastRemoteObject implements ICallBeanServer
//main
public static void main(String args[]) throws Exception
int port = 1000 ;
Registry reg = null ;
if( args[0].equals("true"))
reg = LocateRegistry.createRegistry(port) ;
System.out.println("Successfully created registry") ;
else
reg = LocateRegistry.getRegistry(port) ;
System.out.println("Connected to existing registry") ;
CallBeanServer callBeanServer = new CallBeanServer(reg) ;
}//main
//constructor
public CallBeanServer(Registry reg) throws Exception, RemoteException
super() ;
reg.rebind("CallBeanServer",this) ;
System.out.println("CallBeanServer Object bound") ;
//my public method
public String callBeanServer() throws RemoteException
{ return "Success" ;
I have run the rmiregistry at port no 1000 like
rmiregistry 1000
I have compiled ICallBeanServer also and run rmic also over CallBeanServer like
rmic CallBeanServer
when I run this program using
java CallBeanServer false
it gives the follwoing errors
Connected to existing registry
Exception in thread "main" java.rmi.ServerException: Server RemoteException; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: CallBeanServer_Stub
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: CallBeanServer_Stub
java.lang.ClassNotFoundException: CallBeanServer_Stub
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at CallBeanServer.<init>(CallBeanServer.java:38)
at CallBeanServer.main(CallBeanServer.java:30)
Can you please tell me what is the error?
Thanks
Prashant GuptaAdd the classes (the stubs included) to the classpath when you start the registry.
-
Crazy Exception blocked my RMI server
Hi all one crazy exception is thrown when I try to start the server. Plz reply me the the possible cause and solution.
thanks in advance
The exception is :
Error starting service
java.rmi.server.ExportException: Listen failed on port: 0; nested exception is:
java.net.SocketException: JVM_Bind (code=10055)You cant listen / bind on port 0. Try a different port number greater than 1024. That should work out.
-
Load balancing on RMI Server Application
Hi there, I'd like to know more detail about load balancing on RMI server application, been digging the web for some time, but couldn't find much information, does anyone know any website or has the knowledge of load balancing on RMI to share? Sort like its design and implementation.
Thanks,
JaxI want performance and fault-tolerance,
In that case, is it necessary to have a main
rmi server to allow client to access and pick one of
the rmi servers for the client?Well, if you have one main RMI server, you have a single point of failure again.. Why can't your application know about all rmi servers, and randomly choose one? If it's down, pick a different one.. If your applicatoin is an applet, you'll have to sign it.. Do that and put it on 2 redundant web servers. You have performance by splitting the load and you have your fault tolerance by having x identical rmi servers.
If you're saying what I think, why would you have one main rmi server that picks a different rmi server? That's more work AND your redundancy goes byebye, ie if your main rmi server dies.. -
How to get the IP address of RMI server???
Hi:
Is there a way to know the IP address of RMI server before client and server connect?
I am assuming that client didn't know the IP address of the server.
Because I know that client must hold a server reference so that client can connect to server.
But I want my client program to find out server IP address before they connect and use this finding to connect to server.
Is it possible?
Thanks!So you KNOW that the client MUST know where the server is yet you want the client to find out where the server is?
Simple answer: forget it.
If you don't know where to connect to how are you ever going to connect to it?
And if you do know you don't have to go looking it up...
You can probably do something with JNDI, but then you're only putting off the inevitable as now you need to both know how to contact the JNDI server AND the JNDI server needs to know where the the RMI registry for the service you want to connect to is. -
How do I make a RMI client running in Bea find a remote, non Bea, RMI server?
On my stand alone test system I run a RMI server in one JVM,
registry.exe and a RMI client in its own JVM. The client uses
java.rmi.Naming.lookup() to find the RMI server, and this works fine.
If I run the same RMI client class within Bea the naming lookup fails! I
guess this is due to Bea using it own RMI registry rather than the
registry.exe I started separately(?)
QUESTION: How do I make a RMI client running in Bea find a remote,
non-Bea, RMI server?
Of course, in the final environment the server will run on a system
remote from Bea.
The RMI client calls are done from a servlet, not from a EJB.
The doumentation about using RMI with Bea is focused on running the RMI
server within Bea. This might be the "normal" thing to do, but in our
case Bea is the client, not the server. Do I still need to use
weblogic.rmi.*....? If so, where?
Grateful for any tip.
Göran HagnellOn my stand alone test system I run a RMI server in one JVM,
registry.exe and a RMI client in its own JVM. The client uses
java.rmi.Naming.lookup() to find the RMI server, and this works fine.
If I run the same RMI client class within Bea the naming lookup fails! I
guess this is due to Bea using it own RMI registry rather than the
registry.exe I started separately(?)
QUESTION: How do I make a RMI client running in Bea find a remote,
non-Bea, RMI server?
Of course, in the final environment the server will run on a system
remote from Bea.
The RMI client calls are done from a servlet, not from a EJB.
The doumentation about using RMI with Bea is focused on running the RMI
server within Bea. This might be the "normal" thing to do, but in our
case Bea is the client, not the server. Do I still need to use
weblogic.rmi.*....? If so, where?
Grateful for any tip.
Göran Hagnell -
Cant create JDBC Connections in RMI Server
I am having a pretty weird problem which I am struggling with for the last three days. In the main method of the Server object, following three things are supposed to happen:
1) Creation of a JDBC Connection
2) Creation of a Remote Object and then publishing the same to Registry.
3) Creation of another JDBC Connection (exactly same as in step1)
step 1 and 2 successfully executes and the third one always errors out. I just simply get a NullPointerException.
If I comment out step 2, step 3 executes successfully. Can someone please tell me the mystery? I need your response really urgently so please help me.
TIA
Code Snippet:
public static void main(String[] args) {
System.setSecurityManager(new RMISecurityManager());
try {
Properties dbProps = new Properties();
dbProps.put("user", "SDAWOODI");
dbProps.put("password", "SDAWOODI");
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@wonder.cisco.com:1521:ODSDEV", dbProps);
catch (Exception sqle) {
System.out.println("[11111]"+sqle.toString());
Properties props = new Properties();
props.put("java.rmi.server.codebase", rmiCodeBase);
System.setProperties(props);
try {
SchedulerRImpl schedulerR = new SchedulerRImpl(ssce_sch1);
String nameStr = "s-sce-scheduler";
try {
Naming.bind(nameStr, schedulerR);
if (Scheduler.m_debug_flag) System.out.println("[Scheduler.main] Scheduler bound with RMI registry!!!");
catch (AlreadyBoundException abe) {
if (Scheduler.m_debug_flag) System.out.println("[Scheduler.main] Scheduler is already bound with RMI registry ... trying RE-bind ...");
try {
Naming.rebind(nameStr, schedulerR);
if (Scheduler.m_debug_flag) System.out.println("[Scheduler.main] Scheduler RE-bound with RMI registry!!!");
catch (Exception e) {
if (Scheduler.m_debug_flag) System.out.println("[Scheduler.main] Rcheduler RE-binding failed :(((");
catch (Exception e) {
if (Scheduler.m_debug_flag) System.out.println("[Scheduler.main] SchedulerR instantiation failed:((( : "+e.toString());
Properties dbProps2 = new Properties();
dbProps2.put("user", "SDAWOODI");
dbProps2.put("password", "SDAWOODI");
try {
java.sql.Connection connection2 = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@wonder.cisco.com:1521:ODSDEV", dbProps2);
if (connection2==null) {
System.out.println("connection is NULL");
else {
System.out.println("connection is NOT null");
catch (Exception sqle2) {
System.out.println("[22222]"+sqle2.toString());
}In reply to reply #4:
You can also quote the other part of my reply when it comes to snippets. There are so many pieces of code missing from your snippet that I simply cannot guess what is wrong. (Please do not put your entire class structures here.)
We get connections in many different classes at many different times. It is after all an application that does user work and the user work involves database accesses. Some of those accesses are before RMI (to establish repositories, etc). Most are after.
This URL (jdbc:oracle:thin:@wonder.cisco.com:1521:ODSDEV) appears to use a network connection (yes?). Is the 1521 a port? Are you trying to reuse this port? (the first conn uses the same URL). What port does RMI use?
There is nothing in your snippet that stands out obviously as "this is wrong".
RMI uses networking. JDBC uses networking.
Try substituting some other networking code in place of the RMI code and see if you still get a null trying the second connection. As you say, if you leave out the RMI code the second get.conn works.
Try leaving out the first get.conn. Do the RMI and second get.conn.
Try this and try that and try some more. I once had this problem with a network printer that would not print. The code was fine. The URL was fine. The response from the network and printer were both fine. The damn thing just wasn't printing. Turns out there was this bit, yes a single bit, in one word of a property called the "start print bit". If this bit wasn't on, nothing happened. I tried every combination until I finally found it.
I wish you the best. -
Hello all, I am e newbie in the world of RMI programming. I have developed an application that can control two devices over the internet. The code files are given below :
Parallel.java
import java.rmi.*;
public interface Parallel extends Remote
void relayDriver(byte k) throws RemoteException;
byte currentStatus() throws RemoteException;
ParallelImpl.java
import parport.ParallelPort;
import java.rmi.*;
import java.rmi.server.*;
public class ParallelImpl extends UnicastRemoteObject implements Parallel
private Byte ctrlValue;
ParallelPort lpt1 = new ParallelPort(0x378); // 0x378 is normally the base address for the LPT1 port
public ParallelImpl(byte a) throws RemoteException
ctrlValue = a;
lpt1.write(ctrlValue);
System.out.println("Device Actuation Code "+ctrlValue);
public void relayDriver(byte k) throws RemoteException
ctrlValue = k;
System.out.println("Device Actuation Code "+ctrlValue);
lpt1.write(ctrlValue);
public byte currentStatus() throws RemoteException
return ctrlValue;
ParallelClient.Java
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ParallelClient extends JApplet implements ActionListener
Byte g;
String url = "rmi://169.254.196.149/";
private Container container;
private javax.swing.JTextArea resultArea;
public void init()
container = getContentPane();
container.setLayout( new BorderLayout() );
resultArea = new javax.swing.JTextArea();
JRadioButton buttonZero = new JRadioButton("No Device
On");
buttonZero.setMnemonic(KeyEvent.VK_A);
buttonZero.setActionCommand("0");
buttonZero.setSelected(true);
JRadioButton buttonOne = new JRadioButton("Device 1 On
Only");
buttonOne.setMnemonic(KeyEvent.VK_B);
buttonOne.setActionCommand("1");
JRadioButton buttonTwo = new JRadioButton("Device 2 On
Only");
buttonTwo.setMnemonic(KeyEvent.VK_C);
buttonTwo.setActionCommand("2");
JRadioButton buttonThree = new JRadioButton("Device 1
and 2 Both On");
buttonThree.setMnemonic(KeyEvent.VK_D);
buttonThree.setActionCommand("3");
//Group the radio buttons.
ButtonGroup group = new ButtonGroup();
group.add(buttonZero);
group.add(buttonOne);
group.add(buttonTwo);
group.add(buttonThree);
//Register a listener for the radio buttons.
buttonZero.addActionListener(this);
buttonOne.addActionListener(this);
buttonTwo.addActionListener(this);
buttonThree.addActionListener(this);
JPanel radioPanel = new JPanel(new GridLayout(0, 1));
radioPanel.add(buttonZero);
radioPanel.add(buttonOne);
radioPanel.add(buttonTwo);
radioPanel.add(buttonThree);
container.add(radioPanel, BorderLayout.LINE_START);
container.add(resultArea, BorderLayout.SOUTH);
public void actionPerformed(ActionEvent e)
try
Parallel r1 = (Parallel)Naming.lookup(url +
"inival");
if(r1.currentStatus()==0)
resultArea.setText("Previous
Status: No Devices Online....");
else if(r1.currentStatus()==1)
resultArea.setText("Previous
Status: Device 1 Online. Device 2 Offline.");
else if(r1.currentStatus()==2)
resultArea.setText("Previous
Status: Device 2 Online. Device 1 Offline.");
else
resultArea.setText("Previous
Status: Device 1 & 2 both are Online.");
g = Byte.parseByte(e.getActionCommand());
r1.relayDriver(g);
if(r1.currentStatus()==0)
resultArea.setText("Current
Status: No Devices Online....");
else if(r1.currentStatus()==1)
resultArea.setText("Current
Status: Device 1 Online. Device 2 Offline.");
else if(r1.currentStatus()==2)
resultArea.setText("Current
Status: Device 2 Online. Device 1 Offline.");
else
resultArea.setText("Current
Status: Device 1 & 2 both are Online.");
catch(Exception et)
resultArea.setText("Server OffLine");
ParallelServer.java
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
public class ParallelServer
public static void main(String args[])
try
System.out.println("Constructing Server Implementations ....");
ParallelImpl p1 = new ParallelImpl((byte)0);
System.out.println("Binding Server Implementation to registry ....");
Naming.rebind("inival",p1);
System.out.println("Waiting for invocations from Client ....");
catch(Exception e)
System.out.println("Server is Offline or Line has broken. Error : "+ e);
The corresponding stub files, class files have been loaded on the internet. http://rcviproject.110mb.com/
On the server machine the rmi registry is on and the ParallelServer program is also running. But when the applet at the URL is actuated then it shows 'server offline'. Why is this happening? Please help.That did not print anything. The server when started by the following commands :
start rmiregistry
start java ParallelServer
continues to run at Waiting for invocation from client ...... no error msg is shown.
do i need tomcat on the server machine in addition to this ? -
RMI server object lookup in a session bean
Hi all,
I am getting MarshalException when I call java.rmi.Naming.lookup() in a session
bean. Following is the code and exception. Please note that I am using java.rmi
package instead of weblogic.rmi and that both the session bean and RMI server
object (a startup class) is deployed on the same machine.
Thanks for your help in advance.
// a simple, replica-aware session bean method
// some code here
try {
MediatorInterface mediator = (MediatorInterface) java.rmi.Naming.lookup("rmi://localhost:7001/TestMediator);
catch (Exception e) {
// log the exception
The exception:
java.rmi.MarshalException: Error marshaling transport header; nested exception
i
s:
java.io.EOFException
java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:224)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:206
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:84)
at test.mgmtop.CreateNetworkOpHandler.execute(CreateNetworkOpHandler.jav
a:88)
at test.mgmtop.CreateNetworkOpHandler.perform(CreateNetworkOpHandler.jav
a:28)
at test.ejb.MgmtServiceBean.create(MgmtServiceBean.java:57)
at test.ejb.MgmtServiceSession_idi8yo_EOImpl.create(MgmtServiceSession_i
di8yo_EOImpl.java:46)
at test.ejb.MgmtServiceSession_idi8yo_EOImpl_WLSkel.invoke(Unknown Sourc
e)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:346)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:300)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:762)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:295)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)Hi Pyung,
How about trying this instead:
InitialContext ctx = new InitialContext();
MediatorInterface mediator = (MediatorInterface) ctx.lookup("TestMediator");
This assumes your startup class binds the Mediator to the JNDI name "TestMediator".
- Matt
Pyung Yoon wrote:
Hi all,
I am getting MarshalException when I call java.rmi.Naming.lookup() in a session
bean. Following is the code and exception. Please note that I am using java.rmi
package instead of weblogic.rmi and that both the session bean and RMI server
object (a startup class) is deployed on the same machine.
Thanks for your help in advance.
// a simple, replica-aware session bean method
// some code here
try {
MediatorInterface mediator = (MediatorInterface) java.rmi.Naming.lookup("rmi://localhost:7001/TestMediator);
catch (Exception e) {
// log the exception
The exception:
java.rmi.MarshalException: Error marshaling transport header; nested exception
i
s:
java.io.EOFException
java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:224)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:206
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:84)
at test.mgmtop.CreateNetworkOpHandler.execute(CreateNetworkOpHandler.jav
a:88)
at test.mgmtop.CreateNetworkOpHandler.perform(CreateNetworkOpHandler.jav
a:28)
at test.ejb.MgmtServiceBean.create(MgmtServiceBean.java:57)
at test.ejb.MgmtServiceSession_idi8yo_EOImpl.create(MgmtServiceSession_i
di8yo_EOImpl.java:46)
at test.ejb.MgmtServiceSession_idi8yo_EOImpl_WLSkel.invoke(Unknown Sourc
e)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:346)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:300)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:762)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:295)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
Maybe you are looking for
-
Error Message: Motion menus exceed maximum duration
Our iDVD has one Main Menu with Nine Submenu's. We used the Reflections Theme. All these have motion menus, for consistency. Each is set at a loop duration for audio of no more than 45 seconds. [10X45=450 secs or 7:30 mins]. The menu screeen allows f
-
Flash to Illustrator - colors change!
Flash CS3: I export an image in Flash as Illustrator file (6 or 88). When I open such an AI file in Illustrator CS3, it keeps the shapes and layers from Flash, but turns out to have lost the brillant RGB colors and shows very "greyish" CMYK colors! I
-
I have Pages on my Ipad2 and want to move a document to Google Drive but it wont let me. It does let me open a doucument from google drive but not save one to Google drive. Who can help?
-
Result row when condition is active
Hello gurus, I have created a condition in my report and the result row does not reflect the rows displayed when condition is active. Is it possible to get a result which is the total of rows displayed when condition is active ? Thanks in advance, Va
-
Looking for a good message recovery site?
My iPhone 5 went into recovery mode when I updated to iOS 7.1.2. Does anyone know of any good data recovery sites that I can use to recovery some lost text messages and Photos?