Amy Young

Greenhorn
+ Follow
since Oct 04, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Amy Young

Hi

I just want thank all those contributed to the SCJD forum. I own a lot to all those who shared their experience and knowledge.

Here my marks:

Section Max Actual Points Points General Con: 100 88
Documentation: 70 70
OOD: 30 30
GUI: 40 33
Locking: 80 80
Data Store: 40 40
Network Server: 40 40
Total: 400 381

Greeting

Amy
15 years ago
Hallo

Are you calling the readRecord() method from the Remote package directly to the DBAccess interface??
Because this is what I did and cause lots of problems. The way I solved it is described in : https://coderanch.com/t/189390/java-developer-SCJD/certification/RMI-Factory-implementation-fails

Good luck

Amy
Hallo

I'm have done by now 90% of the application and I'm busy with minor issues like code style checking.
I download and installed the eclipse chekStyle plugin.
When activating it I saw a huge (really huge ) amount of messages like this:

'Tab chrachter: line contains a tab charachter'

Of course it does, I always use tabs to indent code. I checked on the SUN site : http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
and there it stated :

Four spaces should be used as the unit of indentation.


Is this really important??? Can anybody who passed the assignement tel me
if I could loose points when letting the code the way it is now?

Thanks

Amy
Hallo everybody

I found the solution!!!
The DataRemoteImpl must be of type : DBAccess!!!

This is the way I implemented it:

suncertify.db.DBAccess <-- given by SUN
suncertify.db.Data <-- implementation of DBAccess
suncertify.db.DataRemoteAdapter extends Remote <-- interface which declares all methods declared in the DBAccess. because this uses the Remote interface I'll be able to throw RemoteException as required by RMI.
suncertify.db.DataRemoteAdapterImpl implements DataRemoteAdapter <-- has a reference to the Data class and calls the Data's methods.

suncertify.remote.DataRemote extends Remote, DataRemoteAdapter
suncertify.remote.DataRemoteImpl extends UnicastRemoteObject implements DataRemote

And here it comes the RmiClient has a method called by the GUIController :

public static DataRemoteAdapter getRemote(String hostname, String port)
throws RemoteException {
String url = "rmi://" + hostname + ":" + port + "/DataRemote";
log.info("URL = " + url);
try {
DataRemoteFactory remoteFactory = (DataRemoteFactory) Naming.lookup(url);
}
DataRemote remote = remoteFactory.getClient();
DataRemoteAdapter dra = (DataRemoteAdapter) remote;
return dra;
}catch (){
//all kind of exceptions
}
}

I hope someone else will be helped by this...

Bye

Amy
I have chosen to implement RMI for my application.
In the suncertify.gui.GuiControlle I do the following:

case NETWORK_RMI:
remoteConnection = suncertify.remote.RmiClient.getRemote(
dbLocation, port);
break;

The suncertify.remote.RmiClient.getRemote is implemented as follows:

try {
DataRemoteFactory remoteFactory = (DataRemoteFactory) Naming.lookup(url);
DataRemote remote = remoteFactory.getClient();
DataRemoteAdapter res = (DataRemoteAdapter) remote;
return res;
}

The loookup goes well , at least I see, debugging, that an object is received.
The DataRemoteFactory also returns an object which when printed out looks like this:

Proxy[DataRemote,RemoteObjectInvocationHandler[UnicastRef [liveRef: [endpoin
t:[127.0.0.2:1057](remote),objID:[440b37a7:1158b7f57c8:-8000, 1]]]]]

Indeed the DataRemoteFactory should instantiates (and returns) an object of type DataRemoteImpl which extends UnicastRemoteObject and has though composition a reference to the DataRemoteAdapter class.

The problem takes place when the remote object is casted to suncertify.db.DataRemoteAdapter which through composition has an instance of DBAccess dba = new Data(); and implements all the method given by the Sun inteface.

Since the casting is failing I'm wondering what kind of type the received "DataRemote remote" has at runtime .When usinf getClass(0 on it , I see the : "class $Proxy1"

Greetings

Amy
Hi Paul

I realize that I wasn't clear in describing the problem. I guess I've been looking at this for too long.
Let's start saying that when running the application in mode "alone" everything goes well.
The real problem is caused by calling:
DataRemote dr = new DataRemoteImpl(location);javascript: x()

DataRemoteImpl is defined as :

public class DataRemoteImpl extends UnicastRemoteObject implements DataRemote

In its constructor DataRemoteImpl instantiates the Data.java class which is the mandatory implementation of the DBAccess interface given by SUN in the assignement.And the constructor throws RemoteException.
The DataRemoteImpl calls all methods that can be found in the Data.java (as CreateRecord , deleteRecord etc).
This is the trace (I used a proef.java class to isolate the problem)

java.rmi.server.ExportException: remote object implements illegal remote interfa
ce; nested exception is:
java.lang.IllegalArgumentException: illegal remote method encountered: public a
bstract java.util.Collection suncertify.db.MyInterface.readAllRecords()
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:171)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:29
3)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:23
5)
at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:133)
at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:119)
at suncertify.remote.DataRemoteImpl.<init>(DataRemoteImpl.java:24)
at suncertify.remote.proef.<init>(proef.java:18)
at suncertify.remote.proef.main(proef.java:12)

It has something to do with the RMI implemetation, but I don't see what it is.
I hope this time I managed to be clear. I certanly don't want let people work on obvious issues.

Thanks

Amy
Hallo everybody

I'm doing the B&S assignment. I'm busy with the last part, setting up a network connection between the server and the client. I choose RMi.
I'm now able to start the server , and the RMI registry programatically.
When doing: netstat -na |grep 1099 I see that this port is listening.

Then I launch the Gui client , give as host : local host and as port 1099.
The client finds the registry for it doesn't fail doing:
DataRemoteFactory remoteFactory = (DataRemoteFactory) Naming.lookup(url);

But when asking to the server an instance of the object the client should use to talk to a failure takes place :

DataRemote remote = remoteFactory.getClient();


The url is correct. But this is the trace I receive: (HOpe is not too long)

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.server.ExportException: remote object implements illegal remote interface; nested exception is:
java.lang.IllegalArgumentException: illegal remote method encountered: public abstract java.util.Collection suncertify.db.MyInterface.readAllRecords()
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:325)
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:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
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 $Proxy0.getClient(Unknown Source)
at suncertify.remote.RmiClient.getRemote(RmiClient.java:42)
at suncertify.gui.controller.GuiController.<init>(GuiController.java:60)
at suncertify.gui.wiew.ClientWindow.<init>(ClientWindow.java:100)
at suncertify.gui.ApplicationRunner.<init>(ApplicationRunner.java:56)
at suncertify.gui.ApplicationRunner.main(ApplicationRunner.java:35)
Caused by: java.rmi.server.ExportException: remote object implements illegal remote interface; nested exception is:
java.lang.IllegalArgumentException: illegal remote method encountered: public abstract java.util.Collection suncertify.db.MyInterface.readAllRecords()
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:171)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:293)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:235)
at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:133)
at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:119)
at suncertify.remote.DataRemoteImpl.<init>(DataRemoteImpl.java:24)
at suncertify.remote.DataRemoteFactoryImpl.getClient(DataRemoteFactoryImpl.java:34)
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:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException: illegal remote method encountered: public abstract java.util.Collection suncertify.db.MyInterface.readAllRecords()
at sun.rmi.server.Util.checkMethod(Util.java:244)
at sun.rmi.server.Util.getRemoteInterfaces(Util.java:223)
at sun.rmi.server.Util.getRemoteInterfaces(Util.java:193)
at sun.rmi.server.Util.createProxy(Util.java:126)
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:169)
... 17 more
Exception in thread "main" java.lang.NullPointerException
at suncertify.gui.controller.GuiController.getAllContractors(GuiController.java:96)
at suncertify.gui.wiew.ClientWindow.createAndShow(ClientWindow.java:128)
at suncertify.gui.wiew.ClientWindow.<init>(ClientWindow.java:104)
at suncertify.gui.ApplicationRunner.<init>(ApplicationRunner.java:56)
at suncertify.gui.ApplicationRunner.main(ApplicationRunner.java:35)


I've no idea what's going on... and that is just to little to go on.

Thank you in advance.

Amy