"Transfering objects" with RMI
Hi!
I have a general question concerning the capabilities of RMI. The server provides a interface that creates instances of certain classes and returns it to the client.
the corresponding method in the interface looks like this
public Service getService () throws RMIException
So calling the method via RMI works fine. Then I tried to make a subclass of Service called ExtService and changed the implementation of the getService method in that way, that I create an instance of ExtService and return it. The problem then was, that at the client the ExtService class is not available and the call failed.
Now my question: is it also possible to pass such subclasses via the rmi mechanism in that way, that the client only knows the base class (here Service) but can receive subclasses via the RMI call??
thanx, Ingo
Sounds like you changed the return value from public Service getService();to public ExtService getService();right?
Wrong. in getService() you simply return the ExtService instance (as Service - the base class).
You can't change the implementation to return the ExtService, because, as you found out,
the client side has no idea what ExtService is. It can BE an ExtService, but the client
has to "see" Service. ExtService is still then free to override behaviour of any methods.
Similar Messages
-
IllegalAccessError passing object with RMI
Hi,
I am playing with RMI at the moment.
I have a Remote class that implements a Remote interface
The interface has one method which the class implements and this is to get a TestSerial object.
If I run without using a Securitymanager then there are no problems.
When I do use the SecurityManager then there is an error.
This error remains even if set the permissions in the policy file to java.security.AllPermissions
Does anyone know why this is?
thanks in advance,
J
//Start the server....
java -Djava.security.policy=policy HelloServer
In main....
HelloImpl bound in registry....
//Run the client
java -Djava.security.policy=policy HelloClient
Exception in thread "main" java.lang.IllegalAccessError: tried to access TestSerial from class $Proxy0
at $Proxy.getTestSerial(Unknown Source)
at HelloClient.main(HelloClient.jav:23)
* Remote interface
public interface Hello extends java.rmi.Remote {
TestSerial getTestSerial() throws java.rmi.RemoteException;
* Remote class
public class HelloImpl implements Hello {
public HelloImpl() {
public TestSerial getTestSerial(){
return new TestSerial();
* Server class
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
public class HelloServer {
public HelloServer() {
public static void main(String args[]) {
System.out.println("In main....");
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
try {
HelloImpl obj = new HelloImpl();
Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0);
Registry registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
registry.bind("Hello", stub);
System.out.println("HelloImpl bound in registry....");
catch (Exception e) {
System.out.println("HelloImpl exception: " + e.getMessage());
e.printStackTrace();
* Client class
import java.rmi.*;
import java.rmi.registry.*;
import java.io.*;
public class HelloClient {
public static void main(String args[]) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
try {
Registry registry = LocateRegistry.getRegistry();
Hello obj = (Hello) registry.lookup("Hello");
TestSerial x = obj.getTestSerial();
System.out.println(x.getName());
catch (Exception e) {
System.out.println("HelloClient exception: " + e.printStackTrace();
* TestSerial class
class TestSerial implements java.io.Serializable {
public TestSerial(){
public String getName(){
return "TestSerial";
* Policy file
grant codeBase "file:." {
permission java.net.SocketPermission "*:1024-", "accept,connect";
};class TestSerial implements java.io.Serializable {
public class TestSerial implements java.io.Serializable { -
Use JFreeChart or Component object with RMI
I am trying to pass a JFreeChart object or a java.awt.Component object from a server to a client. I thought RMI would be the solution, but I get a "java.lang.NoClassDefFoundError: org/jfree/chart/JFreeChart" error when trying to run the server. I believe the problem is that the JFreeChart is not an Interface and so can not be used in a Remote Invocation. So, the problem would be the same with a Component Object.
JFreeChart and Component are Serializable object, so I thought there may be a way to remotely use them or pass and recreate them from a server to a client.
Does someone can help me here to figure out what I could do?sure you can pass instances through RMI, but that doesn't prevent you from needing the required jars for the product on both client and server.
So make sure both client and server have the jfree jars installed in the classpath of their applications when you run the application. -
I've successfully (well, almost) programmed an RMI client and server...and amazing they work (happy chappy) ... most of the time. The problem is of the 8 methods I've defined in interfaces 6 of them are of return type String, the other two are objects I've defined. The problem is these objects don't transfer through the system - just throw a RemoteException every time either one of these methods is invoked. The first , and well, only, thing I could think of was to make sure these objects were Serializable but that didn't have an effect...so what's the solution?
tiapackage messenger.coreMessenger.contact;
import java.io.Serializable;
public class Contact implements Serializable {
private final String email;
private String displayName;
private boolean status;
private int displayIcon;
public Contact(String email, String displayName, int displayIcon) {
this.email = email;
this.displayName = displayName;
this.status = false;
this.displayIcon = displayIcon;
public String getEmail(){
return email;
public String getName(){
return displayName;
public int getDisplayIcon(){
return displayIcon;
public boolean isOnline(){
return status;
public void setName(String displayName){
this.displayName = displayName;
public void setDisplayIcon(int displayIcon){
this.displayIcon = displayIcon;
public void logOn(){
this.status = true;
public void logOff(){
this.status = false;
}this is one of the return classes - the other one is not too disimilar so to save space I wont bother posting that... -
Regular RMI server object with WebLogic JNDI
Is that possible to register a regular RMI object with WebLogic JNDI
tree? I was building a simple program (using javac and rmic only) based
on the java.rmi.* (without changing the import statements to
weblogic.rmi.*) and using the weblogic.jndi to register the server
object. Below is some piece of code,
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://172.20.20.20:7001");
ctx = new InitialContext(ht);
ctx.bind("HelloServer", obj);
The code failed for the following reason,
javax.naming.NamingException. Root exception is
java.rmi.MarshalException: failed to marshal public abstract void
weblogic.jndi.internal.NamingNode.bind(java.lang.String,java.lang.Object,java.util.Hashtable)
throws javax.naming.NamingException,java.rmi.RemoteException; nested
exception is:
java.rmi.server.ExportException: A description for
examples.rmi.hello.HelloImpl was found but it could not be read due to:
[Failed to find examples.rmi.hello.HelloImpl_WLStub or
examples.rmi.hello.Hello_WLStub for class examples.rmi.hello.HelloImpl]
java.rmi.StubNotFoundException: Failed to find
examples.rmi.hello.HelloImpl_WLStub or examples.rmi.hello.Hello_WLStub
for class examples.rmi.hello.HelloImpl
at
weblogic.rmi.internal.BasicDescriptor.<init>(BasicDescriptor.java:101)
at
weblogic.rmi.internal.BasicRuntimeDescriptor.<init>(BasicRuntimeDescriptor.java:50)
at
weblogic.rmi.internal.DescriptorManager.resolveClass(DescriptorManager.java:55)
at
weblogic.rmi.internal.DescriptorManager.getDescriptor(DescriptorManager.java:39)
at
weblogic.rmi.internal.DescriptorManager.getDescriptor(DescriptorManager.java:30)
at
weblogic.rmi.internal.OIDManager.getRequestDispatcher(OIDManager.java:281)
at
weblogic.rmi.internal.OIDManager.getReplacement(OIDManager.java:270)
at
weblogic.rmi.internal.OIDManager.replaceObject(OIDManager.java:98)
at
weblogic.common.internal.ChunkedObjectOutputStream.replaceObject(ChunkedObjectOutputStream.java:55)
at
weblogic.common.internal.ChunkedObjectOutputStream$NestedObjectOutputStream.replaceObject(ChunkedObjectOutputStream.java:239)
Any idea?
- SteveC"Pyung Yoon" <[email protected]> writes:
MediatorInterface mediator = (MediatorInterface) java.rmi.Naming.lookup("rmi://localhost:7001/TestMediator);This implies JRMP which the server does not support. You need to use t3 or iiop.
andy -
Transferring object graph over RMI
Hi all,
I'm designing a client-server thingy, and am intending it to communicate over RMI. I'm currently designing a filter mechanism to let the client see a certain subset of the state (essentially an object graph), manipulate this, and transfer updates of it back to the server, which then are propagated to the other clients and so on.
Any tips and tricks to take into account when transfering interconnected objects over RMI? (They don't need remove references, apart from the state transfer process, all local references are sufficient.) Also, I'd like to not transfer the entire "graph", only updates to it as they happen.
I have a couple of ideas, I'd just like to hear your input before I dwelve more into the mechanics of them..
Thanks!
/CGo for it.
Just think clearly about where the objects exist, and what get's transferred:
o What objects are on the clients?.
o What is a shared remote object?
o What objects get passed from client to server? What objects are returned to clients? -
Hi,
I am trying to deploy an EJB module have 4-5 EJB's on weblogic 8.1 through JBuilder.
I am getting following error during deployment.
Exception:weblogic.management.ApplicationException: prepare failed for Sample.jar
Module: Sample.jar Error: Exception preparing module: EJBModule(Sample.jar,status=NEW)
Unable to deploy EJB: SampleBean from Sample.jar:
weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Cannot export non
clusterable object with jndiName ]
at weblogic.utils.Debug.assertion(Debug.java:57)
at weblogic.rmi.extensions.server.ServerHelper.exportObject(ServerHelper.java:272)
at weblogic.ejb20.internal.BaseEJBHome.setup(BaseEJBHome.java:95)
at weblogic.ejb20.internal.StatelessEJBHome.setup(StatelessEJBHome.java:67)
at weblogic.ejb20.deployer.ClientDrivenBeanInfoImpl.prepare(ClientDrivenBeanInfoImpl.java:979)
at weblogic.ejb20.deployer.EJBDeployer.setupBeanInfos(EJBDeployer.java:983)
at weblogic.ejb20.deployer.EJBDeployer.prepare(EJBDeployer.java:1283)
at weblogic.ejb20.deployer.EJBModule.prepare(EJBModule.java:477)
at weblogic.j2ee.J2EEApplicationContainer.prepareModule(J2EEApplicationContainer.java:2962)
at weblogic.j2ee.J2EEApplicationContainer.prepareModules(J2EEApplicationContainer.java:1534)
at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:1188)
at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:1031)
at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.prepareContainer(SlaveDeployer.java:2602)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer(SlaveDeployer.java:2552)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2474)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:798)
at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:507)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:465)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Any clue?, what its talking about?
Thanks
NareshHi,
I am trying to deploy an EJB module have 4-5 EJB's on weblogic 8.1 through JBuilder.
I am getting following error during deployment.
Exception:weblogic.management.ApplicationException: prepare failed for Sample.jar
Module: Sample.jar Error: Exception preparing module: EJBModule(Sample.jar,status=NEW)
Unable to deploy EJB: SampleBean from Sample.jar:
weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Cannot export non
clusterable object with jndiName ]
at weblogic.utils.Debug.assertion(Debug.java:57)
at weblogic.rmi.extensions.server.ServerHelper.exportObject(ServerHelper.java:272)
at weblogic.ejb20.internal.BaseEJBHome.setup(BaseEJBHome.java:95)
at weblogic.ejb20.internal.StatelessEJBHome.setup(StatelessEJBHome.java:67)
at weblogic.ejb20.deployer.ClientDrivenBeanInfoImpl.prepare(ClientDrivenBeanInfoImpl.java:979)
at weblogic.ejb20.deployer.EJBDeployer.setupBeanInfos(EJBDeployer.java:983)
at weblogic.ejb20.deployer.EJBDeployer.prepare(EJBDeployer.java:1283)
at weblogic.ejb20.deployer.EJBModule.prepare(EJBModule.java:477)
at weblogic.j2ee.J2EEApplicationContainer.prepareModule(J2EEApplicationContainer.java:2962)
at weblogic.j2ee.J2EEApplicationContainer.prepareModules(J2EEApplicationContainer.java:1534)
at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:1188)
at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:1031)
at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.prepareContainer(SlaveDeployer.java:2602)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer(SlaveDeployer.java:2552)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2474)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:798)
at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:507)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:465)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Any clue?, what its talking about?
Thanks
Naresh -
VersioningError when Using JDBC driver for SQL Server with RMI
Hi,
I wrote a simple class for inserting rows into a database. The database is SQL Server 2000, and I am using weblogic's mssqlserver4 driver. The class works fine, but when I try to export the class as a remote object (using Sun's RMI implementation, not Weblogic RMI), I get the following error:
Exception in thread "main" weblogic.common.internal.VersioningError: No WebLogic packages defined in CLASSPATH at weblogic.common.internal.VersionInfo.<init>(VersionInfo.java:35) at weblogic.version.<clinit>(version.java:18)
at weblogic.jdbc.common.internal.FileProxy.initFileHandles(FileProxy.java:30) at weblogic.jdbc.mssqlserver4.BaseConnection.prepareConnection(BaseConnection.java:215)
at weblogic.jdbc.mssqlserver4.Driver.newConnection(Driver.java:34) at weblogic.jdbc.mssqlserver4.ConnectDriver.connect(ConnectDriver.java:151) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:171)
Can anyone tell me why this happens? What is difference between using the driver standalone and using it with RMI? Does it have anything to do with the fact that I'm using Javasoft RMI and not Weblogic RMI? I'm pretty sure I have the classpaths set up correctly.
Thanks,
BoBo Min Jiang wrote:
Hi,
I wrote a simple class for inserting rows into a database. The database is SQL Server 2000, and I am using weblogic's mssqlserver4 driver. The class works fine, but when I try to export the class as a remote object (using Sun's RMI implementation, not Weblogic RMI), I get the following error:
Exception in thread "main" weblogic.common.internal.VersioningError: No WebLogic packages defined in CLASSPATH at weblogic.common.internal.VersionInfo.<init>(VersionInfo.java:35) at weblogic.version.<clinit>(version.java:18)
at weblogic.jdbc.common.internal.FileProxy.initFileHandles(FileProxy.java:30) at weblogic.jdbc.mssqlserver4.BaseConnection.prepareConnection(BaseConnection.java:215)
at weblogic.jdbc.mssqlserver4.Driver.newConnection(Driver.java:34) at weblogic.jdbc.mssqlserver4.ConnectDriver.connect(ConnectDriver.java:151) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:171)
Can anyone tell me why this happens? What is difference between using the driver standalone and using it with RMI? Does it have anything to do with the fact that I'm using Javasoft RMI and not Weblogic RMI? I'm pretty sure I have the classpaths set up correctly.
Thanks,
BoHi. Show me the whole stacktrace of the exception. The issue seems to be the driver licensing
code, which is looking for the bea.license file, and not finding it. Have your code run a System command
to find and print out the classpath it thinks is in effect. You will then see if the license file is there.
Joe -
Hi,
I have a question on using EJB / or RMI servers with CORBA clients using
RMI-IIOP transport, which in theory should work, but in practice has few
glitches.
Basically, I have implemented a very simple server, StockTreader, which
looks up for a symbol and returns a 'Stock' object. In the first example, I
simplified the 'Stock' object to be a mere java.lang.String, so that lookup
would simply return the 'synbol'.
Then I have implemented the above, as an RMI-IIOP server (case 1) and a
CORBA server (case 2) with respective clients, and the pair of
client-servers work fine as long as they are CORBA-to-CORBA and RMI-to-RMI.
But the problem arises when I tried using the RMI server (via IIOP) with the
CORBA client, when the client tries to narrow the object ref obtained from
the naming service into the CORBA idl defined type (StockTrader) it ends up
with a class cast exception.
This is what I did to achieve the above results:
[1] Define an RMI interface StockTrader.java (extending java.rmi.Remote)
with the method,
public String lookup( String symbol) throws RMIException;
[2] Implement the StorckTrader interface (on a PortableRemoteObject derived
class, to make it IIOP compliant), and then the server to register the stock
trader with COS Naming service as follows:
String homeName =....
StockTraderImpl trader =new StockTraderImpl();
System.out.println("binding obj <" homeName ">...");
java.util.Hashtable ht =new java.util.Hashtable();
ht.put("java.naming.factory.initial", args[2]);
ht.put("java.naming.provider.url", args[3]);
Context ctx =new InitialContext(ht);
ctx.rebind(homeName, trader);
[3] Generate the RMI-IIOP skeletons for the Implementation class,
rmic -iiop stock.StockTraderImpl
[4] generate the IDL for the RMI interface,
rmic -idl stock.StockTraderImpl
[5] Generate IDL stubs for the CORBA client,
idlj -v -fclient -emitAll StockTraderImpl.idl
[6] Write the client to use the IDL-defined stock trader,
String serverName =args[0];
String symList =args[1];
StockClient client =new StockClient();
System.out.println("init orb...");
ORB orb =ORB.init(args, null);
System.out.println("resolve init name service...");
org.omg.CORBA.Object objRef
=orb.resolve_initial_references("NameService");
NamingContext naming =NamingContextHelper.narrow(objRef);
... define a naming component etc...
org.omg.CORBA.Object obj =naming.resolve(...);
System.out.println("narrow objRef: " obj.getClass() ": " +obj);
StockTrader trader =StockTraderHelper.narrow(obj);
[7] Compile all the classes using Java 1.2.2
[8] start tnameserv (naming service), then the server to register the RMI
server obj
[9] Run the CORBA client, passing it the COSNaming service ref name (with
which the server obj is registered)
The CORBA client successfully finds the server obj ref in the naming
service, the operation StockTraderHelper.narrow() fails in the segment
below, with a class cast exception:
org.omg.CORBA.Object obj =naming.resolve(...);
StockTrader trader =StockTraderHelper.narrow(obj);
The <obj> returned by naming service turns out to be of the type;
class com.sun.rmi.iiop.CDRInputStream$1
This is of the same type when stock trader object is registered in a CORBA
server (as opposed to an RMI server), but works correctly with no casting
excpetions..
Any ideas / hints very welcome.
thanks in advance,
-hariOn the contrary... all that is being said is that we needed to provide clearer examples/documentation in the 5.1.0 release. There will be no difference between the product as found in the service pack and the product found in the 5.1.1. That is, the only substantive will be that 5.1.1 will also
include the examples.
"<=one way=>" wrote:
With reference to your and other messages, it appears that one should not
expect that WLS RMI-IIOP will work in a complex real-life system, at least
not now. In other words, support for real-life CORBA clients is not an
option in the current release of WLS.
TIA
"Eduardo Ceballos" <[email protected]> wrote in message
news:[email protected]...
We currently publish an IDL example, even though the IDL programmingmodel in Java is completely non-functional, in anticipation of the support
needs for uses who need to use IDL to talk to the Weblogic server,
generically. This example illustrates the simplest connectivity; it does not
address how
to integrate CORBA and EJB, a broad topic, fraught with peril, imo. I'llnote in passing that, to my knowledge, none of the other vendors attempt
this topic either, a point which is telling if all the less happy to hear.
For the record then, what is missing from our distribution wrt RMI-IIOPare a RMI-IIOP example, an EJB-IIOP example, an EJB-C++. In this you are
correct; better examples are forth coming.
Still, I would not call our RMI-IIOP implementation fragile. I would saythat customers have an understandably hard time accepting that the IDL
programming model is busted; busted in the sense that there are no C++
libraries to support the EJB model, and busted in the sense that there is
simply no
support in Java for an IDL interface to an EJB. Weblogic has nothing to doit being busted, although we are trying to help our customers deal with it
in productive ways.
For the moment, what there is is a RMI (over IIOP) programming model, aninherently Java to Java programming model, and true to that, we accept and
dispatch IIOP request into RMI server objects. The way I look at it is this:
it's just a protocol, like HTTP, or JRMP; it's not IDL and it has
practically nothing to do with CORBA.
ST wrote:
Eduardo,
Can you give us more details about the comment below:
I fear that as soon as the call to narrow succeeds, the remainingapplication will fail to work correctly because it is too difficult ot
use an idl client in java to work.It seems to me that Weblogic's RMI-IIOP is a very fragile
implementation. We
don't need a "HelloWorld" example, we need a concrete serious example(fully
tested and seriously documented) that works so that we can get a betteridea
on how to integrate CORBA and EJB.
Thanks,
Said
"Eduardo Ceballos" <[email protected]> wrote in message
news:[email protected]...
Please post request to the news group...
As I said, you must separate the idl related classes (class files and
java
files) from the rmi classes... in the rmic step, you must set a newtarget
(as you did), emit the java files into that directory (it's not clearyou
did this), then remove all the rmi class files from the class path... ifyou
need to compile more classes at that point, copy the java files to theidl
directly is you must, but you can not share the types in any way.
I fear that as soon as the call to narrow succeeds, the remainingapplication will fail to work correctly because it is too difficult otuse
an idl client in java to work.
Harindra Rajapakshe wrote:
Hi Eduardo,
Thanks for the help. That is the way I compiled my CORBA client, by
separating the IDL-generated stubs from the RMI ones, but still I
get a
CORBA.BAD_PARAM upon narrowing the client proxy to the interfacetype.
Here's what I did;
+ Define the RMI interfaces, in this case a StockTrader interface.
+ Implement RMI interface by extendingjavax.rmi.PortableRemoteObject
making
it IIOP compliant
+ Implemnnt an RMI server, and compile using JDK1.2.2
+ use the RMI implementation to generate CORBA idl, using RMI-IIOPplugin
utility rmic;
rmic -idl -noValueMethods -always -d idl stock.StockTraderImpl
+ generate Java mappings to the IDL generated above, using RMI-IIOPplugin
util,
idlj -v -fclient -emitAll -tf src stocks\StockTrader.idl
This creates source for the package stock and also
org.omg.CORBA.*
package, presumably IIOP type marshalling
+ compile all classes generated above using JDK1.2.2
+ Implement client (CORBA) using the classes generated above, NOTthe
RMI
proxies.
+ start RMI server, with stockTrader server obj
+ start tnameserv
+ start CORBA client
Then the client errors when trying to narrow the obj ref from the
naming
service, into the CORBA IDL defined interface using,
org.omg.CORBA.Object obj =naming.resolve(nn);
StockTrader trader =StockTraderHelper.narrow(obj); // THIS
ERRORS..!!!
throwing a CORBA.BAD_PARAM exception.
any ideas..?
Thanks in advance,
-hari
----- Original Message -----
From: Eduardo Ceballos <[email protected]>
Newsgroups: weblogic.developer.interest.rmi-iiop
To: Hari Rajapakshe <[email protected]>
Sent: Wednesday, July 26, 2000 4:38 AM
Subject: Re: problem using CORBA clients with RMI/EJBservers..!!!???
Please see the post on june 26, re Errors compiling... somewherein
there,
I suspect, you are referring to the rmi class file when you are
obliged
to
completely segregate these from the idl class files.
Hari Rajapakshe wrote:
Hi,
I have a question on using EJB / or RMI servers with CORBA
clients
using
RMI-IIOP transport, which in theory should work, but in practice
has
few
glitches.
Basically, I have implemented a very simple server,
StockTreader,
which
looks up for a symbol and returns a 'Stock' object. In the firstexample, I
simplified the 'Stock' object to be a mere java.lang.String, so
that
lookup
would simply return the 'synbol'.
Then I have implemented the above, as an RMI-IIOP server (case
1)
and a
CORBA server (case 2) with respective clients, and the pair of
client-servers work fine as long as they are CORBA-to-CORBA andRMI-to-RMI.
But the problem arises when I tried using the RMI server (via
IIOP)
with
the
CORBA client, when the client tries to narrow the object ref
obtained
from
the naming service into the CORBA idl defined type (StockTrader)
it
ends
up
with a class cast exception.
This is what I did to achieve the above results:
[1] Define an RMI interface StockTrader.java (extending
java.rmi.Remote)
with the method,
public String lookup( String symbol) throws RMIException;
[2] Implement the StorckTrader interface (on a
PortableRemoteObject
derived
class, to make it IIOP compliant), and then the server to
register
the
stock
trader with COS Naming service as follows:
String homeName =....
StockTraderImpl trader =new StockTraderImpl();
System.out.println("binding obj <" homeName ">...");
java.util.Hashtable ht =new java.util.Hashtable();
ht.put("java.naming.factory.initial", args[2]);
ht.put("java.naming.provider.url", args[3]);
Context ctx =new InitialContext(ht);
ctx.rebind(homeName, trader);
[3] Generate the RMI-IIOP skeletons for the Implementation
class,
rmic -iiop stock.StockTraderImpl
[4] generate the IDL for the RMI interface,
rmic -idl stock.StockTraderImpl
[5] Generate IDL stubs for the CORBA client,
idlj -v -fclient -emitAll StockTraderImpl.idl
[6] Write the client to use the IDL-defined stock trader,
String serverName =args[0];
String symList =args[1];
StockClient client =new StockClient();
System.out.println("init orb...");
ORB orb =ORB.init(args, null);
System.out.println("resolve init name service...");
org.omg.CORBA.Object objRef
=orb.resolve_initial_references("NameService");
NamingContext naming=NamingContextHelper.narrow(objRef);
... define a naming component etc...
org.omg.CORBA.Object obj =naming.resolve(...);
System.out.println("narrow objRef: " obj.getClass() ":"
+obj);
StockTrader trader =StockTraderHelper.narrow(obj);
[7] Compile all the classes using Java 1.2.2
[8] start tnameserv (naming service), then the server to
register
the
RMI
server obj
[9] Run the CORBA client, passing it the COSNaming service ref
name
(with
which the server obj is registered)
The CORBA client successfully finds the server obj ref in the
naming
service, the operation StockTraderHelper.narrow() fails in thesegment
below, with a class cast exception:
org.omg.CORBA.Object obj =naming.resolve(...);
StockTrader trader =StockTraderHelper.narrow(obj);
The <obj> returned by naming service turns out to be of the
type;
class com.sun.rmi.iiop.CDRInputStream$1
This is of the same type when stock trader object is registeredin a
CORBA
server (as opposed to an RMI server), but works correctly with
no
casting
excpetions..
Any ideas / hints very welcome.
thanks in advance,
-hari -
Any example of dynamic proxy with RMI?
Hi, are there any good example of dynamic proxy with RMI, using the new RemoteObjectInvocationHandler class?
I am currently implementing a Registry, and want to use dynamic proxy to wrap around the registry stub, to pass extra information to the client.
I've tried it, but the program will hang and get this exception:
Exception in thread "RMI TCP Connection(1616)-192.168.1.23" java.lang.OutOfMemoryError: Java heap space
My implementation looks like this:
public RegistryImpl extends RemoteServer Implements Registry {
public RegistryImpl(int port, Properties... properties) throws RemoteException, ChannelException {
// Create a reference for the registry.
LiveRef liveref = new LiveRef(id, port);
ref = new UnicastServerRef(liveref);
Registry proxy = (Registry)RegistryProxy.newProxyInstance(
this.getClass().getClassLoader(),
this.getClass().getInterfaces(),
new RemoteObjectInvocationHandler(this.getRef()));
/* Using dynamic proxy */
usref.exportObject(proxy, null, true);
public class RegistryProxy extends Proxy implements Registry {
private InvocationHandler handler;
public RegistryProxy(InvocationHandler handler) {
super(handler);
this.handler = handler;
public Remote lookup(String name) throws RemoteException, NotBoundException, AccessException {
Remote result;
try {
Method m = Registry.class.getMethod("lookup", new Class[]{String.class});
result = (Remote)handler.invoke(this, m, new Object[]{name});
} catch (SecurityException e) {
throw new UndeclaredThrowableException(e);
} catch (NoSuchMethodException e) {
throw new UndeclaredThrowableException(e);
} catch (Throwable e) {
throw new UndeclaredThrowableException(e);
return result;
public void bind(String name, Remote remoteObj) throws RemoteException, AlreadyBoundException, AccessException {
public void unbind(String name) throws RemoteException, NotBoundException, AccessException {
public void rebind(String name, Remote remoteObj) throws RemoteException, AccessException {
public String[] list() throws RemoteException, AccessException {
}I am new to Java programming, any help is appriciated.
Regards
EddieHi Eddie,
Perhaps you might like this one:
http://wiki.java.net/bin/view/Communications/TransparentProxy
it uses dynamic proxies to achieve complete RMI transparency.
Something to consider, good luck.
John -
Serializing objects with the NIO API
I try to use the new IO API to implement a non-blocking multi-threaded server that communicates with client applications by exchanging serialized objects. I started from the code in the JavaWorld article at http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-merlin.html .
With the new features of J2SDK 1.4.0, you don't have to create a separate thread per connected client. That is a big improvement.
But when I read an object with ObjectInputStream, I get a java.nio.channels.IllegalBlockingModeException.
Has anybody successfully implemented such a server since the release of the new io API?
Thanks.
Jean-RobertThe ObjectStream code is basically incompatible with non blockin I/O since you must block on the stream until a whole Object is available. You could roll something like this yourself, by reading bytes until there are enough available to build the next object and then getting that Object from the buffer and shipping it to your client thread. All of this is far more trouble than just using the Stream oriented I/O.
NIO and mutilple threads are a nightmare, the whole idea of non-blocking I/O is to avoid needing multiple threads. If you do use multiple threads you will need queues between them. See the Taming the NIO Circus topic for lots of discussion of NIO and its problems. The system seems more stable in JDK 1.5, but most people haven't even started using 1.4 for production yet.
Personally I avoid ObjectStreams. They are only useful between Java applications, if I want that I just use RMI and let Java do ALL the hard work. When I write a Socket based app, its probably because the other end is a mainframe of a C program. For that reason I send data as bytes, packaged up in packets, and encode as XML or ASN.1 so the other end can interpret it. -
Following a moving object with a mask
Has anyone out there tried to follow an object with a mask in FCP? bascially I transferred a CAD video into MOV and imported it into FCP to edit it.
NOw i have a "flickering"occuring over some of the objects in the video that I have been masking with a PSD (transparent background) of 'the whole object'.. But i have to import and insert these masks each frame.... does anyone have ANY other ideas on how to resolve this.
A friend of mine said aftereffects, but i cant imagine FCP cant do it.
Thanks ahead of time... i look forward to hearing other people's smarts- as i dont have them.
I can email sample video if there are questions.within FCP or FCS?
if you have FCS 2 you can use Motion's Analyze Motion and Match Move functions ... tutorial here
if not you could buy Lyric's Motion Tracking Kit plugin bundle
http://www.lyric.com/fcp-plugins/tracking.htm
even better would be to try to address the root of the problem ... what's with the flickering objects? -
URGENT Servlet with RMI ConnectionException
i have an object with two personalities: Servlet and RMI.
However when i invoke it using the web browser, the following exceptions pop out:
<!--
java.rmi.ConnectException: Connection refused to host: 172.20.134.24; nested exc
eption is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at IncomingSMSController.init(IncomingSMSController.java:43)
at IncomingSMSController.init(IncomingSMSController.java:35)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:916)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.jav
-->
the way i code my program is as follow:
<!--
protected void init()throws ServletException{
try{
System.out.println("\n<<IN>>");
Registry reg=LocateRegistry.getRegistry();
System.out.println("\n<<"+reg+">>");
reg.rebind("ControllerInterface",this);
bound=true;
System.out.println("Server now bound to IncomingSMSController");
}catch(Exception e){
System.out.println("Error binding");
e.printStackTrace();
public static void main(String[] args)throws RemoteException,ServletException{
Controller con=new Controller();
con.init();
-->
Anyone please help thanks. i have been asking this question here for many time and no one reply may i know at least why?
thanks.Hi,
I see the java doc of LocateRegsitry and you can read :
LocateRegistry is used to obtain a reference to a bootstrap remote object registry on a particular host (including the local host), or
to create a remote object registry that accepts calls on a specific port.
Note that a getRegistry call does not actually make a
connection to the remote host. It simply creates a local reference to
the remote registry and will succeed even if no registry is running on
the remote host. Therefore, a subsequent method invocation to a remote
registry returned as a result of this method may fail.
So may be the exception, throw when you call rebind, is due to non active registry in local machine. You can try to execute your servlet
after activate your registry via LocateRegistry.createRegistry(int port)
Hope this help -
Java.io.EOFException while returning a large object using RMI
Hello
I am having an issue with RMI which seems to be quite common (given the given the amount of matches in Google) but for which I can find a way out.
In my application there 2 RMI objects , say OBJECT1 and OBJECT2. For OBJECT1 to get stuff from the database it gives a call to OBJECT2, which in turn fetches it from the DB and provides it back to OBJECT1.
It is in such a call from OBJECT1 that i get the following exception.
Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.EOFException
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:164)
at CALL FROM OBJECT1
... 13 more
Caused by: java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.readFully(ObjectInputStream.java:2571)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1824)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1759)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1603)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1271)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1603)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1271)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1835)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1759)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)
at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:297)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:146)
... 15 more
The rows retrieved from the DB are stored in a user-defined array (serializable incl. all the subcomponents except for the primitive data fields) and the same is return back from OBJECT2.
Interesting thing is that this exception occurs only when the number of rows retrieved by OBJECT2 is exceeds a certain limit, i.e. when the no. of rows are less the application works perfectly.
Tried the following based on what was mentioned in different posts: Added following parameters to the JVM startup call.
-Dsun.rmi.server.exceptionTrace=true - did not get any pointers
-Dsun.rmi.log.debug=true
-Dsun.rmi.transport.connectionTimeout=600000 - cause the time for the DB query was above the default time of 15 sec
I am using Sun j2sdk1.4.2_13 for the application.
Any pointers to resolve this issue would be greatly appreciated.ronpg wrote:
The issue is solved by increasing the VM max. memory parameters!if you want to avoid issues like this in the future, check out RMIIO. it provides an api for a "streaming remote iterator" over rmi, so you wouldn't have too read all this data into memory at once (causing memory exhaustion issues). -
Binding RMI-IIOP Remote Object in RMI Registry through JNDI
hi friends
I am writing RMI-IIOP Remote Object, both server program, and client program
are java programs. Through JNDI (with cosnaming name service), my program is working.
But what i want is, I want to use JNDI (with rmi registry name service) for my RMI-IIOP Remote Object ( and not RMI -JRMP Remote Object). Both my server
program and client programs are java(and not corba)
I am not getting this, while starting server its showing some error
Is it not possible to bind rmi-iiop remote object in rmi registry through jndi, whybecause you are supposed to use the COSNaming service with IIOP. Even if you could bind an IIOP remote object into an RMIRegistry the clients wouldn't be able to use it because the RMI Registry doesn't do the extra processing that the COSNaming service does with IIOP references.
Maybe you are looking for
-
Query Transported but doesnt reflect in target
Hi guys, I had an existing Query in Validation. In Development, I added 5 new free characteristics and redid some key figures. It got sucessfully transported but the problem is in Validation, I still see the old Query. (Not the new one with new free
-
How to get separators from a string
I need to find the thousand separator, hundred separator and decimal separator from a string. I need to check which separator is available in a string ie., thousand or hundred separator. There may be a case where there is no separators. Please sugges
-
Missing sapj2eeclient.jar?
We can no longer start Integration Repository in XI3.0. We get this error message: Unable to load resource: http://ourhost:port/rep/repository/sapj2eeclient.jar I have tried to redeploy SAPJ2EECLIENT.SDA but
-
For my Web application I don't want to allow the user to open the applicatin in new window(using Ctrl N or file New Window) Pls any body send the required code. Thanks in Advance Ramu
-
Olympus OMD EM1 Camera Profile Doesn't Show Up
I created a colorchecker passport profile for my new OMD EM1 camera and it doesn't show up in the list of camera profiles. At least one other person I know with this camera is reporting the same issue. I am on a brand new download of Lightroom 5.2.