You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Achleitner Thomas <Th...@infoniqa.com> on 2009/03/05 15:05:50 UTC

[LAUNCHER] Using procrun with commons launcher

Hi!
I am using commons launcher to start my java application. This works pretty fine.
Then when I want my java application to run as a windows service with procrun I am installing the service like this:
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass LauncherBootstrap --StartParams -executablename;myapp;myapp --StartPath %myapp_BASE%\bin --StartMode jvm --LogPath %myapp_BASE%\logs --LogPrefix myapp

Starting the application as a windows service works fine, too.
But when I stop the windows service the service is stopped but my application (javaw process) is still running. I have to kill the process manually using task manager.

Is it possible to use commons launcher und procrun on windows systems together?
Has anyone made this working?

thomas

Re: [Commons NET]

Posted by Ward <wa...@gmail.com>.
Okey, this did the job indeed!
Should have reed the api more detailed...
Thanks!

Ward

Steve Cole schreef:
> I think you need to call the FTPClient completePendingCommand() method.
> 
> Here's the example from API documentation...
> 
> For example, 
>  InputStream input;
>  OutputStream output;
>  input  = new FileInputStream("foobaz.txt");
>  output = ftp.storeFileStream("foobar.txt")
>  if(!FTPReply.isPositiveIntermediate(ftp.getReplyCode())) {
>      input.close();
>      output.close();
>      ftp.logout();
>      ftp.disconnect();
>      System.err.println("File transfer failed.");
>      System.exit(1);
>  }
>  Util.copyStream(input, output);
>  input.close();
>  output.close();
>  // Must call completePendingCommand() to finish command.
>  if(!ftp.completePendingCommand()) {
>      ftp.logout();
>      ftp.disconnect();
>      System.err.println("File transfer failed.");
>      System.exit(1);
>  }
> ----- Original Message ----- 
> From: "Ward" <wa...@gmail.com>
> To: "Commons Users List" <us...@commons.apache.org>
> Sent: Thursday, March 05, 2009 9:44 AM
> Subject: [Commons NET]
> 
> 
>> Hi,
>>
>> I'm using the Apache Commons NET library to ftp some files to a server.
>> I use the storeFileStream() method of FTPClient so I can write on the 
>> OutputStream and keep track of the progress during the upload
>> This is (a summary of) the code:
>>
>> File file = File("location of file");
>> FileInputStream fis = new FileInputStream(file);
>> FTPClient ftpClient = new FTPClent();
>> ftpClient.connect(server-name);
>> ftpClient.login(user,pass);
>> ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
>> OutputStream os = ftpClient.storeFileStream(file.getName());
>> byte buf[] = new byte[1024];
>> int len;
>> long totalLength = file.length();
>> long bytesRead = 0;
>> long percent;
>> while ((len = fis.read(buf)) > 0) {
>>      os.write(buf, 0, len);
>>      bytesRead += len;
>>      percent = (100 * bytesRead / totalLength);
>> }
>> fis.close();
>> os.close();
>> ftpClient.disconnect();
>>
>> This seems to work fine: files get uploaded.
>> But when I take a closer look at the uploaded files, I notice they 
>> aren't uploaded completely.
>> The uploaded files are all shorter than the original files on my disk
>> The difference is alway around the 59-60kb
>> What could be the reason for that?
>> Is there something wrong with the copy-ing-structure I use between the 2 
>> streams?
>>
>> Thanks for anwering
>>
>> Ward
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [Commons NET]

Posted by Steve Cole <sc...@camsbycbs.com>.
I think you need to call the FTPClient completePendingCommand() method.

Here's the example from API documentation...

For example, 
 InputStream input;
 OutputStream output;
 input  = new FileInputStream("foobaz.txt");
 output = ftp.storeFileStream("foobar.txt")
 if(!FTPReply.isPositiveIntermediate(ftp.getReplyCode())) {
     input.close();
     output.close();
     ftp.logout();
     ftp.disconnect();
     System.err.println("File transfer failed.");
     System.exit(1);
 }
 Util.copyStream(input, output);
 input.close();
 output.close();
 // Must call completePendingCommand() to finish command.
 if(!ftp.completePendingCommand()) {
     ftp.logout();
     ftp.disconnect();
     System.err.println("File transfer failed.");
     System.exit(1);
 }
----- Original Message ----- 
From: "Ward" <wa...@gmail.com>
To: "Commons Users List" <us...@commons.apache.org>
Sent: Thursday, March 05, 2009 9:44 AM
Subject: [Commons NET]


> Hi,
> 
> I'm using the Apache Commons NET library to ftp some files to a server.
> I use the storeFileStream() method of FTPClient so I can write on the 
> OutputStream and keep track of the progress during the upload
> This is (a summary of) the code:
> 
> File file = File("location of file");
> FileInputStream fis = new FileInputStream(file);
> FTPClient ftpClient = new FTPClent();
> ftpClient.connect(server-name);
> ftpClient.login(user,pass);
> ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
> OutputStream os = ftpClient.storeFileStream(file.getName());
> byte buf[] = new byte[1024];
> int len;
> long totalLength = file.length();
> long bytesRead = 0;
> long percent;
> while ((len = fis.read(buf)) > 0) {
>      os.write(buf, 0, len);
>      bytesRead += len;
>      percent = (100 * bytesRead / totalLength);
> }
> fis.close();
> os.close();
> ftpClient.disconnect();
> 
> This seems to work fine: files get uploaded.
> But when I take a closer look at the uploaded files, I notice they 
> aren't uploaded completely.
> The uploaded files are all shorter than the original files on my disk
> The difference is alway around the 59-60kb
> What could be the reason for that?
> Is there something wrong with the copy-ing-structure I use between the 2 
> streams?
> 
> Thanks for anwering
> 
> Ward
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


[Commons NET]

Posted by Ward <wa...@gmail.com>.
Hi,

I'm using the Apache Commons NET library to ftp some files to a server.
I use the storeFileStream() method of FTPClient so I can write on the 
OutputStream and keep track of the progress during the upload
This is (a summary of) the code:

File file = File("location of file");
FileInputStream fis = new FileInputStream(file);
FTPClient ftpClient = new FTPClent();
ftpClient.connect(server-name);
ftpClient.login(user,pass);
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
OutputStream os = ftpClient.storeFileStream(file.getName());
byte buf[] = new byte[1024];
int len;
long totalLength = file.length();
long bytesRead = 0;
long percent;
while ((len = fis.read(buf)) > 0) {
     os.write(buf, 0, len);
     bytesRead += len;
     percent = (100 * bytesRead / totalLength);
}
fis.close();
os.close();
ftpClient.disconnect();

This seems to work fine: files get uploaded.
But when I take a closer look at the uploaded files, I notice they 
aren't uploaded completely.
The uploaded files are all shorter than the original files on my disk
The difference is alway around the 59-60kb
What could be the reason for that?
Is there something wrong with the copy-ing-structure I use between the 2 
streams?

Thanks for anwering

Ward

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org