Hi, 

            Just to narrow down on things, I wrote a simple Daemon class as 
follows 
                 public class MyDaemon implements Daemon  

ServerSocket socket; 
private String[] args; 
 
public void destroy()  
System.out.println("In destroy"); 

 

public void init(DaemonContext arg0) throws Exception  
// TODO Auto-generated method stub 
args = arg0.getArguments(); 
socket = new ServerSocket(); 
System.out.println("In init"); 

 

public void start() throws Exception  
SocketAddress endpoint; 
 
int port = Integer.parseInt(args[0]); 
 
endpoint = new InetSocketAddress(port); 
// TODO Auto-generated method stub 
try  
socket.bind(endpoint); 
 
catch(Exception e) 
e.printStackTrace(); 
System.out.println("Cannot bind on port " + port); 
 
System.out.println("In start"); 

 

public void stop() throws Exception  
// TODO Auto-generated method stub 
System.out.println("In stop"); 

 

          and I run the same class using jsvc as ./jsvc -debug -verbose -cp 
commons-daemon.jar:testj1.jar com.test.MyDaemon 125 

          I always get a BindException saying Permission denied. What am I 
doing wrong. I am running as root and also the port is very much available. 
Have herewith attached the jsvc output. 

          Any help / suggestions would be highly valued. 

Thanks, 
Srijith.

>>> "Srijith Kochunni" <[EMAIL PROTECTED]> 12/10/2008 7:16 PM >>>

Hi All,

          I am using jsvc to daemonize my java application, which runs on a 
Linux box. I get an error java.net.BindException: Permission denied. I get this 
only for ports < 1024 and I understand on linux to bind to any ports which are 
below 1024, you require root permission. Therefore I am launching my 
application as root. However I still am not able to get the privileges 
required. My JSVC arguments are as follows.

   jsvc.exec -debug -Xdebug -Xnoagent -Djava.compiler=NONE 
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8008 -jvm server -user 
root -home $JAVA_HOME
  -outfile /var/opt/myfile.out -pidfile /var/run/myfile.pid -errfile '&1'  

          I am launching as root user and also in jsvc arguments I have 
specified "-user root", but am at a loss as to why I am still getting this 
exception, when I launch my jetty server. When I tried to launch it normally 
outside jsvc, it works fine. I have searched on the net, and also came across 
this message thread 
http://markmail.org/message/3mw6r2dievxvviu3#query:jsvc%20java.net.BindException%3A%20Permission%20denied+page:1+mid:j2w4dpzp4aaypun6+state:results
 where it suggested, that some system call had been modified and it worked 
thereafter, but did not find the details. 

         Have run strace, but could not find any errors.
On starting in debug mode,  I see the following messages,
10/12/2008 18:55:30 6349 jsvc debug: user changed to 'root'
10/12/2008 18:55:30 6348 jsvc debug: User 'root' validated
and I also don't see any errors.

      Any help / suggestions in this regard would be greatly appreciated.

Thanks,
Srijith.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to