[Logo]
Forums Register Login
RMI and NullPointerException
Hello.
My JD assignment is Contractor services.
I use RMI to make my 3 tier project.and I design the same MVC framework for 3 tier and 2 tier.the programme is worked well in 2 tier.but in 3 tier it's always false to run update operation.throw a NullException.I have tested it for serval days.my class:
DBMain - sun's interface
|
Data - sun's inteface
BookModel
/ \
/ \
/ \
RmiBookModel LocalBookModel
|->Data |->Data
BookController
--------------
+ modify
+ search
|
|
BookControllerImpl
BookView
--------
+ update(Object data)
|
|
BookViewImpl
in gui table,I store the record' No,when updated ,refresh records by No.
in 3 tier,when user book a record,the controller will run the modify method.
and call RmiBookModel to update the db. it's right to here.but when the Model update all registed Views,it's throw a NullPointerException.
code:
[code]
public RmiBookModel extends BookModel implements UnicastRemoteObject {
private Data db;
private ArrayList bookView;
...
public void update(int recNo,String[] data) {
db.update(recNo,data);
for(int i=0;i<bookView.size();i++){
bookView.update(new Integer(recNo));
}
}
}
public class BookViewImpl extends BookView implements Serization{
private BookModel bookModel;
public void update(Object data){
if (data instanceof Integer){
Get all recNo from Table;
Call bookModel.read(int i) to get the data;
Refresh the table;
} else (data instanceof String[][]){
Refresh the table with data;
}
....
}

}
or the run order follow:
book a record
|->Conroller.modify
|->Model.update
|->View.update
|->Model.read
|->View.update
but the bookView always throws a NullPointerException.
Maybe I don't describe the problem clear.If I resolve it,I can apply any Database design.
please help me.
Hi Song, I see that you tried to use the CODE tag, but it didn't work, there was no closing /CODE tag. and therefore all your code is not formatted and is difficult to read to help you. Try re-posting your code.
Thanks
Mark
Hi Song,
The good news with any NullPointerException issue is that it should be easy to solve. It should have nothing to do with a design decision (2-tiers/3-tiers), but with some unassigned object you access somewhere.
When it happens, the JVM is kind enough to tell you on which line that unassigned object is accessed ... what you don't in the code posted above. So I guess you'll solve the issue by yourself before anyone here can give you a clue.
Best,
Phil.

in gui table,I store the record' No,when updated ,refresh records by No.
in 3 tier,when user book a record,the controller will run the modify method.
and call RmiBookModel to update the db. it's right to here.but when the Model update all registed Views,it's throw a NullPointerException.
code:

I want to say it's work well in 2 tier.but failed in 3tier.I doubt it's wrong to recall the remote object.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Dec 16, 2017 02:20:10.