Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

RMI and NullPointerException

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
song bo
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic