Serializability problem.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Akshay_B
Posted On:   Tuesday, September 26, 2006 05:43 AM

Problem : I am trying to send objects from client to server using the ObjectOutpuStream and ObjectInputStream. One object gets transferred without problem, but the application gets stuck when I try to send another(second) object. Please go through the code. I have specified where exactly the application is getting stuck. I am not getting any exceptions either. CODE: The client side,.. sends a string as a command, and the the Obj n strings in a fixed sequence to execute the command. // initng streams public ClientStub(BufferedReader in, PrintWriter out, ObjectInputStream ois, ObjectOutputStream oos) { //client=clientRec; try { this.in=in   More>>

Problem :

I am trying to send objects from client to server using the ObjectOutpuStream and ObjectInputStream. One object gets transferred without problem, but the application gets stuck when I try to send another(second) object. Please go through the code. I have specified where exactly the application is getting stuck. I am not getting any exceptions either.






CODE:



The client side,.. sends a string as a command, and the the Obj n strings in a fixed sequence to execute the command.
// initng streams
public ClientStub(BufferedReader in, PrintWriter out, ObjectInputStream ois, ObjectOutputStream oos)
{
//client=clientRec;
try
{
this.in=in;
this.out=out;
this.oos=oos;
this.ois=ois;
}
catch(Exception e)
{
System.out.println(e);
}
}
// some code in between n then

if (identificationCode.equals("SGLUSRADD") || identificationCode.equals("MULUSRADD"))
{
User usr = (User)objToTransfer;
oos.println(usr);
out.println(method);

String decTransfer = in.readLine();
//System.out.println("CLIENT -- decTransfer : "+decTransfer);
String tmp = in.readLine();
//System.out.println("CLIENT -- tmp : "+tmp);
if (decTransfer.equals("1"))
dec = JOptionPane.showConfirmDialog (this,"The sequence of given username already exists," +
" would you like to add further records to it starting from "+tmp);

if (decTransfer.equals("0"))
dec = JOptionPane.showConfirmDialog(this,"The sequence of given username does not exist," +
" would you like create a new sequence starting from "+tmp);

out.println(dec);
}



The server stub recieving the data

// init
public ClientWorker(Socket client1)
{
this.client=client1;
System.out.println ("Client Thread Created");


try
{
in = new BufferedReader(new InputStreamReader(client.getInputStream()));
out = new PrintWriter(client.getOutputStream (), true);
ois = new ObjectInputStream(client.getInputStream());
oos = new ObjectOutputStream(client.getOutputStream());
//System.out.println("Inside TRY for assigning IN and OUT");
}
catch(IOException e)
{
System.out.println("In or Out for particular Client Failed");
}


}

// some code

if ( line.equals("SGLUSRADD")) //SingleUserAdd
{
try
{
//ObjectInputStream oisT = new ObjectInputStream(client.getInputStream ());
System.out.println("Inside SingleUserAdd");
Object obj=ois.readObject(); // < < < < < <--- Problem,... 1st object comes n gets added n all,.. second time,.. it comes till here n just gets stuck man
User usr = (User)obj;
usr.setPort(in, out, ois, oos);
usr.add("Single");
System.out.println ("Single User Added");
}
catch(Exception e)
{
System.out.println("SERVER: Singleusr ClientWorker : "+e);
}
}

   <<Less

Re: Serializability problem.

Posted By:   Akshay_B  
Posted On:   Tuesday, September 26, 2006 05:56 AM

Crap,... pls have a look at it here




http://www.geocities.com/akshaybondre/problem.txt
About | Sitemap | Contact