im new to this forum.
i just have a little problem with this new client-server application that i created.
the problem that i have is when the client tries to log into the server using a username and password i get a 'nullpointerexception' error and it wont let the client log in.
when i use the client and server from the same machine it does let me in though.
anyone has any ideas where i am going wrong, please let me know
if you need to see the code and a screendump of the error that i get please let me know
the complete error that i get when i run the client from a different pc is shown below:
---------------------------------------------------------------------
java.io.Filenotfoundexeption: admin_stock.ser (access is denied)
at java.io.FileoutputStream.open(native method)
at java.io.FileoutputStream.<init> (FileOutputStream.java:179)
at java.io.FileoutputStream.<init> (FileOutputStream.java:70)
at ServerWatchList.saveWatchList(ServerWatchList.java: 257)
at ServerWatchList.sendWatchList(ServerWatchList.java: 237)
at ServerWatchList.loadWatchList(ServerWatchList.java: 251)
at ServerWatchList.<init>(ServerWatchlist.java: 46)
at Server.run(Server.java: 82)
at java.lang.Thread.run(Thread.java: 595)
java.io.Filenotfoundexeption: admin_stock.ser (access is denied)
at java.io.FileoutputStream.open(native method)
at java.io.FileoutputStream.<init> (FileOutputStream.java:179)
at java.io.FileoutputStream.<init> (FileOutputStream.java:70)
at ServerWatchList.saveWatchList(ServerWatchList.java: 257)
at ServerWatchList.updateWatchList(ServerWatchList.java: 226)
at ServerWatchList.sendStockList(ServerWatchList.java: 206)
at ServerWatchList.<init>(ServerWatchlist.java: 46)
at Server.updateUsers(Server.java: 114)
at Server.run(Server.java: 84)
at java.lang.Thread.run(Thread.java: 595)
nullpointerexception
----------------------------------------------------------------------
<<< the code that the error is refering to is below:>>>
for the ServerWatchList class
-----------------------------------
void sendStockList(Vector v) {
synchronized (out) {
out.println("__sol");
for (int i = 0; i < v.size(); i++)
out.println(v.elementAt(i));
out.println("__eol");
}
updateWatchlist(v);
}
now i know its a lot of code but im not sure what im doing wrong
like i said before it works fine when the client logs in from the same pc as where the server is running.
if the code does not make any sense to you i can send you all of the classes and you can run them.
well, the stacktrace says that your problem is a file, that could not be found / written:
java.io.Filenotfoundexeption: admin_stock.ser (access is denied)
access denied points out, that you try to write (FileoutputStream.open(native method)) to the file called "admin_stock.ser", but you or your programm has not enough rights. (starting at the at ServerWatchList.saveWatchList(ServerWatchList.java : 257)).
this shurely can lead to a following nullpointer exception.
can that be right, that on the other machines, you run the client on, you don't have enough rights to create that file?
the admin_stock file is saved in the Server folder and when admin tries to log in it needs to access that file to display the stock that are available.
i have included a copy of the application and if you dont mind you can run it and see for yourself and maybe you can find what the problem is.
there are three folders in the application, you first need to open the server folder and run the server.bat file and then open the admin or client folder and run the admin.bat or client.bat files. both folders do different things to the server.
i also have included a screendump of the error that i get when i run the application in two different pc's.
and thanks, i really appreciate what you're doin
Last edited by tonymontana; 05-04-2006 at 05:52 PM.
the screenshot makes it clear: you have a problem accessing the file. perhaps the file is writeprotected? or it was created using another user than the one you are using now.
Bookmarks