I have been trying to catch the following exception java.net.UnknownHostException in my sleep script – but so far without success.Â
I have been able to catch other java exception in the same sleep script so this is very strange.
what am i doing wrong?Â
many thanks
Â
Jul 14, 2014 5:59:24 PM com.comverse.rtbd.security.sdk.audit.xdas.XDasSession initSocket
SEVERE: Error intializing socket :java.net.UnknownHostException: Osecserv: Osecserv
       at java.net.InetAddress.getAllByName0(InetAddress.java:1258)
       at java.net.InetAddress.getAllByName(InetAddress.java:1185)
       at java.net.InetAddress.getAllByName(InetAddress.java:1107)
       at java.net.InetAddress.getByName(InetAddress.java:1057)
       at com.comverse.rtbd.security.sdk.audit.xdas.XDasSession.initSocket(XDasSession.java:393)
       at com.comverse.rtbd.security.sdk.audit.xdas.XDasSession.setupSession(XDasSession.java:382)
       at com.comverse.rtbd.security.sdk.audit.xdas.XDasSession.<init>(XDasSession.java:228)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:44)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:516)
       at sleep.engine.atoms.ObjectNew.evaluate(Unknown Source)
       at sleep.engine.Block.evaluate(Unknown Source)
       at sleep.engine.Block.evaluate(Unknown Source)
       at sleep.runtime.SleepUtils.runCode(Unknown Source)
       at sleep.runtime.ScriptInstance.runScript(Unknown Source)
       at sleep.console.TextConsole.main(Unknown Source)
Â
Â
Â
#### See http://sleep.dashnine.org/manual/hoes.html ###
import org.apache.commons.logging.LogFactory ;
import org.bouncycastle.jce.provider.BouncyCastleProvider ;
import com.comverse.rtbd.security.sdk.audit.xdas.XDasEvents;
import com.comverse.rtbd.security.sdk.audit.xdas.XDasException;
import com.comverse.rtbd.security.sdk.audit.xdas.XDasOutcomes ;
import com.comverse.rtbd.security.sdk.audit.xdas.XDasRecord ;
import com.comverse.rtbd.security.sdk.audit.xdas.XDasSession ;
import org.apache.commons.lang.BooleanUtils;
import java.lang.Object;
import java.net.InetAddress;
import java.io.IOException;
import java.net.UnknownHostException;
import java.lang.System;
Â
# see also /home/localization/bfgui_audit on billingapp server and DR-2-017-791/DR-2-021-608
# typically security.server.ip and sdk.audit.host point to the same host.
[System setProperty: "security.server.ip", "Osecserv"];
[System setProperty: "sdk.audit.host", "Osecserv"];
Â
# security.sdk.mode is optional. If note set is assumed false
[System setProperty: "security.sdk.mode", "false"];
Â
# sdk.audit.port is optional. If not set the standard port 18003 will be used
[System setProperty: "sdk.audit.port", 18003];
Â
$status = 0;
Â
########################
# write to stdout file and exit
########################
sub dieNoLog {
  println("STATUS=1");
  println("INFO=ERROR before log file creation! See console");
  exit();
}
Â
########################
# write to log file and exit
########################
sub die {
  println("STATUS=1");
  println("INFO=ERROR! Check log file ".$log_dir."/".$log_file);
  exit();
}
Â
debug(2 | 34);
println(debug());
try {
Â
                                               $log_dir = systemProperties()["myLogDirName"];
Â
                                               $log_file = "send_xdas.".formatDate("EEE").".log";
Â
                                               # Open log file
                                               if ( !-exists $log_dir ) {
                                                if ( ! mkdir($log_dir) ) { println("Cannot create log file directory; ".$log_dir." ...ABORT!"); dieNoLog(); }
                                               }
                                               $log_handle = openf(">>".$log_dir."/".$log_file);
                                               if ( checkError($error) ) {
                                                 println("Error creating/accessing log file ".$log_file." \($error\) ...ABORT!");
                                                 dieNoLog();
                                               }
Â
                                               # now the log file is created we can write to it for the first time...
                                               println($log_handle, "\n-------------- ".formatDate("yyyyMMdd-HHmmss")." --------------");
                                               println($log_handle, " -->Will create/open log file=".$log_dir."/".$log_file);
Â
                                               #######################################################
                                               #######################################################
                                               # Define the originator information
                                               $originatorName = "XE/LocPerfDetector";
                                               $originatorServiceType = "TCP/IP";
                                               $originatorAuthAuthority = "secserv";
                                               $originatorPrincipalName = "--";
                                               $originatorPrincipalIdentity = "--";
Â
                                               $localhost = [InetAddress getLocalHost];
                                               if ( checkError($error) ) {
                                                 println($log_handle,"ERROR: Error calling InetAddress getLocalHost \($error\)\nABORT!");
                                                 renameToError();
                                                 die();
                                               }
Â
                                               $originatorAddress = [$localhost getHostAddress];
Â
                                               # Open the XDAS sesssion to the security server
                                               try {
                                                               $xdas_session = [new XDasSession:"$originatorName","$originatorAddress","$originatorServiceType","$originatorAuthAuthority","$originatorPrincipalName","$originatorPrincipalIdentity"];
                                               }
                                               catch $myexception {
                                                                println($log_handle, "Caught an exception in place 11111! Exception: ".$myexception);
                                                                printAll($log_handle, getStackTrace());
                                                                renameToError();
                                                                die();
                                                 }
Â
}
catch $myexception {
     println($log_handle, "Caught an exception in place 22222222222! Exception: ".$myexception);
     printAll($log_handle, getStackTrace());
     renameToError();
     die();
  }
Â
  println($log_handle, "logfile=".$log_dir."/".$log_file);
  println($log_handle, "STATUS=0");
Â