socket & JVM  
Author Message
Anceschi Mauro





PostPosted: 2004-11-5 0:32:00 Top

java-programmer, socket & JVM This is a multi-part message in MIME format.


Hi i'm trying to create a some sort of JAVA print server:
I've a machine that accept (throught a socket) some spool file........
Here's the JAVA code:

ServerSocket TServer;

int i = 0;

try{

TServer = new ServerSocket(TPort);

while( true ){

//frame.TModel.addElement("+++ WAITING REQUEST " + i );

Lpd_request request = new Lpd_request(TServer.accept(),frame,PQ,NumQueue);

request.start();

i = i + 1;

}

}


the problem is: every request launch another JVM for handle the print and create a pdf of the the spool data: for some reason if i create a batch that launch 5 spool file one after the other, the print server launch 5 thread, but some thread terminate not correctly.

In particular the exit code are 1-0-1-0-0 so the first fail, the second is executed and so on.....

Can I put a delay between thread execution for solve the problem???

Any suggestion????


--
---------------------------------------------

Mauro Anceschi
IT Department

Global Service Srl
Gruppo Motor Power Company Srl
www.motorpowergroup.com
Tel +39-0522-688189
Fax +39-0522-683552


IMPORTANT: This e-mail message is intended only for the named recipient(s) above and may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify the sender and delete this e-mail message.
--------------------------------------------


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>Hi i'm trying to create a some sort of JAVA print
server:</FONT></DIV>
<DIV><FONT face=Arial size=2>I've a machine that accept (throught a socket) some
spool file........</FONT></DIV>
<DIV><FONT face=Arial size=2>Here's the JAVA code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>
<P><FONT face=Arial size=2>ServerSocket TServer;</FONT></P>
<P><FONT face=Arial size=2>int i = 0;</FONT></P>
<P><FONT face=Arial size=2>try</FONT><FONT face=Arial size=2>{</FONT></P>
<P><FONT face=Arial size=2>    TServer = new
ServerSocket(TPort);</FONT></P>
<P><FONT face=Arial size=2>    while( true )</FONT><FONT
face=Arial size=2>{</FONT></P>
<P><FONT face=Arial size=2>       
//frame.TModel.addElement("+++ WAITING REQUEST " + i );</FONT></P>
<P><FONT face=Arial size=2>        Lpd_request
request = new Lpd_request(TServer.accept(),frame,PQ,NumQueue);</FONT></P>
<P><FONT face=Arial size=2>       
request.start();</FONT></P>
<P><FONT face=Arial size=2>        i = i +
1;</FONT></P>
<P><FONT face=Arial size=2>    }</FONT></P>
<P><FONT face=Arial size=2>}</FONT></P></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>the problem is: every request launch another JVM
for handle the print and create a pdf of the the spool data: for some reason if
i create  a batch that launch 5 spool file one after the
other, the print server launch 5 thread, but some thread
terminate not correctly.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>In particular the exit code are 1-0-1-0-0 so the
first fail, the second is executed and so on.....</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Can I put a delay between thread execution for
solve the problem???</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Any suggestion????</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><BR><FONT
face=Arial size=2>--
<BR>---------------------------------------------<BR> <BR>Mauro
Anceschi<BR>IT Department<BR> <BR>Global Service Srl<BR>Gruppo Motor Power
Company Srl<BR></FONT><A href="http://www.motorpowergroup.com"><FONT face=Arial
size=2>www.motorpowergroup.com</FONT></A><BR><FONT face=Arial size=2>Tel
+39-0522-688189<BR>Fax +39-0522-683552<BR> <BR> <BR>IMPORTANT: This
e-mail message is intended only for the named recipient(s) above and may contain
information that is privileged, confidential and/or exempt from disclosure under
applicable law. If you have received this message in error, or are not the named
recipient(s), please immediately notify the sender and delete this e-mail
message.<BR> --------------------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>

 
Chris Smith





PostPosted: 2004-11-5 5:47:00 Top

java-programmer >> socket & JVM Anceschi Mauro wrote:
> the problem is: every request launch another JVM for handle the print
> and create a pdf of the the spool data: for some reason if i create
> a batch that launch 5 spool file one after the other, the print
> server launch 5 thread, but some thread terminate not correctly.

First of all, you are not launching another JVM when you create a new
thread. Unfortunately, a bug in the Linux 'ps' utility made it look
that way for a long time. Recently, a new release of the Linux kernel
fixed that bug (the fix is referred to as NPTL), so recent versions of
the kernel are less confusing.

> In particular the exit code are 1-0-1-0-0 so the first fail, the
> second is executed and so on.....

Threads don't have exit codes. You're seeing some artifact of the
threading library implementation on your old version of the Linux
kernel. This is an artifact of the same bug.

Unless you're seeing actual symptoms, there is very likely no problem at
all. If this bothers you, then update your Linux kernel and basic
utilities to eliminate the broken reporting tools.

By the way, can you please configure your newsreader to break lines. It
took a lot of effort to reply to you in a way that everyone can read. I
probably won't reply again if I have to keep doing so.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Anceschi Mauro





PostPosted: 2004-11-5 16:44:00 Top

java-programmer >> socket & JVM "Chris Smith" <email***@***.com> ha scritto nel messaggio
news:email***@***.com...
> First of all, you are not launching another JVM when you create a new
> thread. Unfortunately, a bug in the Linux 'ps' utility made it look
> that way for a long time. Recently, a new release of the Linux kernel
> fixed that bug (the fix is referred to as NPTL), so recent versions of
> the kernel are less confusing.

I know that, but in every new thread i launch a new JVM throught a
runtime.exec() ^_^

Also I'm not using a unix machine but a windows 2000 machine.



 
 
Chris Uppal





PostPosted: 2004-11-5 17:25:00 Top

java-programmer >> socket & JVM Anceschi Mauro wrote:

> I know that, but in every new thread i launch a new JVM throught a
> runtime.exec() ^_^

Why ?

-- chris (a different Chris, please note)



 
 
Anceschi Mauro





PostPosted: 2004-11-5 17:33:00 Top

java-programmer >> socket & JVM "Chris Uppal" <email***@***.com> ha scritto nel
messaggio news:email***@***.com...
> Anceschi Mauro wrote:
>
> > I know that, but in every new thread i launch a new JVM throught a
> > runtime.exec() ^_^
>
> Why ?
>
> -- chris (a different Chris, please note)
Good question!

Now I'm trying not to invoke a external java program, but create the pdf in
the new thread.

The main reason was historic.
At the beginning of this project the JAVA print server already exists: they
asked me to integrate a new program to the existing one.
After many problem I've found that the problem was the Print Server who has
problem in executing the new JVM.




 
 
Anceschi Mauro





PostPosted: 2004-11-5 18:34:00 Top

java-programmer >> socket & JVM This is a multi-part message in MIME format.


Problem solved.
I don't use exec.runtime for every file that i process.
I' just created a bigger java project that integrate the print server and the PDF creator.
"Anceschi Mauro" <email***@***.com> ha scritto nel messaggio news:2Qsid.16505$email***@***.com...
Hi i'm trying to create a some sort of JAVA print server:
I've a machine that accept (throught a socket) some spool file........
Here's the JAVA code:

ServerSocket TServer;

int i = 0;

try{

TServer = new ServerSocket(TPort);

while( true ){

//frame.TModel.addElement("+++ WAITING REQUEST " + i );

Lpd_request request = new Lpd_request(TServer.accept(),frame,PQ,NumQueue);

request.start();

i = i + 1;

}

}


the problem is: every request launch another JVM for handle the print and create a pdf of the the spool data: for some reason if i create a batch that launch 5 spool file one after the other, the print server launch 5 thread, but some thread terminate not correctly.

In particular the exit code are 1-0-1-0-0 so the first fail, the second is executed and so on.....

Can I put a delay between thread execution for solve the problem???

Any suggestion????


--
---------------------------------------------

Mauro Anceschi
IT Department

Global Service Srl
Gruppo Motor Power Company Srl
www.motorpowergroup.com
Tel +39-0522-688189
Fax +39-0522-683552


IMPORTANT: This e-mail message is intended only for the named recipient(s) above and may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify the sender and delete this e-mail message.
--------------------------------------------


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Problem solved.</FONT></DIV>
<DIV><FONT face=Arial size=2>I don't use exec.runtime for every file that i
process.</FONT></DIV>
<DIV><FONT face=Arial size=2>I' just created a bigger java project that
integrate the print server and the PDF creator.</FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Anceschi Mauro" <<A
href="mailto:email***@***.com">email***@***.com</A>> ha scritto nel
messaggio <A
href="news:2Qsid.16505$email***@***.com">news:2Qsid.16505$email***@***.com</A>...</DIV>
<DIV><FONT face=Arial size=2>Hi i'm trying to create a some sort of JAVA print
server:</FONT></DIV>
<DIV><FONT face=Arial size=2>I've a machine that accept (throught a socket)
some spool file........</FONT></DIV>
<DIV><FONT face=Arial size=2>Here's the JAVA code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>
<P><FONT face=Arial size=2>ServerSocket TServer;</FONT></P>
<P><FONT face=Arial size=2>int i = 0;</FONT></P>
<P><FONT face=Arial size=2>try</FONT><FONT face=Arial size=2>{</FONT></P>
<P><FONT face=Arial size=2>    TServer = new
ServerSocket(TPort);</FONT></P>
<P><FONT face=Arial size=2>    while( true )</FONT><FONT
face=Arial size=2>{</FONT></P>
<P><FONT face=Arial size=2>       
//frame.TModel.addElement("+++ WAITING REQUEST " + i );</FONT></P>
<P><FONT face=Arial size=2>        Lpd_request
request = new Lpd_request(TServer.accept(),frame,PQ,NumQueue);</FONT></P>
<P><FONT face=Arial size=2>       
request.start();</FONT></P>
<P><FONT face=Arial size=2>        i = i +
1;</FONT></P>
<P><FONT face=Arial size=2>    }</FONT></P>
<P><FONT face=Arial size=2>}</FONT></P></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>the problem is: every request launch another JVM
for handle the print and create a pdf of the the spool data: for some reason
if i create  a batch that launch 5 spool file one after the
other, the print server launch 5 thread, but some thread
terminate not correctly.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>In particular the exit code are 1-0-1-0-0 so the
first fail, the second is executed and so on.....</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Can I put a delay between thread execution for
solve the problem???</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Any suggestion????</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><BR><FONT
face=Arial size=2>--
<BR>---------------------------------------------<BR> <BR>Mauro
Anceschi<BR>IT Department<BR> <BR>Global Service Srl<BR>Gruppo Motor
Power Company Srl<BR></FONT><A href="http://www.motorpowergroup.com"><FONT
face=Arial size=2>www.motorpowergroup.com</FONT></A><BR><FONT face=Arial
size=2>Tel +39-0522-688189<BR>Fax
+39-0522-683552<BR> <BR> <BR>IMPORTANT: This e-mail message is
intended only for the named recipient(s) above and may contain information
that is privileged, confidential and/or exempt from disclosure under
applicable law. If you have received this message in error, or are not the
named recipient(s), please immediately notify the sender and delete this
e-mail
message.<BR> --------------------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BLOCKQUOTE></BODY></HTML>