Cannot catch Exception thrown by ADF (source of exception is EJB)

Even I tried to use try catch block, it still shows unwanted error popup (showing errors) automatically generated by adf.
I know the source of this error is EJB, I try to insert duplicate field which must be unique. So EJB throws jdbc exception.
How can I disable popup automatically generated by ADF and show my custom error text?
        try {
            BindingContainer bindings = getBindings();
            OperationBinding operationBinding = bindings.getOperationBinding("mergeCity");
            Object result = operationBinding.execute();   
            closePopup(popEdit);
            refreshTable();
            if (!operationBinding.getErrors().isEmpty()) {           
                return null;
        } catch (Exception e) {
            System.out.println(".......... Error..........");
        }        Edited by: user12025867 on Oct 10, 2009 11:17 AM

For custome error handling check this thread.
Handling custom exceptions in 11g
if you call this on button action, do not use partialSubmit that way when the page refreshes the popup will be gone automatically.

Similar Messages

  • Error Catching Exceptions on EJB Clients

    I'm trying to throw an owm exception from an EJB Session to my EJB
    client. I can catch the exception but when i use the getMessage()
    method the String I receive is not the message I used to create the
    exception. The result of the getMessage() call is the same that them
    call to printStackTrace().
    does anybody knows if weblogic in change the message of the
    exception for the printStackTrace before throws the exception to the
    client?
    Thanks.

    David,
    Refer to the following link for best practices concerning EJB exception handling:
    http://dev2dev.bea.com/articles/Rong.jsp
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Cata" <[email protected]> wrote:
    >
    I'm trying to throw an owm exception from an EJB Session to my EJB
    client. I can catch the exception but when i use the getMessage()
    method the String I receive is not the message I used to create the
    exception. The result of the getMessage() call is the same that them
    call to printStackTrace().
    does anybody knows if weblogic in change the message of the
    exception for the printStackTrace before throws the exception to the
    client?
    Thanks.

  • Catching exception of a super constructor

    Is it possible to catch the exception thrown by a super class
    constructor in a sub clas constructor?
    public class A
         public A() throws Exception
              throw new Exception("Exception from A");
    class B extends A
         public B()
              try
                   super();
              catch(Exception e)
    }I get an error saying,
    A.java:16: call to super must be first statement in constructor
    super();
    ^
    Any thoughts?

    More on this here,
    http://archive.devx.com/free/tips/tipview.asp?content_i
    =2384&Java=ONThanks for that link. I completely agree to what it says.
    In other words, not being able to successfully construct our super class implies that we cannot create our derived class.
    But I feel this must be mentioned clearly somewhere in JLS. And the error message that we get must be "You cannot catch exceptions thrown by a super class constructor".

  • How to catch exception thrown from a function module?

    Hi all,
             When we are calling a function module from JSPDynpage setting some import parameters, If in some case an exception is thrown in the function module.  How can we catch the same exception in the JSPDynpage program?
    Thanks & Regards,
    Ravi

    Hi Ravi
                                    Try this
                                                try
                    Object retMsgs = output.get(bapiretrunmsgobject);
                      if(result != null )
    IrecordSet rmsg = (IrecordSet) result
                   catch(Exception ex)
                        printException(ex, "Error getting function result");
    Lemme know for any further questions.
    Regards
    Praveen

  • Help Me, How to catch exception thrown from ejbStore

    Hi,
    I am working on application running on Iplanet Application Server 4.0. Problem is the application exception thrown from the ejbStore don't reach the calling servlet, calling servlet receive TransactionRollback exception which is system exception. But there is no sign of my application exception thrown from ejbStore. Can anybody tell me how I can get my ApplicationException thrown from ejbStore in my calling servlet.
    I am calling entity beans set method in servlet and in entity bean ejbStore method I am throwing Application exception.
    in entity bean
    public void ejbStore() throws MyException
    if(true) throw new MyException();
    in servlet
    try {
    MyEntityHome home = .......
    MyEntityRemote remote = home.findBy.....
    remote.setMyValue(MyValue value); //Transaction required Container managed
    }catch(MyException e) {
    e.printStackTrace(); // Not cahcing My Exception
    }catch(Exception e) {
    e.printStackTrace(); //catching TransactionRolledBackException
    Thanks
    Shakti

    Hi Ravi
                                    Try this
                                                try
                    Object retMsgs = output.get(bapiretrunmsgobject);
                      if(result != null )
    IrecordSet rmsg = (IrecordSet) result
                   catch(Exception ex)
                        printException(ex, "Error getting function result");
    Lemme know for any further questions.
    Regards
    Praveen

  • Catch exception inside function arguments

    Class A is a core class in my application. When users create it with bad name format, they get an exception.
    public class A{
        public A(String name) throws FormatException{
            // Check if the name the user entered is valid or not.
    }But during the startup of my application I also create some instances of A. At startup time, any exception caught means that my source code is wrong: a bug on my own!
    In this context I got myself with the following problem, how to catch an exception (that should not happen, because it comes from inside my source code) inside a function call:
        // Create an instance of B that wraps A.
        B b = B( new A("a_name_in_a_good_format") , some_other_parameter); // Possible exception from the constructor of A.Is there any way to catch that, or I'm obliged to create the instance of A before calling any function?
    Edited by: ffrantz on Apr 1, 2010 10:15 AM
    Edited by: ffrantz on Apr 1, 2010 10:17 AM

    Thanks. I guess that is the only solution.
    My problem is that I'm using that in the initialization of an enum, and there's no way to put that construction inside a try/catch block. Code looks like.
    public static enum myReferenceInstancesToClone {
        SIGNAL_MAGNITUDE(new C("mag"), some_other_parameters), // C extends A
        SIGNAL_FREQUENCY(new D("freq"), some_other_parameters), // D extends A
        RESISTIVITY     (new A("R")), some_other_parameters),
        INDUCTANCE      (new A("L") , some_other_parameters),
        CAPACITANCE     (new A("C"), some_other_parameters);
        // FIELDS
        private A _referenceInstance;
        private Object[] _refParameters; // A set of private fields that interest me
        // METHODS
        private OutputPropertiesA property, Object[] some_other_parameters){
         _value = property;
            _refParameters = some_other_parameters
        // Other methods that are convenient to get fields.I'm doing it that way because i'm designing the data model for our application and it is uncertain what is the number and nature of properties that we will need to use. This construction with enums seemed good for me because:
    1) Other designers can add properties in a single line. Without looking around on the rest of the source code.
    2) The initialization process keeps probing the same enumeration, independent on the number/nature of the elements contained in it.
    It is in this context that I cannot catch the exception thrown by the constructor of A:
    public static enum myReferenceInstancesToClone {
        SIGNAL_MAGNITUDE(new C("mag"), some_other_parameters), // Java compiler tells me I have an unhandled exception from 'new C()'
        // ...If there is no way to catch that exception or propagate it.. then I'll do it with static arrays and static initialization blocks... but this means that I'll have to break my 'some_other_parameters' in different arrays.

  • Cannot catch ClassNotFoundException

    Hi all,
    I have found a strange behaviour in my java VM (1.3.1_07 Sun)
    Consider the following Code
    Class serviceClass = null;
    try
    serviceClass = Class.forName(tmp[0]);
    catch (ClassNotFoundException e)
    logger.error(e);
    return false
    Now if the class i request is not found, everything is ok. I get the exception. but if the class is found BUT cannot be LOADED because a dependency of this class cannot be found, a ClassNotFoundException will be thrown which i cannot catch.
    Is that a bug or by design.
    If it is by design, I have to say I find it rather anoying, because the current thread will end and I have way to prevent that.

    It probably throws a ClassDefNotFound instead.
    You could've added some simple debug to your code to find this out though....
    eg.
    Class serviceClass = null;
    try
        serviceClass = Class.forName(tmp[0]);
    catch (ClassNotFoundException e)
       logger.error(e);
       return false
    catch ( Exception ex )
       // something unexpected happened...
       e.printStackTrace();
       return false;
    }regards,
    Owen

  • How to catch exception when have max connection pool

    hi,
    i have define in oracle user that i could have max 10 sessions at the same time.
    I have jdbc datasource & connection pool defined at glassfish server(JSF application).
    now, if in application is too many queries to the database then i have error: nullpointer exception - becouse when i try to do:
    con = Database.createConnection(); - it generates nullpointer exception becouse there isn't free connection pool
    i try to catch exception like this:
    public List getrep_dws_wnioski_wstrzymane_graph() {     int i = 0;     try {     con = Database.createConnection();     ps =    (Statement) con.createStatement();     rs = ps.executeQuery("select data, klasa, ile_dni_wstrzymana, ile_wnioskow from stg1230.dwsww_wstrzymane_dws8 order by data, klasa, ile_dni_wstrzymana, ile_wnioskow");     while(rs.next()){       rep_dws_wnioski_wstrzymane_graph.add(i,new get_rep_dws_wnioski_wstrzymane_graph(rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4)));       i++;     }     } catch (NamingException e) {         e.printStackTrace();     } catch (SQLException e) {         e.printStackTrace();     } catch (NullPointerException e) {         e.printStackTrace();         throw new NoConnectionException();  // catch null 1     } finally {     try {         con.close();     } catch (SQLException e) {         e.printStackTrace();     } catch (NullPointerException e) {         e.printStackTrace();         throw new NoConnectionException();  // catch null 2     }     } return rep_dws_wnioski_wstrzymane_graph; }
    but at line:
    con.close();
    i have nullpointerexception
    and
    at line
    throw new NoConnectionException(); // catch null 2
    i have: caused by exception.NoConnectionException
    what's wrong with my exception class? how to resolve it?
    public class NoConnectionException extends RuntimeException{     public NoConnectionException(String msg, Throwable cause){       super(msg, cause);     }     public NoConnectionException(){       super();     } }
    at web.xml i have defined:
    <error-page>         <exception-type>exception.NoConnectionException</exception-type>         <location>/NoConnectionExceptionPage.jsp</location>     </error-page>

    thanks,
    i did it and i have error:
    java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit
    at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:115)
    at logic.Database.createConnection(Database.java:37): conn = ds.getConnection();
    public class Database {
         public static Connection createConnection() throws NamingException,
                    SQLException {
                Connection conn = null;
                try{
                    Context ctx = new InitialContext();
              if (ctx == null) {
                   throw new NamingException("No initial context");
              DataSource ds = (DataSource) ctx.lookup("jdbc/OracleReports");
              if (ds == null) {
                   throw new NamingException("No data source");
              conn = ds.getConnection();  // here's exception when max connections to database
              if (conn == null) {
                   throw new SQLException("No database connection");
                } catch (NamingException e) {
                    e.printStackTrace();
                    throw new NoConnectionException(); 
             } catch (SQLException e) {
                 e.printStackTrace();
                    throw new NoConnectionException(); 
                catch (NullPointerException e) {
                 e.printStackTrace();
                    throw new NoConnectionException();  // obsluga bledy na wypadek jesli braknie wolnych polaczen do bazy
            return conn;
    }and at my ealier code i have error:
    at logic.GetDataOracle.getrep_dws_wnioski_wstrzymane_graph(GetDataOracle.java:192)
    at line: con = Database.createConnection();
    in code:
    public List getrep_dws_wnioski_wstrzymane_graph() {
        int i = 0;
        try {
        con = Database.createConnection();
        ps =    (Statement) con.createStatement();
        rs = ps.executeQuery("select data, klasa, ile_dni_wstrzymana, ile_wnioskow from stg1230.dwsww_wstrzymane_dws8 order by data, klasa, ile_dni_wstrzymana, ile_wnioskow");
        while(rs.next()){
          rep_dws_wnioski_wstrzymane_graph.add(i,new get_rep_dws_wnioski_wstrzymane_graph(rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4)));
          i++;
        } catch (NamingException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (NullPointerException e) {
            e.printStackTrace();
            throw new NoConnectionException();
        } finally {
        try {
            if(con != null)
            con.close();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (NullPointerException e) {
            e.printStackTrace();
            throw new NoConnectionException(); 
    return rep_dws_wnioski_wstrzymane_graph;
    }so what's wrong?
    i have limit max sessions 10 at oracle so i set at my connection pool 5 connections as max. But when i get max 5 sesssins and try to execute next query then i can't catch exception..

  • Facing java.lang.ClassCastException: DummyPagePhaseListener cannot be cast to oracle.adf.model.RegionController while am using master detail relationship by af:table

    Hi friends,
         We are in to new development in Oracle ADF and newbie to this technology.
         Created .jsf page and in corresponding pagedef, has "ControllerClass" with refering "DummyPagePhaseListener" and we have master-detail relationship using Viewlink(created using a SQL Query and  entity based view).
        Below exception raised when navigating from one  to another record in Master af:table. Any help will be appreciated. Thanks in Advance......
    java.lang.ClassCastException: DummyPagePhaseListener cannot be cast to oracle.adf.model.RegionController
    at oracle.adf.model.binding.DCBindingContainer.getRegionController(DCBindingContainer.java:5197)
    at oracle.adf.model.binding.DCBindingContainer.validate(DCBindingContainer.java:4247)
    at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.validateModelUpdates(PageLifecycleImpl.java:300)
    at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.validateModelUpdates(FacesPageLifecycle.java:70)
    at oracle.adf.controller.v2.lifecycle.Lifecycle$6.execute(Lifecycle.java:202)
    at oracle.adfinternal.controller.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:197)
    at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.access$600(ADFPhaseListener.java:23)
    at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$3.after(ADFPhaseListener.java:323)
    at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:75)
    at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:53)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:447)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:202)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:173)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:125)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)
    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:180)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

    Hi timo,
    Thanks for ur reply...
    we are using unbounded taskflow.
    In Controller class(page def file), we refered the class that implements PagePhaseListener
    The following override methods has created
      public void afterPhase(PagePhaseEvent pagePhaseEvent) {
    //In this area we used to read the session object file which is written and sent by another application(application to application navigate).
    If session object file exists,will allow the user to navigate into the requested page else will navigate in to login(security aspect).
      public void beforePhase(PagePhaseEvent pagePhaseEvent) {
    Is we used Controller class wrongly ???
    Is there any relationship with region controller???
    Mani
    [email protected]

  • Doubt on try/catch exception object

    why it is not advisable to catch type exception in try catch block. Its confusing me. If i catch exception object then it will show whatever exception occured.
    btw, i was just go through duke stars how it works and saw this
    http://developers.sun.com/forums/top_10.jsp
    Congrats!

    Because there are many different kinds of Exception. If you have some specific local strategy for dealing with a particular excepion then you should be using a specific catch block.
    If you don't then you should allow the expection to end the program, and ideally you should deal with all the expceptions in one top-level handler, so you should throw, rather than catch the exceptions in your methods. Often at the outer most level of the program or thread you will actually catch Throwable (not just Exception) to deal with any unanticipated problems in a general kind of way.
    Also, you should be keeping track of what exceptions might be thrown, so that rather than using Exception in a throws clause or catch block, you should use the particular exceptions. Exceptions, generally, indicate a recoverable error that you really ought to be recovering from rather than just printing a stacktrace.
    That's why exceptions are treated differently from runtime errors.

  • Wehre can i find all the throw and catch exceptions

    I havent had much success figuring out which predefined exceptions i should/can use. Can someone please guide me where i can find out what kind of throw and catch exceptions are there in java and how and where can i find them. thanks.

    Read this first: http://java.sun.com/docs/books/jls/second_edition/html/exceptions.doc.html#44044
    You can't find them all anywhere. You'll just encounter them as you use different APIs.
    One of the most basic concepts around exceptions has to do with the difference between checked and unchecked exceptions. Any exception that extends RuntimeException is unchecked. Which means that if you call a method that throws an unchecked exception, you don't have to provide a catch block. These exceptions are usually thrown for things that could be avoided, i.e. programmer error.
    The compiler will require you to have a catch block for all checked exceptions. This means you should take steps in your code to handle them and retry the operation, such as user errors.

  • Java.lang.ClassCastException: java.lang.String cannot be cast to oracle.adf

    Hi,
    Please help me to understand why this error comes.
    I have deployed ear file into glass fish server.
    Using adf essential in Jdevelepor 11.1.2.3.0.
    [#|2012-12-04T19:17:51.658+0530|INFO|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=21;_ThreadName=Thread-2;|PWC1412: WebModule[null] ServletContext.log():JspServlet error: Servlet unable to dispatch to the following requested page: The following exception occurred:java.lang.ClassCastException: java.lang.String cannot be cast to oracle.adf.view.rich.model.RegionModel|#]
    [#|2012-12-04T19:17:51.658+0530|INFO|glassfish3.1.2|oracle.j2ee.jsp|_ThreadID=21;_ThreadName=Thread-2;|unable to dispatch JSP page: The following exception occurred:.
    java.lang.ClassCastException: java.lang.String cannot be cast to oracle.adf.view.rich.model.RegionModel
         at oracle.adf.view.rich.component.fragment.UIXRegion.getValue(UIXRegion.java:1587)
         at oracle.adf.view.rich.component.fragment.UIXRegion.getRegionModel(UIXRegion.java:415)
         at oracle.adfinternal.view.faces.taglib.region.RegionTag.doStartTag(RegionTag.java:107)
         at oracle.jsp.runtime.tree.OracleJspBodyTagNode.executeHandler(OracleJspBodyTagNode.java:50)
         at oracle.jsp.runtime.tree.OracleJspCustomTagNode.execute(OracleJspCustomTagNode.java:261)
         at oracle.jsp.runtime.tree.OracleJspClassicTagNode.evalBody(OracleJspClassicTagNode.java:87)
         at oracle.jsp.runtime.tree.OracleJspIterationTagNode.executeHandler(OracleJspIterationTagNode.java:45)
         at oracle.jsp.runtime.tree.OracleJspCustomTagNode.execute(OracleJspCustomTagNode.java:261)
         at oracle.jsp.runtime.tree.OracleJspClassicTagNode.evalBody(OracleJspClassicTagNode.java:87)
         at oracle.jsp.runtime.tree.OracleJspBodyTagNode.executeHandler(OracleJspBodyTagNode.java:58)
         at oracle.jsp.runtime.tree.OracleJspCustomTagNode.execute(OracleJspCustomTagNode.java:261)
    Thanks for the help in advance..

    It seems you have used a taskflow on a page and one of the binding.
    It will be easy to point out if you paste the code of region tag *<af:region.......*.

  • Cannot catch invalid email addresses

    Hi,
    I have been using this very normal email sending routine but for some reason even if the email address is invalid (ex abc), the Transport.send() method does not throw any exception and continues.
    Does anyone know why this should happen??
    The code is given below
         for (int i = 0; i < p.length; i++){
    uEmail = p.getUserEmail();
    System.out.println("Sending Email to :" + uEmail);
         emailContent = emailString;
    /***************** SENDING THE EMAILS *************************/
    try {
              Properties props = System.getProperties();
    //System.out.println("Using mail server"+mailserveraddress);
              props.put("mail.smtp.host",mailserveraddress);
              Session session = Session.getDefaultInstance(props, null);
    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress("[email protected]"));
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(uEmail));
    message.setSubject("Homeland Headlines " + dateString);
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setText(emailContent);
    Multipart multipart = new MimeMultipart();
    multipart.addBodyPart(messageBodyPart);
    //System.out.println("Setting the content");
    message.setContent(multipart);
              //System.out.println("NO exception till here");
    // Send the message
    Transport.send(message);
              System.out.println("Email Sent successfully");
    catch(SendFailedException me) {
              System.out.println("Email not sent to :" + uEmail);
              System.out.println("The exception is" +me.toString());
              invalidemails.add(uEmail);
              catch(MessagingException mesex){
              System.out.println("The exception is:"+mesex.toString());
              sentemailflag="false";
              catch(Exception e){
                   System.out.println("Unexpected error is:"+ e.toString());
                   sentemailflag="false";
    The control never reaches any of the exception blocks even though p has some invalid email addresses.
    It prints:
    Sending email to: abc
    Email sent successfully
    Thanks,
    Chetan

    Hi,
    I believe I have answered this question quite a few times in this forum.
    There is no standard way to know if the e-mail id exists or not, SMTP standards does not mandate the server implementors to notify this.
    There are several things that can happen:
    a. The server implements the VRFY command -- Then you know immediately if the account is active.
    b. The server does not implement the VRFY command, but if the acount does not exist tells you when you send the RCPT command.
    c. The server does not tell you till you say QUIT.
    d. The server accepts the mail silently and sends a mail later saying that the mailbox does not exist.
    Since there is no sure-shot way of determining this no exception is thrown.
    (Also check out the RFC for a typical SMTP session if the commands confuse you.)
    cheers
    Projyal

  • Why catching Exception is bad idea??

    Hi,
    Why it is said that catching an Exception is a bad idea. Any how we get the actual cause in stackTrace of Exception object.!
    Plz help

    Catching exceptions (lowercase e) is not a bad thing. Catching Exception (uppercase E) is generally bad.
    Lowercase e exceptions refer to the entire Throwable hierarchy--everything that can be thrown and caught. Often you want to catch and handle them, or catch and wrap and rethrow them.
    Uppercase E Exception is a particular class of exception, and it's the parent class of all checked exceptions and many unchecked exceptions. When your code has catch Exception, you're saying that almost no matter what goes wrong, you want to handle it the same way. And you're also assuming that if the methods that you're calling change to throw more or fewer exceptions, your code won't need to know or care about it.
    In general you want to catch more specific subclasses of Exception, so that you can handle each one properly, and you know that your code is handling precisely the correct set of exceptions.

  • Showing message after catching Exception

    Hi,
    I'm having some troubles while trying to show a message after catching an Exception, the thing I want to do, is after they enter the values (Integer values in this case) if they didn't entered integer values shows a message that they input the wrong thing and then clear the fields.
    Here's the code:
    private void EnviarActionPerformed(java.awt.event.ActionEvent evt) throws Exception {                                      
            int dir=0, ranuras=0, mp=0, conjunto=0;
            String algoritmo=null;
            try {
                dir = Integer.parseInt(fieldDireccion.getText());       
                ranuras = Integer.parseInt(fieldRanura.getText());
                mp = Integer.parseInt(fieldMP.getText());
                conjunto = Integer.parseInt(fieldConjunto.getText());
                algoritmo = (String)(algoritmos.getSelectedItem());   
            } catch (Exception e) {
                JOptionPane.showmessageDialog(null,"Wrong values");
            }The error I have is: unreported exception java.lang.Exception; must be caught or declared to be thrown.
    Thanks in advance

    Ok well now I have another problem =S since that actionPerformed is made by netbeans itself I cant put it inside a "try".That is incorrect. You could create another method, which does all the work. Then in the original method do nothing but the try/catch and call that other method.
    But it doesn't matter because logically the code is still incorrect. Which hints by me an others have suggested.
    The method should not have a throws clause. That is the problem. If the code in the catch block can throw an exception then the solution to that is to put a try catch block around that code (inside the original catch.)

Maybe you are looking for

  • Slow USB Ports

    I've got a new 27-Inch iMac 2.66GHz Intel Core i5 with 4 GB RAM, less than a month old. I'm noticing that I'm getting slow file transfers on two (out of four) of my USB 2 ports. I've tried two different hard drives and a USB flash memory stick and th

  • HTTP XI  - Data Buffering

    Hi Everyone, I am using HTTP XI action block in Business logic transaction to send the XML document to PI system which in turn sends to ECC. I am trying to test the data buffering capability with following steps 1. Locked PI user ID in PI system that

  • Can we write function in select statement?

    i have function and it has Out parameter,so in this case can i write select statement for my function to retrieve the value?

  • Surface Pro 3 i7 and i5

    So I finally got Surface Pro 3 re-imaging just find using UEFI but they were all i5 processors, then an i7 came in and would not image unless I disabled UEFI and used legacy. We ran all updates and that didn't change anything. Any ideas?

  • Send Images using Dynamic Proxies

    Hi! I try to send java.awt.Images over the wire. My first attempt was to modify the static stub example from the tutorial ('hello'). I added a new method to the interface and the implementation with Image as its return value. It worked fine. However,