Catching TimedOutException from within JWS

I have a web service method within a JWS file that may take long amount of time to process. Occasionally, this method will cause a TimedOutException.
I've tried creating methods for all of the callback events outlined in the "Context.Callback" interface, but none of them seem to get triggered when this particular exception occurs. I would like to be able to catch any TimedOutExceptions that are thrown and handle the errors gracefully. Is there a way to do this?
Thanks,
David

Hi Setya,
I am very sorry ..that i didnt look at the weblogic version which u were using. Actually The Resource Injection and EJB injection are defined by Servlet Specification 2.5 Onwards...WebLogic Server 10.0 implements the Servlet 2.5 specification. These features are available Only After "WebLogic 10.0" Onwards.
So in WebLogic 9.x you cannot Inject resources.
Thanks
Jay SenSharma

Similar Messages

  • Find out who catches exception from within exception

    Hi,
    I am writing some generic Exception for our project. The aim is to simplify exception handling by making the exceptions log the necessary information with Log4J.
    It seems pretty easy to find out which class actually threw the exception (top of stack trace) but I would much rather like to log the exception in the name of the class that will catch the exception.
    The problem is that the stacktrace (it can be retrieved within an exception as of J2SE 1.4) does not contain information about which class will actually be catching the exception.
    Is there any way to accomplish that? Would be very grateful if someone could point me into the right direction if there is a possibility.
    Thank you very much in advance
    Greets Robbi

    Thanks for the quick reply.
    What I actually really wanted is to log from within the Exception. Right now I am doing this from within the Exceptions constructor.
    I see your point with the constructor being supposed to be lightweight, but in most cases the logging will be turned off and log4J does not take a lot of time to find that out.
    The logging within the catch blocks is what we wanted to circumvent as that would be the same in all catch blocks. Additionally it would be easy to simply change the topmost Exception in our hierarchy to log somewhere else instead.
    Performance is not too crucial on our application, but traceability is, as a lot of money is tied to a single transaction. That is why we decided to for Exceptions to log, as thus even when a developer would forget to log, the exception is still logged.
    Anyway, I thought that it is quite likely not possible to determine who catches an exception from within that exception. I guess the virtual machine wouldn't like to unseal that information. Maybe this is something that might work in a future Java version.
    Thanks for the input anyway.
    Regards Robbi

  • How can I execute an external program from within a button's event handler?

    I am using Tomcat ApacheTomcat 6.0.16 with Netbeans 6.1 (with the latest JDK/J2EE)
    I need to execute external programs from an event handler for a button on a JSF page (the program is compiled, and extremely fast compared both to plain java and especially stored procedures written in SQL).
    I tried what I'd do in a standalone program (as shown in the appended code), but it didn't work. Instead I received text saying the program couldn't be found. This error message comes even if I try the Windows command "dir". I thought with 'dir' I'd at least get the contents of the current working directory. :-(
    I can probably get by with cgi on Apache's httpd server (or, I understand tomcat supports cgi, but I have yet to get that to work either), but whatever I do I need to be able to do it from within the button's event handler. And if I resort to cgi, I must be able to maintain session jumping from one server to the other and back.
    So, then, how can I do this?
    Thanks
    Ted
    NB: The programs that I need to run do NOT take input from the user. Rather, my code in the web application processes user selections from selection controls, and a couple field controls, sanitizes the inoputs and places clean, safe data in a MySQL database, and then the external program I need to run gets safe data from the database, does some heavy duty number crunching, and puts the output data into the database. They are well insulated from mischeif.
    NB: In the following array_function_test.pl was placed in the same folder as the web application's jsp pages, (and I'd tried WEB-INF - with the same result), and I DID see the file in the application's war file.
            try {
                java.lang.ProcessBuilder pn = new java.lang.ProcessBuilder("array_function_test.pl");
                //pn.directory(new java.io.File("K:\\work"));
                java.lang.Process pr = pn.start();
                java.io.BufferedInputStream bis = (java.io.BufferedInputStream)pr.getInputStream();
                String tmp = new String("");
                byte b[] = new byte[1000];
                int i = 0;
                while (i != -1) {
                    bis.read(b);
                    tmp += new String(b);
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + tmp);
            } catch (java.io.IOException ex) {
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + ex.getMessage());
            }

    Hi Fonsi!
    One way to execute an external program is to use the System Exec.vi. You find it in the functions pallet under Communication.
    /Thomas

  • WPF UI running in seperate runspace - able to set/get controls via synchronized hash table, but referencing the control via the hash table from within an event handler causes both runspaces to hang.

    I am trying to build a proof of concept where a WPF form is hosted in a seperate runspace and updates are handled from the primary shell/runspace. I have had some success thanks to a great article by Boe Prox, but I am having an issue I wanted to open up
    to see if anyone had a suggestion.
    My goals are as follows:
    1.) Set control properties from the primary runspace (Completed)
    2.) Get control properties from the primary runspace (Completed)
    3.) Respond to WPF form events in the UI runspace from the primary runspace (Kind of broken).
    I have the ability to read/write values to the form, but I am having difficulty with events. Specifically, I can fire and handle events, but the minute I try to reference the $SyncHash from within the event it appears to cause a blocking condition hanging both
    runspaces. As a result, I am unable to update the form based on an event being fired by a control.
    In the example below, the form is loaded and the following steps occur:
    1.) Update-Combobox is called and it populates the combobox with a list of service names and selects the first item.
    2.) update-textbox is called and sets the Text property of the textbox.
    3.) The Text value of the textbox is read by the function read-textbox and output using write-host.
    4.) An event handle is registered for the SelectionChanged event for the combobox to call the update-textbox function used earlier.
    5.) If you change the selection on the combobox, the shell and UI hangs as soon as $SyncHash is referenced. I suspect this is causing some sort of blocking condition from multiple threads trying to access the synchronized nature of the hash table, but I am
    unsure as to why / how to work around it. If you comment out the line "$SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})" within update-textbox the event handler will execute/complete.
    $UI_JobScript =
    try{
    Function New-Form ([XML]$XAML_Form){
    $XML_Node_Reader=(New-Object System.Xml.XmlNodeReader $XAML_Form)
    [Windows.Markup.XamlReader]::Load($XML_Node_Reader)
    try{
    Add-Type –AssemblyName PresentationFramework
    Add-Type –AssemblyName PresentationCore
    Add-Type –AssemblyName WindowsBase
    catch{
    Throw "Unable to load the requisite Windows Presentation Foundation assemblies. Please verify that the .NET Framework 3.5 Service Pack 1 or later is installed on this system."
    $Form = New-Form -XAML_Form $SyncHash.XAML_Form
    $SyncHash.Form = $Form
    $SyncHash.CMB_Services = $SyncHash.Form.FindName("CMB_Services")
    $SyncHash.TXT_Output = $SyncHash.Form.FindName("TXT_Output")
    $SyncHash.Form.ShowDialog() | Out-Null
    $SyncHash.Error = $Error
    catch{
    write-host $_.Exception.Message
    #End UI_JobScript
    #Begin Main
    add-type -AssemblyName WindowsBase
    [XML]$XAML_Form = @"
    <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Window.Resources>
    <DataTemplate x:Key="DTMPL_Name">
    <TextBlock Text="{Binding Path=Name}" />
    </DataTemplate>
    </Window.Resources>
    <DockPanel LastChildFill="True">
    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
    <Label Name="LBL_Services" Content="Services:" />
    <ComboBox Name="CMB_Services" ItemTemplate="{StaticResource DTMPL_Name}"/>
    </StackPanel>
    <TextBox Name="TXT_Output"/>
    </DockPanel>
    </Window>
    $SyncHash = [hashtable]::Synchronized(@{})
    $SyncHash.Add("XAML_Form",$XAML_Form)
    $SyncHash.Add("InitialScript", $InitialScript)
    $Normal = [System.Windows.Threading.DispatcherPriority]::Normal
    $UI_Runspace =[RunspaceFactory]::CreateRunspace()
    $UI_Runspace.ApartmentState = [System.Threading.ApartmentState]::STA
    $UI_Runspace.ThreadOptions = [System.Management.Automation.Runspaces.PSThreadOptions]::ReuseThread
    $UI_Runspace.Open()
    $UI_Runspace.SessionStateProxy.SetVariable("SyncHash",$SyncHash)
    $UI_Pipeline = [PowerShell]::Create()
    $UI_Pipeline.Runspace=$UI_Runspace
    $UI_Pipeline.AddScript($UI_JobScript) | out-Null
    $Job = $UI_Pipeline.BeginInvoke()
    $SyncHash.ServiceList = get-service | select name, status | Sort-Object -Property Name
    Function Update-Combobox{
    write-host "`nBegin Update-Combobox [$(get-date)]"
    $SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.ItemsSource = $SyncHash.ServiceList})
    $SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.SelectedIndex = 0})
    write-host "`End Update-Combobox [$(get-date)]"
    Function Update-Textbox([string]$Value){
    write-host "`nBegin Update-Textbox [$(get-date)]"
    $SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})
    write-host "End Update-Textbox [$(get-date)]"
    Function Read-Textbox(){
    write-host "`nBegin Read-Textbox [$(get-date)]"
    $SyncHash.TXT_Output.Dispatcher.Invoke($Normal,[action]{$Global:Return = $SyncHash.TXT_Output.Text})
    $Global:Return
    remove-variable -Name Return -scope Global
    write-host "End Read-Textbox [$(get-date)]"
    #Give the form some time to load in the other runspace
    $MaxWaitCycles = 5
    while (($SyncHash.Form.IsInitialized -eq $Null)-and ($MaxWaitCycles -gt 0)){
    Start-Sleep -Milliseconds 200
    $MaxWaitCycles--
    Update-ComboBox
    Update-Textbox -Value $("Initial Load: $(get-date)")
    Write-Host "Value Read From Textbox: $(Read-TextBox)"
    Register-ObjectEvent -InputObject $SyncHash.CMB_Services -EventName SelectionChanged -SourceIdentifier "CMB_Services.SelectionChanged" -action {Update-Textbox -Value $("From Selection Changed Event: $(get-date)")}

    Thanks again for the responses. This may not be possible, but I thought I would throw it out there. I appreciate your help in looking into this.
    To clarify the "Respond to control events in the main runspace"... I'm would like to have an event generated by a form object in the UI runspace (ex: combo box selectionchanged event) trigger a delegate within the main runspace and have that delegate in
    the main runspace update the form in the UI runspace.
    ex:
    1.) User changes selection on combo box generating form event
    2.) Event calls delegate (which I have gotten to work)
    3.) Delegate does some basic processing (works)
    4.) Delegate attempts to update form in UI runspace (hangs)
    As to the delegates / which runspace they are running in. I see the $synchash variable if I run get-var within a delegate, but I do not see the $Form variable so I am assuming that they are in the main runspace. Do you agree with that assumption?

  • Automatic Creation of ODBC Data Source From Within Java App

    Good Day Good People :)
    I was wondering if it were possible for a java application to automatically set up an ODBC data source for a JDBC connection in a windows environment.
    This is the method I call to initialise a connection to my database:
    public void initialiseLocalConnection ()
    url = "jdbc:odbc:ICUDB";
    try
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    icuCon = DriverManager.getConnection (url);
    catch (Exception e)
    JOptionPane.showMessageDialog (null, "Error Creating Connection to ICU Database!\n" +
    "Please set up an ODBC data source pointing\n" +
    "to the icudb.mdb file located in the data\n" +
    "folder of the ICU directory and call the\n" +
    "connection 'ICUDB'.", "Database Connection Error", JOptionPane.ERROR_MESSAGE);
    Is it possible to create the ODBC data source ICUDB if it does not exist from within my application.
    All information regarding the possibilty and the application of doing this would be greatly appreciated.
    Kind Regards
    Matt

    Thank you.
    During my search I for dsn-less connections I found the soloution:
    url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" +
    System.getProperty ("user.dir") + System.getProperty ("file.separator") +
    "data" + System.getProperty ("file.separator") + "icudb.mdb";
    try
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    icuCon = DriverManager.getConnection (url);
    This works.
    Thanks for the replies.
    Matt :)

  • Determining Edit/Display Mode from Within Freestyle Component

    I am new to FPM.  We are running ESS.
    I have enhanced a new Web Dynpro Component onto an Edit page of an OVP (as a Freestyle Component).
    I want the new WDC to behave differently based on the mode I am in.
    How, from within the new WDC, can I tell if I have entered the Edit page in Edit (pencil) or Display mode?
    Thanks...
    ...Mike

    Hello Mike,
    Firstly, welcome to the wonderful world of FPM
    Well, usually with FPM, you have an Edit (or Read-only) button in the top, underneath the title (Identification Region, IDR). This, being standard, has some standard FPM events behind it.
    In your freestyle WD component, you implemented IF_FPM_BUILDING_BLOCK interface, and with it you have some additional methods in your COMPONENT CONTROLLER, such as FLUSH, PROCESS_EVENT, and so on...
    In your PROCESS_EVENT method, you can basically catch all FPM events at application level. Usually you have a big CASE, something like:
    case io_event->mv_event_id.
         when ...
         when 'FPM_EDIT'. "you can find some constants behind CL_FPM_EVENT=>GC... Right now I'm not sure how it's called exactly. But it's advised to use this constants!
              You can write your code here in order to change the behavior, basically, you can do whatever.
              also, it's the same with 'FPM_READ_ONLY'
         when others.
              return.
    endcase.
    I strongly recommend you download the latest version of FPM Cookbook, or the one that is suited with your SAP NW version.
    FPM Developer's Handbook SAP NetWeaver 7.03/7.31 SP4
    Hope I made things a little more clear!
    Tudor

  • Start a WS application from within a java program

    Hi,
    I need to start a WebStart application from within a java program. Therefore I develeoped a class which starts javaws.exe within its main-method like this:
    try {
    Runtime.getRuntime().exec(
    "c:\\java web start\\javaws.exe http://a.b/c.jnlp"
    } catch (Exception e) {
    e.printStackTrace();
    And that did not work. Java Web Start tries to start the .jnlp program but returns with the message, that the app-desc|applet-desc|installer-desc|component-desc is missing. But it is there: It is an applet and thus I defined an applet-dec.
    I tried to do it from a command line with the followinf command:
    java -Djnlpx.home="C:\abc" -cp "C:\abc\javaws.jar" com.sun.javaws.Main http://a.b/c.jnlp
    And that works. But using this command from within my jjava prog using the Runtime.exec() method does not work.
    By the way, simply type "javaws http://a.b/c.jnlp" at the command line does not work.
    Can anybody help me? How may I start a .jnlp program within another java program.
    Kind Regards,
    Tobias Neubert

    Hi,
    I recently had a quite similar problem. At least the error message by the Java Web Start application on Mac OS X complained about the same error (app-desc|applet-desc|installer-desc|component-desc). It turned out to be some bad invisible characters in the jnlp file. I copied some sample from a web page which for some reason contained some unicode chars that the parser doesn't like. Use a different text editor or the less command on unix to see if there are some strange characters in you jnlp file.
    But it seems strange that it does work from the command line and not from your code.
    -Stefan

  • Is it allowed to make a rmi call from within an ejb??

    Hello,
    Am I allowed to make a rmi call from within an ejb such as:
    String host = "localhost";
    RemoteObject ro = (RemoteObject) Naming.lookup("rmi://"+host+"/MonServeur");
    ro.myMethod();
    package pack;
    import java.rmi.Naming;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;
    public class MyRemoteObject extends UnicastRemoteObject implements RemoteObject {
        public MyRemoteObject() throws RemoteException {
        public void myMethod() throws RemoteException {
            System.out.println("toto");
        public static void main(String[] args) {
            try {
                RemoteObject ro = new MyRemoteObject();
                Naming.rebind("MonServeur", ro);
            } catch (Exception ex) {
                ex.printStackTrace();
    }Is it allowed by the spec?
    Is it good design?
    Thanks in advance,
    Julien Martin.

    Allowed - yes
    Good design - no, in my opinion.

  • JMX from within an iView

    Hi,
    I've got problems using JMX from within an iView. I try to connect to the local MBeanServer using the following code:
    [code]
      public void doProcessBeforeOutput() throws PageException {
        Form myForm = this.getForm();
        // Get connection to MBeanServer
        InitialContext ctx;
        try {
          ctx = new InitialContext();
          Object objref = ctx.lookup("jmx");               
          MBeanServer conn = (MBeanServer)objref;
        } catch (NamingException e) {
          e.printStackTrace();
    [/code]
    The lookup returns an object of type "com.sap.pj.jmx.server.interceptor.MBeanServerInterceptorChain" which should implement
    the Interface "MBeanServer". Anyhow I get the following error while trying to cast the returned object to type MBeanServer:
    [code]
         at com.sapportals.portal.prt.core.PortalRequestManager.handlePortalComponentException(PortalRequestManager.java:969)
         at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:343)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
         at com.sapportals.portal.prt.core.async.AsyncIncludeRunnable$1$DoDispatchRequest.run(AsyncIncludeRunnable.java:377)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sapportals.portal.prt.core.async.AsyncIncludeRunnable.run(AsyncIncludeRunnable.java:390)
         at com.sapportals.portal.prt.core.async.ThreadContextRunnable.run(ThreadContextRunnable.java:164)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:729)
         at java.lang.Thread.run(Thread.java:534)
    Caused by: java.lang.NoClassDefFoundError: javax/management/MBeanServer
         at com.top_logic.sap.JMXTestiView$JMXTestiViewDynPage.doProcessBeforeOutput(JMXTestiView.java:46)
         at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:123)
         at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
         at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
         at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
         at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
         ... 7 more
    [/code]
    I set the "tc/jmx"-library as "Additional Library" using the Right-Mouse-Click-Context-Menu on the Project Node in Netweaver
    Developer Studio...
    What else needs to be done to get jmx working in an iView-Environment?
    Thanks in advance
    Thorsten Wittmann

    Thank you Maksim,
    when specifying a sharing reference like
    SAPJ2EE::library:tc/jmx
    in the portalapp.xml-File, the server-lookup is working.
    Best regards,
    Thorsten

  • I'm operating OS X 10.8.5, Mail 6.6, and I can't seem to extract jpgs or pdfs from within an email thread.  Any suggestions as to how I can retrieve these files?

    I"m operating OS X 10.8.5,  Mail 6.6 and have discovered I can not extract jpgs from within an email thread.  If I catch it upon arrival, everything's fine, but if I reply and continue the thread, the file is no longer extractable.  Any advice?
    Thank you,
    April Snow

    Thanks Eric,
    I would try that if I could see the jpeg file.  The problem is that once the original email has been responded to, and the thread continued, the jpg files disappear from the body of the original email.  Hmmm.  They must be there somewhere, but I can not locate them.

  • No access to method from within the same class

    Hey there.
    First I have to excuse my English for I'm german and just learning...
    Ok, my problem is as follows. I have a class called JDBC_Wrapper it includes the method sendQuery(String query). When I call this method from within another class (where 'wrapper' is my instance of JDBC_Wrapper) it works fine. For example:
    wrapper.sendQuery("SELECT * FROM myDataBase");
    But then I have written a method called getNumRows() into my JDBC_Wrapper class.
    This method should send a query through sendQuery(Strin query) but when calling getNumRows() it says: "java.sql.SQLException: [FileMaker][ODBC FileMaker Pro driver][FileMaker Pro]Unbekannter Fehler." (Unbekannter Fehler -> Unknown Exception). What could that be?
    I'm using jdk2 sdk 1.4.2 with BlueJ. My database is Filemaker Pro 6. The ODBC/JDBC connector works fine.
    BerndZack

    This is within my JDBC_Wrapper class:
    public ResultSet sendQuery(String query)
            if(connected)
                try
                    Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
                    ResultSet rs = s.executeQuery(query);
                    return rs;
                catch(Exception e)
                    System.out.println(e);
            else
                //System.out.println("There is no connection to the datasource!");
            return null;
    public int getNumRows()
            try
                ResultSet r;
                r = this.sendQuery("SELECT COUNT(*) FROM " + table_name); // At this line the error occurs
                r.next();
                return (int)r.getInt(1);
            catch(Exception e)
                System.out.println(e.getMessage());
                return -1;
    }When I call sendQuery() from within another class it works, but calling getNumRows()
    throws an exception.

  • Jar file - trying to load audio from within it

    I am writing a Game using NetBeans. All works fine when run from within NetBeans, but problems occur when run from a JAR executable.
    The Audio files are not loading. I had a Similar problem with the Images, but resolved it with getResources() etc.
    Any help would be much appreciated, and will post my game when its finished, horray
         * Loads a sequence from the file system. Returns null if
         * an error occurs.
        public Sequence getSequence(String filename)
            try
                return getSequence( new FileInputStream(filename));
            catch (IOException ex)
                ex.printStackTrace();
                return null;
         * Loads a sequence from an input stream. Returns null if
         * an error occurs.
        public Sequence getSequence(InputStream is)
            try
                if (!is.markSupported())
                    is = new BufferedInputStream(is);
                Sequence s = MidiSystem.getSequence(is);
                is.close();
                return s;
            catch (InvalidMidiDataException ex)
                ex.printStackTrace();
                return null;
            catch (IOException ex)
                ex.printStackTrace();
                return null;
        }

    new FileInputStream(filename))That only works for files. Resources in JARs are not files. You should always (when possible) use getClass().getResourceAsStream() to open streams on resources, loading them from the classpath -- regardless of whether your app is a bunch of loose files or in a JAR.

  • Problem sending mail from within C#

    Sorry, I am posting this question for the second time !!!!
    I have constructed a snippet that sends mail from within C#.In My script, there are will be several receivers of my mail. The script will read from a file, mail addresses and send mail to each individual contained in the file. As test I run the script with
    two mail addresses in the file,one my own and the second with outlook mail. However, the result is I get the mail but the second receiver  never gets it.
       What is the problem ????
    Please help
    I debugged the program and verified that Nsmtp and Mailreceiver are correct
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Net;
    using System.Net.Mail;
    using System.Net.Mime;
    using System.Text;
    using System.Windows.Forms;
    namespace Note_Pss
    public partial class Email : Form
    public Note_Pss.Form1 m_parent;
    Util util = new Util(); string signal = "#";
    char g = System.Convert.ToChar("*");
    char X = System.Convert.ToChar("@");
    Utility_Types utility_type = new Utility_Types(); string P = "";
    char p; String Mailsender; String Npass; String Nsmtp;
    String Mailreceiver; String Mailbody; String MailTitle;
    MailMessage mail = new MailMessage();
    public Email(Note_Pss.Form1 parent)
    InitializeComponent();
    m_parent = parent;
    string ListContent = util.openf(wsk.storagedbase + @"\TemFile");
    wsk.listArray = util.arrayadjust(ListContent, signal);
    private void multi_mail_Send()
    {char g = System.Convert.ToChar("*");
    MailParameters();
    int Count_num = wsk.listArray.Count;
    for (int i = 0; i < Count_num; i++)
    string P = wsk.listArray[i].ToString();
    string[] Sub_File = P.Split(g);
    Mailreceiver = Sub_File[2].ToString();
    Nsmtp = "smtp."+msmtp_name(Mailreceiver, "@");
    Send_Mail();
    //if (Enclosure.Text != "") MailAttachment();
    //MailBody();
    private String msmtp_name(string p, string p_2)
    string P = p.ToString();
    string[] Pp = P.Split(X);
    string bbb = Pp[1];
    return bbb;
    private void MailParameters()
    Mailsender = Sender.Text;
    Npass = Senderpass.Text;
    Mailbody = Body.Text;
    MailTitle = Subject.Text;
    private void Send_Mail()
    try
    MailMessage mail = new MailMessage();
    SmtpClient client = new SmtpClient();
    client.Port = 587;
    client.Host = Nsmtp;
    mail.From = new MailAddress(Mailsender);
    mail.To.Add(Mailreceiver);
    mail.Subject = MailTitle;
    mail.Body = Mailbody;
    textBox1.Text = Nsmtp + " " + Mailreceiver;
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.UseDefaultCredentials = false;
    client.Credentials = new System.Net.NetworkCredential(Mailsender, Npass);
    client.EnableSsl = true;
    client.Send(mail);
    catch (Exception ex) { textBox1.Text = ex.ToString(); }
    private void MailSend_Click(object sender, EventArgs e)
    { multi_mail_Send(); }
    private void button2_Click(object sender, EventArgs e)
    { Enclosure.Text = util.openImage();}
    private void button1_Click(object sender, EventArgs e)
    this.Close();

    Nsmtp and Mailreceiver are verified through debugging:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Net.Mail;
    using System.Net.Mime;
    using System.Net;
    namespace Note_Pss
    public partial class Email : Form
    public Note_Pss.Form1 m_parent;
    Util util = new Util(); string signal = "#";
    char g = System.Convert.ToChar("*");
    char X = System.Convert.ToChar("@");
    Utility_Types utility_type = new Utility_Types(); string P = "";
    char p; String Mailsender; String Npass; String Nsmtp;
    String Mailreceiver; String Mailbody; String MailTitle;
    MailMessage mail = new MailMessage();
    public Email(Note_Pss.Form1 parent)
    InitializeComponent();
    m_parent = parent;
    string ListContent = util.openf(wsk.storagedbase + @"\TemFile");
    wsk.listArray = util.arrayadjust(ListContent, signal);
    private void multi_mail_Send()
    char g = System.Convert.ToChar("*");
    MailParameters();
    int Count_num = wsk.listArray.Count;
    for (int i = 0; i < Count_num; i++)
    string P = wsk.listArray[i].ToString();
    string[] Sub_File = P.Split(g);
    Mailreceiver = Sub_File[2].ToString();
    Nsmtp = "smtp." + msmtp_name(Mailreceiver, "@");
    Send_Mail();
    //if (Enclosure.Text != "") MailAttachment();
    //MailBody();
    private String msmtp_name(string p, string p_2)
    string P = p.ToString();
    string[] Pp = P.Split(X);
    string bbb = Pp[1];
    return bbb;
    private void MailParameters()
    Mailsender = Sender.Text;
    Npass = Senderpass.Text;
    Mailbody = Body.Text;
    MailTitle = Subject.Text;
    private void Send_Mail()
    try
    MailMessage mail = new MailMessage();
    SmtpClient client = new SmtpClient();
    client.Port = 587;
    client.Host = Nsmtp;
    mail.From = new MailAddress(Mailsender);
    mail.To.Add(Mailreceiver);
    mail.Subject = MailTitle;
    mail.Body = Mailbody;
    //SmtpServer.Port = 25;
    //textBox1.Text = Nsmtp + " " + Mailreceiver;
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.UseDefaultCredentials = false;
    client.Credentials = new System.Net.NetworkCredential(Mailsender, Npass);
    client.EnableSsl = true;
    client.Send(mail);
    // MessageBox.Show("mail Send");
    catch (Exception ex) { }
    private void MailSend_Click(object sender, EventArgs e)
    { multi_mail_Send(); }
    private void button2_Click(object sender, EventArgs e)
    { Enclosure.Text = util.openImage(); }
    private void button1_Click(object sender, EventArgs e)
    this.Close();

  • Running unix commands from within a procedure

    Oracle 11.1, AIX 6.1
    ================
    A developer would like to know what the commands are to execute from within a procedure to run unix commands on the database server and capture those results back to the procedure for parsing & manipulation.
    Thanks.

    Don't take this as the correct way to do it, but this is merely 'a' way to do it:
    have a db procedure thats executes a db function
    create or replace procedure csproc(p_cmd in varchar2)
    as
    x number;
    begin
    x:=csfunc(p_cmd);
    dbms_output.put_line('x is: '||x);
    end;
    /The function calls a piece of java to execute the os command and return the return code of the os command
    create or replace function csfunc( p_cmd  in varchar2) return number
    as language java
    name 'csclass.RunThis(java.lang.String[]) return integer';
    /Here is the java class to run the os command
    create or replace and compile java source
    named "csclass"
    as
    import java.io.*;
    import java.lang.*;
    public class csclass extends Object
    public static int RunThis(String[] args)
       Runtime rt = Runtime.getRuntime();
        int        rc = -1;
        try
           Process p = rt.exec(args[0]);
          int bufSize = 4096;
           BufferedInputStream bis =
           new BufferedInputStream(p.getInputStream(), bufSize);
           int len;
           byte buffer[] = new byte[bufSize];
           // Echo back what the program spit out
           while ((len = bis.read(buffer, 0, bufSize)) != -1)
              System.out.write(buffer, 0, len);
           rc = p.waitFor();
        catch (Exception e)
           e.printStackTrace();
           rc = -1;
        finally
           return rc;
    /and finally the os command - in this case its a very simple shell script
    #!/usr/bin/ksh
    echo "Hi" >> /app/oracle/workdir/cs.logwill have to grant privileges to my user 'CS' to run the various os commands
    exec dbms_java.grant_permission('CS','java.io.FilePermission','/app/oracle/workdir/cs.ksh','read,execute');
    exec dbms_java.grant_permission('CS','java.io.FilePermission','/app/oracle/workdir/cs.log','write');
    exec dbms_java.grant_permission('CS','SYS:java.lang.RuntimePermission','*','readFileDescriptor');
    exec dbms_java.grant_permission('CS','SYS:java.lang.RuntimePermission','*','writeFileDescriptor');and finally can run the procedure from within the db
    set serveroutput on
    exec dbms_java.set_output(1000000);
    exec csproc('/app/oracle/workdir/cs.ksh');
    x is: 0
    PL/SQL procedure successfully completed.to prove it works ok the logfile shows an entry:
    'Hi'

  • Finding hard and soft open file limits from within jvm in linux

    Hi All,
    I have a problem where I need to find out the hard and soft open file limits for the process in linux from within a java program. When I execute ulimit from the terminal it gives separate values for hard and soft open file limits.
    From shell if I run the command then the output is given below:
    $ ulimit -n
    1024
    $ ulimit -Hn
    4096
    The java program is given below:
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.Reader;
    import java.io.StringWriter;
    import java.io.Writer;
    public class LinuxInteractor {
    public static int executeCommand(String command, boolean waitForResponse, OutputHandler handler) {
    int shellExitStatus = -1;
    ProcessBuilder pb = new ProcessBuilder("bash", "-c", command);
    pb.redirectErrorStream(true);
    try {
    Process shell = pb.start();
    if (waitForResponse) {
    // To capture output from the shell
    InputStream shellIn = shell.getInputStream();
    // Wait for the shell to finish and get the return code
    shellExitStatus = shell.waitFor();
    convertStreamToStr(shellIn, handler);
    shellIn.close();
    catch (IOException e) {
    System.out
    .println("Error occured while executing Linux command. Error Description: "
    + e.getMessage());
    catch (InterruptedException e) {
    System.out
    .println("Error occured while executing Linux command. Error Description: "
    + e.getMessage());
    return shellExitStatus;
    public static String convertStreamToStr(InputStream is, OutputHandler handler) throws IOException {
    if (is != null) {
    Writer writer = new StringWriter();
    char[] buffer = new char[1024];
    try {
    Reader reader = new BufferedReader(new InputStreamReader(is,
    "UTF-8"));
    int n;
    while ((n = reader.read(buffer)) != -1) {
    String output = new String(buffer, 0, n);
    writer.write(buffer, 0, n);
    if(handler != null)
    handler.execute(output);
    } finally {
    is.close();
    return writer.toString();
    } else {
    return "";
    public abstract static class OutputHandler {
    public abstract void execute(String str);
    public static void main(String[] args) {
    OutputHandler handler = new OutputHandler() {
    @Override
    public void execute(String str) {
    System.out.println(str);
    System.out.print("ulimit -n : ");
    LinuxInteractor.executeCommand("ulimit -n", true, handler);
    System.out.print("ulimit -Hn : ");
    LinuxInteractor.executeCommand("ulimit -Hn", true, handler);
    If I run this program the output is given below:
    $ java LinuxInteractor
    ulimit -n : 4096
    ulimit -Hn : 4096
    I have used ubuntu 12.04, Groovy Version: 1.8.4 JVM: 1.6.0_29 for this execution.
    Please help me in understanding this behavior and how do I get a correct result from withing the java program.

    Moderator Action:
    As mentioned in one of the earlier responses:
    @OP this is not a Java question. I suggest you take it elsewhere, i.e. to a Unix or Linux forum.You posted this to a Java programming forum.
    It is not a Java programming inquiry.
    This off-topic thread is locked.
    Additionally, you have answered your own question.
    Don't bother posting it to one of the OS forums. It will get deleted as a duplicate cross-post.

Maybe you are looking for