• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why this code snippet does not send the msg ?

 
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am try with following code snippet..this is suppose to send to another class but surprisingly it sends the first message and don't touch the rest of two? But if i stop the sending part but only prints it does all the activity? Perhaps I am doing something silly...Could not understand what?
Could you please help me?
regards,
Arun

[ April 22, 2002: Message edited by: Dirk Schreckmann ]
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me to sort this problem
regards
arun
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not clear what your sender class is doing, but the way you describe your problem it seems like it's blocking at construction, ie, calling:
new Sendorder(pr)
is not returning.
What are you doing in your constructor? You should probably re-factor your constructor so that it doesn't perform any blocking activity, and move it to some method invocation that performs the same fucntionality. At least this way, you can construct your object.
Without knowing what the Sendorder constructor is doing, it's hard to say anything more specific.
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply Rob. please help me to figure out the problem.
Here is the code for sendorder class:

regards,
Arun
[ April 22, 2002: Message edited by: Dirk Schreckmann ]
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What exactly prints out when you run your program? What is the last thing that prints?
DO you know where your code blocks after that? The constructor is empty, so that's not the problem.
What method is causing your problem?
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I stop sending my request to this class it prints out easy..but if open up whole lot of code it sends first message and than hangs up and don't show any thing to me...
Rob do you thing style of coding could be a problem? can i write it better way?
what could be other reasons of this behaviour?
Any thought?
regards,
Arun
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
arun,
what prints out? I can't help you if you don't give me specific information.
Can you please print out the exactly contents of your console (ie, Dos Window/command window) so I can see what is getting printed and where the application hangs?
Thank you.
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem is never sends the error...perhaps there is no error but if I try to debug what I could find is that it never calls the second instance...
I don't know who can help me in this world....
regards,
Arun
[ April 21, 2002: Message edited by: arun mahajan ]
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're sending around a PrintWriter object. Do you ever flush this? Is it auto-flushing? If you println() to a buffered object, and something causes the program to 'abort' or 'hang'.. then you won't ever see the output.

Try this (*especially* when you catch exceptions), don't just send to your pr object, but send to System.err.println the same message (the exception you just caught).

System.err.println is not buffered, and you should see the error on your console.

What Rob has been asking you is for the output in your DOS window, and I suspect there hasn't been any, because you are catching every exception and burying it.
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mike foryou suggestion...I will try to rerun same...but perhaps this won't help as this class is being called by a servlet and Syste.err.println() will not let me to see the error there...

But I would like to ask following question and would appreciate if some one can answer them point wise:-
1. IS it bad idea of catching every exception and burying them their itself...(perhaps sound foolish but what is right?)
2. Am i writing a better code? I am sure there could be better way of writing my sendorder class...can you help me?
3. Is style of coding I am adopting is taking lot of memory?
4. Am i releasing the memory in better fashion?
5. will it be useful to call System.gc() after every call of sending my orders to sendorder class?
Please spare some moments and help me for these basic questions...
regards,
Arun
[ April 21, 2002: Message edited by: arun mahajan ]
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can somebody help me for these basic questions..it may help to sort out my problem..i would be highly obliged
regards,
arun
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help to answer these basic questions...I could not able to find an answer for my problem but perhaps these question/answer somewhere help...
PLEASE HELP...
regards,
Arun
reply
    Bookmark Topic Watch Topic
  • New Topic