Remote method arguments (RMI)
Configuration:
OC4J Release 2
JDeveloper 9i RC
Problem:
I get a "ClassNotFoundException" when passing objects as arguments to a remote method.
The object being passed implements an interface. The interface extends "Serializable" and it is available on the server (where the RMI class resides).
Appreciate any help on this.
Thanks,
Ranga
Found the solution. Thanx.
Similar Messages
-
can you please tell whatis wrong in the program.
//the interface
package com.nanotech.nanopos.synchronize.actions.user;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.security.Key;
import org.w3c.dom.Document;
public interface ISyncUser extends Remote {
public void updateUsers(Document d, Key keyEncryptKey) throws RemoteException;
}// the object
package com.nanotech.nanopos.synchronize.actions.user;
import com.nanotech.framework.Framework;
import com.nanotech.nanopos.user.bl.IUserBO;
import com.nanotech.nanopos.user.bl.UserBO;
import com.nanotech.nanopos.user.delegate.IUserDelegate;
import java.rmi.MarshalledObject;
import java.rmi.RemoteException;
import java.rmi.activation.Activatable;
import java.rmi.activation.ActivationID;
import java.security.Key;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import org.apache.xml.security.encryption.XMLCipher;
import org.apache.xml.security.utils.EncryptionConstants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class SyncUser extends Activatable implements ISyncUser{
Document d;
public SyncUser(ActivationID id, MarshalledObject data) throws RemoteException {
super(id, 0);
public void updateUsers(Document doc, Key keyEncryptKey) throws RemoteException {
try {
d = decryptFile(doc,keyEncryptKey);
Element root1 = d.getDocumentElement();
NodeList nusers = root1.getChildNodes();
Framework nanoFramework = Framework.getInstance();
IUserDelegate userDelegate = (IUserDelegate) nanoFramework.getBean("userDelegate");
for(int j=0; j < nusers.getLength(); j++){
Node n = nusers.item(j);
String s = n.getAttributes().getNamedItem("status").getNodeValue();
NodeList nl = n.getChildNodes();
IUserBO user = new UserBO();
user.setUserId(nl.item(0).getFirstChild().getNodeValue());
user.setUserName(nl.item(1).getFirstChild().getNodeValue());
user.setPassword(nl.item(2).getFirstChild().getNodeValue());
user.setRights(Integer.parseInt(nl.item(3).getFirstChild().getNodeValue()));
user.setStatus("S");
if(s.equalsIgnoreCase("A")){
userDelegate.addUser(user);
}else if(s.equalsIgnoreCase("E")){
userDelegate.updateUser(user);
}else if(s.equalsIgnoreCase("D")){
userDelegate.deleteUser(user.getUserId());
} catch (Exception ex) {
ex.printStackTrace();
public Document decryptFile(Document doc, Key EncryptKey) throws Exception{
// load the encrypted file into a Document
Document document = doc;
org.apache.xml.security.Init.init();
// get the encrypted data element
String namespaceURI = EncryptionConstants.EncryptionSpecNS;
String localName = EncryptionConstants._TAG_ENCRYPTEDDATA;
Element encryptedDataElement =
(Element)document.getElementsByTagNameNS(namespaceURI,
localName).item(0);
// Load the key encryption key.
String jceAlgorithmName = "DESede";
// File kekFile = new File(fileName);
DESedeKeySpec keySpec = new DESedeKeySpec(EncryptKey.getEncoded());
SecretKeyFactory skf = SecretKeyFactory.getInstance(jceAlgorithmName);
SecretKey key = skf.generateSecret(keySpec);
Key keyEncryptKey = key;
// initialize cipher
XMLCipher xmlCipher = XMLCipher.getInstance();
xmlCipher.init(XMLCipher.DECRYPT_MODE, null);
xmlCipher.setKEK(keyEncryptKey);
// do the actual decryption
xmlCipher.doFinal(document, encryptedDataElement);
return document;
//server
package com.nanotech.nanopos.synchronize.actions.server;
import com.nanotech.nanopos.synchronize.actions.user.ISyncUser;
import java.net.MalformedURLException;
import java.rmi.MarshalledObject;
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.rmi.activation.Activatable;
import java.rmi.activation.ActivationDesc;
import java.rmi.activation.ActivationException;
import java.rmi.activation.ActivationGroup;
import java.rmi.activation.ActivationGroupDesc;
import java.rmi.activation.ActivationGroupID;
import java.rmi.activation.UnknownGroupException;
import java.util.Properties;
public class SyncUserServer {
public SyncUserServer(){
try {
System.setSecurityManager(new RMISecurityManager());
Properties props = new Properties();
props.put("java.security.policy", "com/nanotech/nanopos/synchronize/actions/security/security.policty");
ActivationGroupDesc.CommandEnvironment ace = null;
ActivationGroupDesc exampleGroup = new ActivationGroupDesc(props, ace);
ActivationGroupID agi =
ActivationGroup.getSystem().registerGroup(exampleGroup);
String location = "file:com/nanotech/nanopos/synchronize/actions/user/";
MarshalledObject data = null;
ActivationDesc desc = new ActivationDesc
(agi, "com.nanotech.nanopos.synchronize.actions.user.SyncUser",location, data);
ISyncUser syncUser = (ISyncUser)Activatable.register(desc);
System.out.println("Got the stub for SyncUser");
Naming.rebind("SyncUser1", syncUser);
System.out.println("Exported from registration");
} catch (RemoteException ex) {
ex.printStackTrace();
} catch (UnknownGroupException ex) {
ex.printStackTrace();
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (ActivationException ex) {
ex.printStackTrace();
}//the client
package com.nanotech.nanopos.synchronize.actions.user;
import com.nanotech.framework.Framework;
import com.nanotech.framework.action.IAction;
import com.nanotech.nanopos.controller.NanoPOSController;
import com.nanotech.nanopos.user.bl.IUserBO;
import com.nanotech.nanopos.user.delegate.IUserDelegate;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.ArrayList;
import java.util.Iterator;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerFactoryConfigurationError;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.security.Key;
import javax.crypto.SecretKey;
import javax.crypto.KeyGenerator;
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.encryption.XMLCipher;
import org.apache.xml.security.encryption.EncryptedData;
import org.apache.xml.security.encryption.EncryptedKey;
public class UserSyncAction implements IAction {
public void execute(Object controller) throws Exception {
NanoPOSController nanoPOSController = (NanoPOSController) controller;
Framework nanoFramework = Framework.getInstance();
IUserDelegate userDelegate = (IUserDelegate) nanoFramework.getBean("userDelegate");
ArrayList users = userDelegate.getAllUnSyncUsers();
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
org.w3c.dom.Document d = db.newDocument();
Element root = d.createElement("nanoPOS");
Iterator i = users.iterator();
while(i.hasNext()){
Element user = d.createElement("user");
IUserBO userBO = (IUserBO) i.next();
Element userId = d.createElement("userid");
Element userName = d.createElement("username");
Element password = d.createElement("password");
Element rights = d.createElement("rights");
userId.appendChild(d.createTextNode(userBO.getUserId()));
userName.appendChild(d.createTextNode(userBO.getUserName()));
password.appendChild(d.createTextNode(userBO.getPassword()));
rights.appendChild(d.createTextNode(userBO.getRights().toString()));
user.appendChild(userId);
user.appendChild(userName);
user.appendChild(password);
user.appendChild(rights);
Attr status = d.createAttribute("status");
status.setValue(userBO.getStatus());
user.setAttributeNode(status);
root.appendChild(user);
d.appendChild(root);
Registry reg = LocateRegistry.getRegistry();
ISyncUser syncUser = (ISyncUser) reg.lookup("SyncUser");
syncUser.updateUsers(encryptFile(d),keyEncryptKey);
} catch (DOMException ex) {
ex.printStackTrace();
} catch (ParserConfigurationException ex) {
ex.printStackTrace();
} catch (TransformerFactoryConfigurationError ex) {
ex.printStackTrace();
private Key GenerateSymmetricKey() throws Exception {
String jceAlgorithmName = "AES";
KeyGenerator keyGenerator =
KeyGenerator.getInstance(jceAlgorithmName);
keyGenerator.init(128);
return keyGenerator.generateKey();
private SecretKey GenerateKeyEncryptionKey() throws Exception {
String jceAlgorithmName = "DESede";
KeyGenerator keyGenerator =
KeyGenerator.getInstance(jceAlgorithmName);
SecretKey keyEncryptKey = keyGenerator.generateKey();
return keyEncryptKey;
private void storeKeyFile(Key keyEncryptKey) throws IOException {
byte[] keyBytes = keyEncryptKey.getEncoded();
File keyEncryptKeyFile = new File("keyEncryptKey");
FileOutputStream outStream = new FileOutputStream(keyEncryptKeyFile);
outStream.write(keyBytes);
outStream.close();
System.out.println("Key encryption key stored in: "
+ keyEncryptKeyFile.toURL().toString());
Key keyEncryptKey;
public Document encryptFile(Document d) throws Exception{
org.apache.xml.security.Init.init();
// generate symmetric key
Key symmetricKey = GenerateSymmetricKey();
// Get a key to be used for encrypting the symmetric key
keyEncryptKey = GenerateKeyEncryptionKey();
// Write the key to a file
storeKeyFile(keyEncryptKey);
// initialize cipher
XMLCipher keyCipher =
XMLCipher.getInstance(XMLCipher.TRIPLEDES_KeyWrap);
keyCipher.init(XMLCipher.WRAP_MODE, keyEncryptKey);
// encrypt symmetric key
EncryptedKey encryptedKey = keyCipher.encryptKey(d, symmetricKey);
// specify the element to encrypt
Element elementToEncrypt = d.getDocumentElement();
// initialize cipher
XMLCipher xmlCipher =
XMLCipher.getInstance(XMLCipher.AES_128);
xmlCipher.init(XMLCipher.ENCRYPT_MODE, symmetricKey);
// add key info to encrypted data element
EncryptedData encryptedDataElement =
xmlCipher.getEncryptedData();
KeyInfo keyInfo = new KeyInfo(d);
keyInfo.add(encryptedKey);
encryptedDataElement.setKeyInfo(keyInfo);
// do the actual encryption
boolean encryptContentsOnly = true;
xmlCipher.doFinal(d,elementToEncrypt,encryptContentsOnly);
return d;
}//policy file
grant {
Permission java.security.AllPermission;
//command used to run the program
first i start the rmiregistryby the following command
start rmiregisry
the rmid deamon
start rmid -J-Djava.security.policy=com\nanotech\nanopos\synchronize\actions\security\security.policy
when i arn the program i getting the following exception
java.rmi.activation.ActivateFailedException: activation failed; nested exception is:
java.rmi.activation.ActivationException: Activatable object must provide an activation constructor; nested exception is:
java.lang.NoSuchMethodException: com.nanotech.nanopos.synchronize.actions.user.SyncUser.<init>(java.rmi.activation.ActivationID, java.rmi.MarshalledObject)
at sun.rmi.server.ActivatableRef.activate(ActivatableRef.java:285)
at sun.rmi.server.ActivatableRef.invoke(ActivatableRef.java:114)
at com.nanotech.nanopos.synchronize.actions.user.SyncUser_Stub.updateUsers(Unknown Source)
at com.nanotech.nanopos.synchronize.actions.user.UserSyncAction.execute(UserSyncAction.java:86)
at com.nanotech.nanopos.controller.NanoPOSController.actionPerformed(NanoPOSController.java:582)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1766)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.rmi.activation.ActivationException: Activatable object must provide an activation constructor; nested exception is:
java.lang.NoSuchMethodException: com.nanotech.nanopos.synchronize.actions.user.SyncUser.<init>(java.rmi.activation.ActivationID, java.rmi.MarshalledObject)
at sun.rmi.server.ActivationGroupImpl.newInstance(ActivationGroupImpl.java:273)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at java.rmi.activation.ActivationGroup_Stub.newInstance(Unknown Source)
at sun.rmi.server.Activation$ObjectEntry.activate(Activation.java:1277)
at sun.rmi.server.Activation$GroupEntry.activate(Activation.java:972)
at sun.rmi.server.Activation$ActivatorImpl.activate(Activation.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:179)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
at $Proxy17.activate(Unknown Source)
at java.rmi.activation.ActivationID.activate(ActivationID.java:96)
at sun.rmi.server.ActivatableRef.activate(ActivatableRef.java:258)
... 28 more
Caused by: java.lang.NoSuchMethodException: com.nanotech.nanopos.synchronize.actions.user.SyncUser.<init>(java.rmi.activation.ActivationID, java.rmi.MarshalledObject)
at java.lang.Class.getConstructor0(Class.java:2647)
at java.lang.Class.getDeclaredConstructor(Class.java:1953)
at sun.rmi.server.ActivationGroupImpl$1.run(ActivationGroupImpl.java:228)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.server.ActivationGroupImpl.newInstance(ActivationGroupImpl.java:222)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)i have done what u have said no i am getting following exception.
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:203)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at sun.rmi.server.ActivatableRef.invoke(ActivatableRef.java:124)
at com.nanotech.nanopos.synchronize.actions.user.SyncUser_Stub.updateUsers(Unknown Source)
at com.nanotech.nanopos.synchronize.actions.user.UserSyncAction.execute(UserSyncAction.java:85)
at com.nanotech.nanopos.controller.NanoPOSController.actionPerformed(NanoPOSController.java:582)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1766)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:243)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:189)
... 29 more
also on the rmid console i am getting the following exception.
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:Exception in thread "RMI TCPConnection(2)-192.168.0.4" java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.4:1630 accept,resolve)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at java.security.AccessController.checkPermission(AccessController.java:427)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at java.lang.SecurityManager.checkAccept(SecurityManager.java:1157)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.checkAcceptPermission(TCPTransport.java:560)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at sun.rmi.transport.tcp.TCPTransport.checkAcceptPermission(TCPTransport.java:208)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at sun.rmi.transport.Transport$1.run(Transport.java:152)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at java.security.AccessController.doPrivileged(Native Method)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at java.lang.Thread.run(Thread.java:595)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:Exception in thread "RMI TCPConnection(2)-192.168.0.4" java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.4:1641 accept,resolve)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at java.security.AccessController.checkPermission(AccessController.java:427)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at java.lang.SecurityManager.checkAccept(SecurityManager.java:1157)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.checkAcceptPermission(TCPTransport.java:560)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at sun.rmi.transport.tcp.TCPTransport.checkAcceptPermission(TCPTransport.java:208)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at sun.rmi.transport.Transport$1.run(Transport.java:152)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at java.security.AccessController.doPrivileged(Native Method)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
Sat Jul 01 16:07:32 GMT+05:00 2006:ExecGroup-1:err:at java.lang.Thread.run(Thread.java:595)
Sat Jul 01 16:06:24 GMT+05:00 2006:ExecGroup-0:err:at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
Message was edited by:
abdulKhaliq
Message was edited by:
abdulKhaliq -
NullPointerException while calling a Remote Method
I have got the following exception wh�le calling a remote method,
do you have any idea?
java.lang.NullPointerException
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
at distributedchess.server.ChessGameImpl_Stub.applyAction(ChessGameImpl_Stub.java:53)Looks to me like your server has a bug in a remote method.
-
Is RMI the right choice for developing a remote desktop application (sending mouse and keys events and receive screen shots) ?
That's not a reason, that's just a (fallacious) assertion about using RMI for anything. In fact, 'managing the RMI server' is probably the easiest part of RMI.
The reason I said it isn't appropriate is that the communications primitives you need can't be sensibly expressed as procedure calls. You have a stream of screen information flowing between the remote and the peer, and you may have occasional keyboard/mouse events going the other way if you implement remote control. RMI is a completely inappropriate choice for this. -
Connection problem while invoking remote method from client using oracle 8.1.6 server
while using a connection object to make connection to oracle in all remote methods(in EJB)only the first remote method called from the EJB client is getting invoked and the connection stops.It gives me COMM_FAILURE while invoking the second method in oracle 8.1.6.Help me out in this aspect immediately please.
r singh wrote:
>
I am getting "No Suitable Driver" exception from WebLogic 6.1 (sp1) at
the start up of the server.
My settings:
- WLS 6.1 on a solaris 8 machine and Oracle 8.1.6 on a WIN2K machine.
- I created the connection pool for oracle with the following
parameters:
connection name: OracleConnectionPool
url: jdbc.oracle.thin:@myOracleServer:1521:myDBName
driver class name: oracle.jdbc.driver.OracleDriver
properties: user=scott
password=tiger
- I have also downloaded classes12.zip and nls_charset12.zip from
Oracle.com
and have placed under $WL_HOME/lib.
- I have added $WL_HOME/lib/classes12.zip:$WL_HOME/lib/nls_charset12.zip
in
front of the $CLASSPATH in the startWeblogic.sh script. The echoed
classpath
from the startup script is:
/opt/tools/bea/wlserver6.1/lib/classes12.zip:/opt/tools/bea/wlserver6.1/lib/nls_
charset12.zip:/opt/tools/bea/wlserver6.1:/opt/tools/bea/wlserver6.1/lib/weblogic
_sp.jar:/opt/tools/bea/wlserver6.1/lib/weblogic.jar
- Still I get the error:
<Jan 16, 2002 1:38:45 PM EST> <Error> <JDBC> <Cannot startup
connection pool "Or
acleConnectionPool" No suitable driver>
Can somebody point me out if i am doing anything wrong here.
Thanks.
RamanandHi,
Sure. Your URL should be "jdbc:oracle:thin:@myOracleServer:1521:myDBName"
not "jdbc.oracle.thin:@myOracleServer:1521:myDBName"
Joe -
Flex Data Services does not see remote methods in extended ColdFusion component.
I have created a remote service base component as a AModelService.cfc file. I extend that file to make my ModelService.cfc. When I configure the ColdFusion data service and point to ModelService.cfc and click next, I don't see any remote methods (there are none explicitly defined in the component) in the Service Operations window.
If I go back and point to AModelServide.cfc, the parent component, and hit next, I see all the remote methods that are defined in the parent component. So, either I am doing something wrong, or Data Services does not look at methods up the cfc prototype chain, which from an OOP standpoint means that instead of say creating one restful base class and being nice and DRY you can't. I.e. not OOP for data services. Is this a bug, or what?
Anybody get data services to work with extended service components?
MarkThanks for the reply. Yes, I did compile all the Java and it
works OK with a simple Java program. It just will not work in a
Flex application.
The java classes are:
RRA:
package blah.myPackage;
import java.util.List;
import java.util.Collection;
import flex.data.DataSyncException;
import flex.data.assemblers.AbstractAssembler;
class RRA extends AbstractAssembler
public Collection fill( List fillParameters )
RRS service = new RRS();
return service.getSome();
RRS:
package blah.myPackage;
import java.util.ArrayList;
import java.util.List;
import java.sql.*;
import flex.EORS.*;
class RRS
public List getSome()
ArrayList list = new ArrayList();
String str = "bob";
RR rr = new RR(str);
list.add(rr);
return list;
RR:
package blah.myPackage;
class RR
private String name;
public RR() { }
public RR(String name)
this.name = name;
public String getName()
return this.name;
public void setName(String name)
this.name = name;
I started with something that retrieved data from a database
but watered it down just to try and get some kind of communication
between Flex and Java. -
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 -
Exception data: java.lang.AbstractMethodError - Calling Remote Method.
We recently changed some of our CMP fields from primative int's to integer's and now we are receiving Abstract Method Errors at runtime. We have fixed all the methods that use this CMP fields, well at least we think we got them all. Since this are remote methods the sever is setup to pull JAR files from a lib directory on the server. This JAR files have also been updated. Can anyone give me more information about this error or something I might be missing.
------------------------------------------------------------------------------------- Errors -------------------------------------------------------------------------------------
[11/7/07 15:40:23:141 CST] 00000022 ExceptionUtil E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "getPositionInfo" on bean "BeanId(hr-ear#hr-ejb.jar#PositionService, null)". Exception data: java.lang.AbstractMethodError: com/tgt/supply/pdd/ejb/entity/AmcOffice.getOfcI()Ljava/lang/Integer;
at com.theamc.hr.ejb.session.PositionServiceBean.getPositionCollections(PositionServiceBean.java:1383)
at com.theamc.hr.ejb.session.PositionServiceBean.getPositionInfo(PositionServiceBean.java:46)
at com.theamc.hr.ejb.session.EJSRemoteStatelessPositionService_fae72574.getPositionInfo(EJSRemoteStatelessPositionService_fae72574.java:262)
at com.theamc.hr.ejb.session._PositionService_Stub.getPositionInfo(_PositionService_Stub.java:272)
at com.theamc.hr.web.servlet.PositionServlet.createPageObject(PositionServlet.java:153)
at com.theamc.framework.servlet.ControllerServlet.doGet(ControllerServlet.java:221)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
[11/7/07 15:34:10:043 CST] 00000020 ExceptionUtil E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "getUserOrgInfo" on bean "BeanId(userprofile-ear#userprofile-ejb.jar#UserOrgInfo, null)". Exception data: java.lang.AbstractMethodError: com/tgt/supply/pdd/ejb/entity/AmcOffice.getOfcI()Ljava/lang/Integer;
at com.theamc.userprofile.ejb.session.UserOrgInfoBean.getUserOfficeValue(UserOrgInfoBean.java:536)
at com.theamc.userprofile.ejb.session.UserOrgInfoBean.getUserOrgInfo(UserOrgInfoBean.java:84)
at com.theamc.userprofile.ejb.session.EJSRemoteStatelessUserOrgInfo_13c2e095.getUserOrgInfo(EJSRemoteStatelessUserOrgInfo_13c2e095.java:194)
at com.theamc.userprofile.ejb.session._UserOrgInfo_Stub.getUserOrgInfo(_UserOrgInfo_Stub.java:273)
at com.theamc.userprofile.servlet.UserOrgInfoServlet.createPageObject(UserOrgInfoServlet.java:243)
at com.theamc.framework.servlet.ControllerServlet.doGet(ControllerServlet.java:221)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
------------------------------------------------------------------------------------- Usage -------------------------------------------------------------------------------------
HashMap ofcRegn = new HashMap();
AmcOffice off = null;
AmcOfficeHome offHome = com.tgt.supply.pdd.ejb.entity.EntityHomeFactory.getAmcOfficeHome();
ArrayList ofcColl = new ArrayList();
Iterator iter = offHome.findAll().iterator();
while (iter.hasNext()) {
off = (AmcOffice) PortableRemoteObject.narrow(iter.next(), AmcOffice.class);
ofcColl.add(new GenericCode(""+off.getOfcI(),off.getOfcN())); line 1383
ofcRegn.put(""+off.getOfcI(),""+off.getRegnI());
The abstract method error is thrown when off.getOfcI() is called. OfcI is the field that was changed from a primative int to an integer.
Any help is appreciated
ChrisI am pretty sure. I am using RAD locally so I have deleted all the generated AccessBean and Deployment code and rerun the deploy. My concern is that these remote methods are using an external JAR file which is loaded when the server is started. I have updated this JAR files, but I am not sure if maybe they are being cached some where.
-
I have a static method in my class .
Now i want to change my class to Distributed class
So what to do with that static method ...
I can't take in interface , so how i can call that method
Sunil VirmaniThe pre condition of all the remote methods is that they should have been declared in the interface implementing RemoteInterface. Now its been discussed in detail in this forum already why we cannot have static methods declared in the interface therefore by nature not being polymorphic u cannot use static methods for the aforesaid purpose.
-
Hi,
Read a lot of forums about how to create a Remote file browser using RMI and JFileChooser.
Not done any RMI coding I thought I'd give it a try. I have finally after 2 days managed to do it.
This is an overview.
Create a RemoteFile class that extends Remote.. eg.
import java.rmi.*;
import java.io.*;
import java.net.*;
public interface RemoteFile extends Remote {
public boolean canRead() throws RemoteException;
public boolean canWrite() throws RemoteException;
public int compareTo(File pathname) throws RemoteException;etc.etc
Then create an implementation class...
import java.rmi.server.*;
import java.io.*;
import java.net.*;
public class RemoteFileImpl extends UnicastRemoteObject implements RemoteFile {
private File f;
public RemoteFileImpl(File sf) throws java.rmi.RemoteException {
f=sf;
public boolean canRead() throws java.rmi.RemoteException {
return f.canRead();
}etc etc for all other File functions.
Then we create a RemoteFileSystemView interface, again extending remote...
public interface RemoteFileSystemView extends Remote {
public RemoteFile createFileObject(File dir, String filename) throws RemoteException;
public RemoteFile createFileObject(String path) throws RemoteException;blah blah
Then An implementation class...
import javax.swing.filechooser.*;
import java.io.*;
public class RemoteFileSystemViewImpl extends java.rmi.server.UnicastRemoteObject implements RemoteFileSystemView {
int length;
private FileSystemView fs;
public RemoteFileSystemViewImpl() throws java.rmi.RemoteException {
fs=FileSystemView.getFileSystemView();
public RemoteFile createFileObject(String path) throws java.rmi.RemoteException {
return new RemoteFileImpl(fs.createFileObject(path));
public RemoteFile createFileObject(java.io.File dir, String filename) throws java.rmi.RemoteException {
return new RemoteFileImpl(fs.createFileObject(dir,filename));
//public RemoteFileImpl createFileSystemRoot(java.io.File f) throws java.rmi.RemoteException {
// return new RemoteFileImpl(fs.createFileSystemRoot(f));
public RemoteFile createNewFolder(java.io.File containingDir) throws java.rmi.RemoteException {
RemoteFile tempf;
try{
tempf= new RemoteFileImpl(fs.createNewFolder(containingDir));
} catch (IOException e){System.out.println(e); tempf=null;}
return tempf;
public RemoteFile getDefaultDirectory() throws java.rmi.RemoteException {
return new RemoteFileImpl(fs.getDefaultDirectory());
public String[] getFiles(java.io.File dir, boolean useFileHiding) throws java.rmi.RemoteException {
String[] tempf= new String[fs.getFiles(dir,useFileHiding).length];
int i;
File[] f = fs.getFiles(dir,useFileHiding);
for(i=0;i<tempf.length;i++) tempf=f[i].toString();
return tempf;
public RemoteFile getHomeDirectory() throws java.rmi.RemoteException {
return new RemoteFileImpl(fs.getHomeDirectory());
public RemoteFile getParentDirectory(java.io.File dir) throws java.rmi.RemoteException {
return new RemoteFileImpl(fs.getParentDirectory(dir));
public String[] getRoots() throws java.rmi.RemoteException {
String[] tempf= new String[fs.getRoots().length];
System.out.println("fs is-"+fs.getRoots().length);
int i;
File[] f = fs.getRoots();
for(i=0;i<tempf.length;i++) {tempf[i]=f[i].toString();}
System.out.println("Roots="+tempf[0]);
return tempf;
public String getSystemDisplayName(java.io.File f) throws java.rmi.RemoteException {
return fs.getSystemDisplayName(f);
public javax.swing.Icon getSystemIcon(java.io.File f) throws java.rmi.RemoteException {
return fs.getSystemIcon(f);
public String getSystemTypeDescription(java.io.File f) throws java.rmi.RemoteException {
return fs.getSystemTypeDescription(f);
public boolean isComputerNode(java.io.File dir) throws java.rmi.RemoteException {
return fs.isComputerNode(dir);
public boolean isDrive(java.io.File dir) throws java.rmi.RemoteException {
return fs.isDrive(dir);
public boolean isFileSystem(java.io.File f) throws java.rmi.RemoteException {
return fs.isFileSystem(f);
public boolean isFileSystemRoot(java.io.File dir) throws java.rmi.RemoteException {
return fs.isFileSystemRoot(dir);
public boolean isFloppyDrive(java.io.File dir) throws java.rmi.RemoteException {
return fs.isFloppyDrive(dir);
public boolean isHiddenFile(java.io.File f) throws java.rmi.RemoteException {
return fs.isHiddenFile(f);
public boolean isParent(java.io.File folder, java.io.File file) throws java.rmi.RemoteException {
return fs.isParent(folder,file);
public boolean isRoot(java.io.File f) throws java.rmi.RemoteException {
return fs.isRoot(f);
public Boolean isTraversable(java.io.File f) throws java.rmi.RemoteException {
return fs.isTraversable(f);
public RemoteFile getChild(File parent, String fileName) throws java.rmi.RemoteException {
return new RemoteFileImpl(fs.getChild(parent,fileName));
Notice that whenever I should be passing a File, I pass a RemoteFile instead! Also.. when I am passing a File Array, I instead pass a String array. Reason is.. I havent managed to get File arrays through RMI.. Any Help anyone?!?!?!?!
I got round it by simply passing a String array and relying on the client to reconstruct a File array locally using the String array. Messy... perhaps.. any suggestions welcome!
Next.. use rmic to create Stubs and Skels for the 2 implementations and write an RMI server.. eg.
import java.rmi.Naming;
public class RemoteServerRMI {
/** Creates a new instance of RemoteServerRMI */
public RemoteServerRMI() {
try {
RemoteFileSystemView c = new RemoteFileSystemViewImpl();
Naming.rebind("rmi://localhost:1099/FileService", c);
} catch (Exception e) {
System.out.println("Trouble: " + e);
public static void main(String[] args) {
new RemoteServerRMI();
}Yes.. simple and shamelessly lifted from the tutorials.
and Finally the client....
import javax.swing.filechooser.*;
import java.rmi.*;
import java.net.MalformedURLException;
import java.io.*;
import javax.swing.*;
public class RemoteFileSystemViewClient extends FileSystemView {
static RemoteFileSystemView c;
public RemoteFileSystemViewClient() {
try {
c = (RemoteFileSystemView) Naming.lookup("rmi://localhost:1099/FileService");
catch (MalformedURLException murle) {
System.out.println();
System.out.println(
"MalformedURLException");
System.out.println(murle);
catch (RemoteException re) {
System.out.println();
System.out.println(
"RemoteException");
System.out.println(re);
catch (NotBoundException nbe) {
System.out.println();
System.out.println(
"NotBoundException");
System.out.println(nbe);
public File getHomeDirectory() {
File tempf;
try {
tempf= new File(c.getHomeDirectory().gettoString());
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public File createFileObject(File dir, String filename) {
File tempf;
try {
tempf= new File(c.createFileObject(dir, filename).gettoString());
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public File createFileObject(String path) {
File tempf;
try {
tempf=new File(c.createFileObject(path).gettoString());
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public File createNewFolder(File containingDir) throws RemoteException {
File tempf;
try {
tempf=new File(c.createNewFolder(containingDir).getAbsolutePath());
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public File getChild(File parent, String fileName) {
File tempf;
try {
tempf=new File(c.getChild(parent,fileName).gettoString());
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public File getDefaultDirectory() {
File tempf;
try {
tempf=new File(c.getDefaultDirectory().gettoString());
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public File[] getFiles(File dir, boolean useFileHiding) {
File[] tempf;
try {
tempf=new File[c.getFiles(dir,useFileHiding).length];
String[] rtempf=c.getFiles(dir, useFileHiding);
int i;
for(i=0;i<c.getFiles(dir, useFileHiding).length;i++) tempf=new File(rtempf[i]);
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public File getParentDirectory(File dir) {
File tempf;
try {
tempf= new File(c.getParentDirectory(dir).gettoString());
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public File[] getRoots(){
File[] tempf;
try {
String[] rtempf= c.getRoots();
System.out.println("in");
tempf=new File[rtempf.length];
int i;
for(i=0;i<c.getRoots().length;i++) tempf[i]=new File(rtempf[i]);
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public String getSystemDisplayName(File f) {
String tempf;
try{
tempf=c.getSystemDisplayName(f);
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public javax.swing.Icon getSystemIcon(File f) {
javax.swing.Icon tempf;
try{
tempf=c.getSystemIcon(f);
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public String getSystemTypeDescription(File f) {
String tempf;
try {
tempf=c.getSystemTypeDescription(f);
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public boolean isComputerNode(File dir) {
boolean tempf;
try {
tempf= c.isComputerNode(dir);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isDrive(File dir) {
boolean tempf;
try {
tempf= c.isDrive(dir);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isFileSystem(File f) {
boolean tempf;
try {
tempf= c.isFileSystem(f);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isFileSystemRoot(File dir) {
boolean tempf;
try {
tempf= c.isFileSystemRoot(dir);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isFloppyDrive(File dir) {
boolean tempf;
try {
tempf= c.isFloppyDrive(dir);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isHiddenFile(File f) {
boolean tempf;
try {
tempf= c.isHiddenFile(f);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isParent(File folder, File file) {
boolean tempf;
try {
tempf= c.isParent(folder,file);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isRoot(File f) {
boolean tempf;
try {
tempf= c.isRoot(f);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public Boolean isTraversable(File f) {
Boolean tempf;
try {
tempf= c.isTraversable(f);
} catch (RemoteException re){System.out.println(re);tempf=new Boolean(false);}
return tempf;
public static void main(String[] args) {
RemoteFileSystemViewClient rc = new RemoteFileSystemViewClient();
JFileChooser fch= new JFileChooser(rc);
fch.showOpenDialog(null);
Notice.. the getFiles and getRoots, procedures, get String arrays from the RMI and reconstruct local File arrays.
I managed to browse up and down directories with this, and even.. to my surprise, create folders!
If you got any improvements please let me know at [email protected]Copyright © Esmond Pitt, 2007. All rights reserved.
* RemoteFileSystem.java
* Created on 13 May 2007, 14:39
import java.io.File;
import java.io.IOException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import javax.swing.Icon;
* @author Esmond Pitt
public interface RemoteFileSystem extends Remote
File createFileObject(String path) throws RemoteException;
File[] getFiles(File dir, boolean useFileHiding) throws RemoteException;
File createFileObject(File dir, String filename) throws RemoteException;
File getChild(File parent, String fileName) throws RemoteException;
boolean isFloppyDrive(File dir) throws RemoteException;
boolean isFileSystemRoot(File dir) throws RemoteException;
boolean isFileSystem(File f) throws RemoteException;
boolean isDrive(File dir) throws RemoteException;
boolean isComputerNode(File dir) throws RemoteException;
File createNewFolder(File containingDir) throws RemoteException, IOException;
File getParentDirectory(File dir) throws RemoteException;
String getSystemDisplayName(File f) throws RemoteException;
Icon getSystemIcon(File f) throws RemoteException;
String getSystemTypeDescription(File f) throws RemoteException;
File getDefaultDirectory() throws RemoteException;
File getHomeDirectory() throws RemoteException;
File[] getRoots() throws RemoteException;
// File createFileSystemRoot(File f) throws RemoteException;
import java.io.File;
import java.io.IOException;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Icon;
import javax.swing.filechooser.FileSystemView;
* @author Esmond Pitt
* @version $Revision: 3 $
public class RemoteFileSystemServer extends UnicastRemoteObject implements RemoteFileSystem
private FileSystemView fs = FileSystemView.getFileSystemView();
private Logger logger = Logger.getLogger(this.getClass().getName());
/** Creates a new instance of RemoteFileSystemServer */
public RemoteFileSystemServer(int port) throws RemoteException
super(port);
logger.log(Level.INFO, "exported on port {0} and receiving calls fs={1}", new Object[]{port, fs});
public File createFileObject(String path)
logger.log(Level.FINE, "createFileObject({0})", path);
return fs.createFileObject(path);
public File createFileObject(File dir, String filename)
logger.log(Level.FINE, "createFileObject({0},{1})", new Object[]{dir, filename});
return fs.createFileObject(dir, filename);
public File[] getFiles(File dir, boolean useFileHiding)
logger.log(Level.FINE, "getFiles({0},{1})", new Object[]{dir, useFileHiding});
return fs.getFiles(dir, useFileHiding);
public File getChild(File parent, String fileName)
logger.log(Level.FINE, "getChild({0},{1})", new Object[]{parent, fileName});
return fs.getChild(parent, fileName);
public boolean isFloppyDrive(File dir)
logger.log(Level.FINE, "isFloppyDrive({0})", dir);
return fs.isFloppyDrive(dir);
public boolean isFileSystemRoot(File dir)
logger.log(Level.FINE, "isFileSystemRoot({0})", dir);
return fs.isFileSystemRoot(dir);
public boolean isFileSystem(File f)
logger.log(Level.FINE, "isFileSystem({0})", f);
return fs.isFileSystem(f);
public boolean isDrive(File dir)
logger.log(Level.FINE, "isDrive({0})", dir);
return fs.isDrive(dir);
public boolean isComputerNode(File dir)
logger.log(Level.FINE, "isComputerNode({0})", dir);
return fs.isComputerNode(dir);
public File createNewFolder(File containingDir) throws IOException
logger.log(Level.FINE, "createNewFolder({0})", containingDir);
return fs.createNewFolder(containingDir);
public File getParentDirectory(File dir)
logger.log(Level.FINE, "getParentDirectory({0})", dir);
return fs.getParentDirectory(dir);
public String getSystemDisplayName(File f)
logger.log(Level.FINE, "getSystemDisplayName({0})", f);
return fs.getSystemDisplayName(f);
public Icon getSystemIcon(File f)
logger.log(Level.FINE, "getSystemIcon({0})", f);
return fs.getSystemIcon(f);
public String getSystemTypeDescription(File f)
logger.log(Level.FINE, "getSystemTypeDescription({0})", f);
return fs.getSystemTypeDescription(f);
public File getDefaultDirectory()
logger.log(Level.FINE, "getDefaultDirectory()");
return fs.getDefaultDirectory();
public File getHomeDirectory()
logger.log(Level.FINE, "getHomeDirectory()");
return fs.getHomeDirectory();
public File[] getRoots()
logger.log(Level.FINE, "getRoots()");
return fs.getRoots();
public File createFileSystemRoot(File f)
return fs.createFileSystemRoot(f);
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Icon;
import javax.swing.filechooser.FileSystemView;
* @author Esmond Pitt
* @version $Revision: 4 $
public class RemoteFileSystemView extends FileSystemView
private Logger logger = Logger.getLogger(this.getClass().getName());
private RemoteFileSystem fs;
public RemoteFileSystemView(String host)
throws NotBoundException, RemoteException, MalformedURLException
String url = "rmi://"+host+"/"+RemoteFileSystem.class.getName();
this.fs = (RemoteFileSystem)Naming.lookup(url);
logger.log(Level.INFO, "Connected to {0} via {1}", new Object[]{url, fs});
public File createFileObject(String path)
logger.entering(this.getClass().getName(), "createFileObject", path);
try
return fs.createFileObject(path);
catch (RemoteException exc)
logger.log(Level.SEVERE, "path="+path, exc);
return null;
public File[] getFiles(File dir, boolean useFileHiding)
logger.entering(this.getClass().getName(), "getFiles", new Object[]{dir, useFileHiding});
try
return fs.getFiles(dir, useFileHiding);
catch (RemoteException exc)
logger.log(Level.SEVERE, "dir="+dir+" useFileHiding="+useFileHiding, exc);
return null;
public File createFileObject(File dir, String filename)
logger.entering(this.getClass().getName(), "createFileObject", new Object[]{dir, filename});
try
return fs.createFileObject(dir, filename);
catch (RemoteException exc)
logger.log(Level.SEVERE, "dir="+dir+" filename="+filename, exc);
return null;
public File getChild(File parent, String fileName)
logger.entering(this.getClass().getName(), "getChild", new Object[]{parent, fileName});
try
return fs.getChild(parent, fileName);
catch (RemoteException exc)
logger.log(Level.SEVERE, "parent="+parent+" fileName="+fileName, exc);
return null;
public boolean isFloppyDrive(File dir)
logger.entering(this.getClass().getName(), "isFloppyDrive", dir);
try
return fs.isFloppyDrive(dir);
catch (RemoteException exc)
logger.log(Level.SEVERE, "dir="+dir, exc);
return false;
public boolean isFileSystemRoot(File dir)
logger.entering(this.getClass().getName(), "isFileSystemRoot", dir);
try
return fs.isFileSystemRoot(dir);
catch (RemoteException exc)
logger.log(Level.SEVERE, "dir="+dir, exc);
return false;
public boolean isFileSystem(File file)
logger.entering(this.getClass().getName(), "isFileSystem", file);
try
return fs.isFileSystem(file);
catch (RemoteException exc)
logger.log(Level.SEVERE, "file="+file, exc);
return false;
public boolean isDrive(File dir)
logger.entering(this.getClass().getName(), "isDrive", dir);
try
return fs.isDrive(dir);
catch (RemoteException exc)
logger.log(Level.SEVERE, "dir="+dir, exc);
return false;
public boolean isComputerNode(File dir)
logger.entering(this.getClass().getName(), "isComputerNode", dir);
try
return fs.isComputerNode(dir);
catch (RemoteException exc)
logger.log(Level.SEVERE, "dir="+dir, exc);
return false;
public File createNewFolder(File containingDir) throws IOException
logger.entering(this.getClass().getName(), "createNewFolder", containingDir);
try
return fs.createNewFolder(containingDir);
catch (RemoteException exc)
logger.log(Level.SEVERE, "containingDir="+containingDir, exc);
return null;
public File getParentDirectory(File dir)
logger.entering(this.getClass().getName(), "getParentDirectory", dir);
try
return fs.getParentDirectory(dir);
catch (RemoteException exc)
logger.log(Level.SEVERE, "dir="+dir, exc);
return null;
public String getSystemDisplayName(File file)
logger.entering(this.getClass().getName(), "getSystemDisplayName", file);
try
return fs.getSystemDisplayName(file);
catch (RemoteException exc)
logger.log(Level.SEVERE, "file="+file, exc);
return null;
public Icon getSystemIcon(File file)
logger.entering(this.getClass().getName(), "getSystemIcon", file);
try
return fs.getSystemIcon(file);
catch (RemoteException exc)
logger.log(Level.SEVERE, "file="+file, exc);
return null;
public String getSystemTypeDescription(File file)
logger.entering(this.getClass().getName(), "getSystemTypeDescription", file);
try
return fs.getSystemTypeDescription(file);
catch (RemoteException exc)
logger.log(Level.SEVERE, "file="+file, exc);
return null;
public File getDefaultDirectory()
logger.entering(this.getClass().getName(), "getDefaultDirectory");
try
return fs.getDefaultDirectory();
catch (RemoteException exc)
logger.log(Level.SEVERE, "getDefaultDirectory()", exc);
return null;
public File getHomeDirectory()
logger.entering(this.getClass().getName(), "getHomeDirectory");
try
return fs.getHomeDirectory();
catch (RemoteException exc)
logger.log(Level.SEVERE, "getHomeDirectory()", exc);
return null;
public File[] getRoots()
logger.entering(this.getClass().getName(), "getRoots");
try
return fs.getRoots();
catch (RemoteException exc)
logger.log(Level.SEVERE, "getRoots()", exc);
return null;
protected File createFileSystemRoot(File file)
logger.entering(this.getClass().getName(), "createFileSystemRoot", file);
logger.log(Level.SEVERE, "createFileSystemRoot called with ({0})", new Object[]{file});
try
return fs.createFileSystemRoot(file);
catch (RemoteException exc)
logger.log(Level.SEVERE, "", exc);
return null;
} -
Multithread remote method invocation problem
Hello all
I have simple method that is entry point of CORBA remote invocation method
Inside it I have some kind of Logic I need to perform the this logic is inside method and I like
That each method that performs logic will be executed in its own thread ( from thread pool )
this method also returns parameters by reference back to the server .
here is example:
public boolean RemothMethod(Object obj1,Object obj2){
//this is where I allocate thread from thread pool to invoke the logic method
ThreadPool.getTask(LogicMethod(Object obj1,Object obj2));
}But the problem I have here that I can get several "RemothMethod" calls
And the returned Parameters can be from the wrong thread call .
My question is how can I force the right thread to return the right parameters to the "RemothMethod" callI have simple method that is entry point of CORBA
remote invocation method
Inside it I have some kind of Logic I need to perform
the this logic is inside method and I like
That each method that performs logic will be executed
in its own thread ( from thread pool )Why? Each remote method is already being executed in its own thread.
//this is where I allocate thread from thread pool
l to invoke the logic method
ThreadPool.getTask(LogicMethod(Object obj1,Object obj2));What are these APIs?
But the problem I have here that I can get several
"RemothMethod" calls
And the returned Parameters can be from the wrong
thread call . Something wrong with the ThreadPool API you seem to have written.
My question is how can I force the right thread to
return the right parameters to the "RemothMethod" callGet rid of it and execute whatever you need to execute directly in the remote method body. There is no advantage to what you're trying to do. You already have a thread per concurrent client executing the remote method; you're trying to stall those threads and create yet more threads from an evidently non-working ThreadPool. This seems quite pointless. -
Sending files from the remote method
hi,
I would like to know if we can send a File object, i.e. a file as the return value from the remote method on the server side accessed by the client.
Actually, i want to make the files stored at the server system accessible to the client system. how to achieve it?java.io.File implements java.io.Serializable so the previous answer is formally incorrect. However you need to be aware that that would only send the File object, which is essentially the filename, not its contents. I'm sure that what the poster meant to say.
You can send the contents as well in a number of ways but you have to write it by hand. There's no easy way out of the box. -
Can I make method arguments read only?? I want to send an object to a method and make it read only. i dont want a method to change public varables of the mthod argument object.
Can anyone help me on this??
Thanks,
VaijayantiNot possible, but you can pass a copy of the object, so that even if it's changed the changes aren't reflected to the original object.
-
Getting method arguments as hasmap
Hi,
can I get a method arguments in hashtable ? for example
public void methodA(integer arg1,string arg2, integer arg3)
so,
is there any method in java that return a hashtable contains all method arguments , while running methodA.
hashTable would be like this :
arg1 1
arg2 'a'
arg3 5Bender_R. wrote:
If you really need it, you can do it using Spring AOP. See AOP
Edited by: Bender_R. on Oct 29, 2009 11:47 AMWhich won't give parameter names. And is unnecessary anyway, since you could just use a dynamic proxy without having to have all the Spring dependencies present -
Hi,
I am trying to deploy ejb3.0 on weblogic 10 server. I am able to find the JNDI name of the stateless session bean correctly, but getting an exception while narrowing it down. My ejb3.0 client is a standalone java client. I am trying to access the stateless session ejb3.0 bean.Please help me. i have been trying it for many days.
thanks in advance,
Sanjeev
[sanpraka@localhost certEjb]$ java -cp ./:/usr/weblogic/bea/wlserver_10.0/server/lib/weblogic.jar:/usr/weblogic/bea/wlserver_10.0/server/lib/wlclient.jar com.titan.clients.Client
Object is weblogic.rmi.internal.BasicRemoteRef - hostID: '5337880647112897730S:127.0.0.1:[7001,7001,-1,-1,-1,-1,-1]:wl_server:examplesServer', oid: '302', channel: 'null'
java.lang.ClassCastException: Cannot narrow remote object weblogic.rmi.internal.BasicRemoteRef - hostID: '5337880647112897730S:127.0.0.1:[7001,7001,-1,-1,-1,-1,-1]:wl_server:examplesServer', oid: '302', channel: 'null' to com.titan.travelagent.TravelAgentRemote
at weblogic.corba.server.naming.ReferenceHelperImpl.narrow(ReferenceHelperImpl.java:206)
at weblogic.rmi.extensions.PortableRemoteObject.narrow(PortableRemoteObject.java:88)
at weblogic.iiop.PortableRemoteObjectDelegateImpl.narrow(PortableRemoteObjectDelegateImpl.java:32)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at com.titan.clients.Client.main(Client.java:24)
[sanpraka@localhost certEjb]$We have a similar problem. We have a web application (on server A) that invokes an EJB on a remote server (server B). This works fine, until we deploy another web application to server A at which point the existing web application starts to throw java.lang.ClassCastException when narrowing the remote EJB interface. The exception starts to be thrown at the moment the latter web application is deployed - start is not required.
The latter web application contains (actually in APP-INF/lib) the old version of the EJB remote interface, that somehow gets to be loaded into the classpath of the existing web application. The solution is to delete the old version of the EJB remote interface from APP-INF/lib of the latter web application (we didn't need it anyway), but it would be interesting to know in which circumstances classes can get mixed between enterprise applications.
I failed to reproduce the error in simple scenario, so this does not happen always.
Maybe you are looking for
-
Hi, I am creating a Infoset Query for Pending MIRO report means PO + Vender whose GR has done but not MIRO. i use EKKO and EKBE..... Can any other table should me used.......Please suggest ! REgards, Pardeep Malik
-
How to setup Private VLAN in Small business switch SF200-24
Dear All, According release notes 1.4 , private vlan is supported. I've upgraded my SF200-24 with firmware 1.4.0.88 and boot 1.3.5.06. The system information show firmware version 1.4.0.88 and boot version 1.3.5.06 after reboot. I can't find private
-
Macro to compare CSV and Excel file
Team, Do we have any macro to compare CSV and Excel file. 1) In Excel we should have two text boxes asking the user to select the files from the path where they have Stored 2) First Text is for CSV file 3) Second Text box is for Excel file 4) We Shou
-
Installing Oracle 8i Enterprise Edition on XP Pro
I am trying to install Oracle8i - Release 3(8.1.7) on my computer which is a Celeron 1.7GHz with 512MB of RAM and a 40 GIG hard drive. when I put the Oracle8i CD into the CD-ROM drive the autorun feature starts. I then click on the Install/DeInstall
-
Hi I am trying to create qualification in Infotype 0024 for a person. I tried using FM <b>"HR_INFOTYPE_OPERATION"</b>. But saying complex error occured. is this the FM to create qualification or some other FM is there. please suggest. Also i cant see