unable to catch a Java exception - help needed

24 views
Skip to first unread message

James D

unread,
Jul 16, 2014, 5:22:43 AM7/16/14
to sleep-de...@googlegroups.com
hi all,

i have been struggling with this.

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");

 

Reply all
Reply to author
Forward
0 new messages