Logging Exception in errorPage of struts

Hi,
I have got the code such
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
which redirects all errors to error.jsp and now in error.jsp I want to get the exact exception message to log(Write) it in a file with log4j.
could any one help me ?
Thanks

Does anyone has an suggestion

Similar Messages

  • Log Exceptions on Insert, Erroring on PK Violation

    I have a process that inserts into a table with an append hint. When the insert is based on a select, primary key exceptions propogate to the code and error:
    *1. Create table and error table:*
    SQL>CREATE TABLE test
      2    (col1 NUMBER(10)    CONSTRAINT test_pk01 PRIMARY KEY
      3    );
    Table created.
    SQL>
    SQL>exec dbms_errlog.create_error_log(dml_table_name=>'TEST',err_log_table_name=>'TEST_ERRORS')
    PL/SQL procedure successfully completed.*2. Put a row in:*
    SQL>INSERT INTO test
      2    (col1
      3    )
      4  VALUES
      5    (1
      6    );
    1 row created.*3. Attempt to put rows in that violated the PK with and without append hint:*
    SQL>INSERT INTO test
      2    (col1
      3    )
      4  VALUES
      5    (1
      6    )
      7  LOG ERRORS INTO test_errors
      8  REJECT LIMIT UNLIMITED;
    0 rows created.
    SQL>INSERT /*+ APPEND */ INTO test
      2    (col1
      3    )
      4  VALUES
      5    (1
      6    )
      7  LOG ERRORS INTO test_errors
      8  REJECT LIMIT UNLIMITED;
    0 rows created.
    SQL>SELECT ORA_ERR_MESG$
      2        ,col1 col_1
      3  FROM test_errors;
    ORA_ERR_MESG$                                                          COL_1
    ORA-00001: unique constraint (DW2.TEST_PK01) violated                  1
    ORA-00001: unique constraint (DW2.TEST_PK01) violated                  1So far so good, the code is behaving
    *4. Attempt to Violate the PK with a select in the query (and no append hint):*
    SQL>INSERT INTO test
      2    (col1
      3    )
      4    (select 1 from dual)
      5  LOG ERRORS INTO test_errors
      6  REJECT LIMIT UNLIMITED;
    0 rows created.
    SQL>SELECT ORA_ERR_MESG$
      2        ,col1 col_1
      3  FROM test_errors;
    ORA_ERR_MESG$                                                          COL_1
    ORA-00001: unique constraint (DW2.TEST_PK01) violated                  1
    ORA-00001: unique constraint (DW2.TEST_PK01) violated                  1
    ORA-00001: unique constraint (DW2.TEST_PK01) violated                  1Still OK
    *5. Attempt to violate the PK with a select and an append hint:*
    SQL>INSERT /*+ APPEND */ INTO test
      2    (col1
      3    )
      4    (select 1 from dual)
      5  LOG ERRORS INTO test_errors
      6  REJECT LIMIT UNLIMITED;
    INSERT /*+ APPEND */ INTO test
    ERROR at line 1:
    ORA-00001: unique constraint (DW2.TEST_PK01) violated
    SQL>SELECT ORA_ERR_MESG$
      2        ,col1 col_1
      3  FROM test_errors;
    ORA_ERR_MESG$                                                          COL_1
    ORA-00001: unique constraint (DW2.TEST_PK01) violated                  1
    ORA-00001: unique constraint (DW2.TEST_PK01) violated                  1
    ORA-00001: unique constraint (DW2.TEST_PK01) violated                  1Now I get an error instead of a logged exception
    I've reproduced this on 11.2.0.1.0 & 10.2.0.4.0, both running on windows
    SQL>select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - ProductionThe Oracle Knowledge Base is timing out on me at the moment ...
    Thank you for taking the time to have a look.
    Ben

    user503699 wrote:
    bencol wrote:
    The Oracle Knowledge Base is timing out on me at the moment ...
    Thank you for taking the time to have a look.In the case, where you do a "INSERT /*+ APPEND */..VALUES", the hint is ignored as it is not valid (till 10gR2 atleast).
    That statement is executed as conventional INSERT and hence you get error logging. When you do "INSERT /*+ APPEND */...SELECT", oracle attempts to use direct path insert and reports error, ignoring the LOG ERRORS clause, as mentioned in the documentation.11g has introduced an APPEND_VALUES hint to enable direct-path to work with "INSERT INTO...VALUES" syntax.
    What do you get when you use APPEND_VALUES hint, in place of APPEND in your INSERT INTO...VALUES example?

  • How to log exception from a struts action class

    Hi guys,
    I am recoding my application to use the strut framework. There's one small thing i wonder is that how i can log an exception arrise in an action class. In my original servlet, wherever an exception arise, i use:
    catch(Exception e)
             getServletContext().log("User enter an invalid date");
             throw e;
          }However, when i move this servlet into a action class, the getServletContext method doesnt work anymore. I thought action is a child of httpServlet but since getServletContext is not available in action, then how can i log the error?
    Hope to get some help
    Message was edited by:
    lnthai2002

    Hi guys,
    I am recoding my application to use the strut
    framework. There's one small thing i wonder is that
    how i can log an exception arrise in an action class.
    In my original servlet, wherever an exception arise,
    i use:
    catch(Exception e)
    getServletContext().log("User enter an invalid
    valid date");
             throw e;
          }However, when i move this servlet into a action
    class, the getServletContext method doesnt work
    anymore. I thought action is a child of httpServlet
    but since getServletContext is not available in
    action, then how can i log the error?
    Hope to get some help
    Message was edited by:
    lnthai2002Action class is just a POJO and works a handler of your request. ActionServlet invoke your Action class based on the action you call in your URL. When you are usign the Struts why do you need your Original Servel, use the ActionServlet and if required you can extend it and create your own servlet

  • How to log Exceptions raised in CAF Application Services

    Hi All,
    When there is an Exception rasing in CAF Application Service custom method implementation what are the steps need to follow for send that exception details to log files & where those log files will be generated i.e either in server, local system, etc.
    If we use following 2 different lines please explain me where that trace is going to written:
    1) System.out.println(e);
    2) e.printStackTrace();
    Thanks in Advance,
    Uday.

    Hi Uday,
    Try this (in my case I'm using that in Background CO that implements IGPBackgroundCallableObject ):
         public static Location logger =
              Location.getLocation(<yourClass>.class);
    Catch block:
              } catch (GPInvocationException e) {
                   throw new GPTechnicalCallableObjectException(
                        logger,
                        resourceAccessor,
                        "ERROR_PARAMETERS",
                        e);
              } catch (GPEngineException e) {
                   throw new GPTechnicalCallableObjectException(
                        logger,
                        resourceAccessor,
                        e.getMessage(),
                        e);
    Reward points if it's helpful.

  • Log 4 j error in struts 1.2.8

    I am using struts1.2.8 with hibernate 3.
    I am getting below error.
    Is there any solution for this problem ?
    private DailyRollingFileAppender cAeroAppender;
         java.util.Calendar cal=java.util.Calendar.getInstance(); // getting calendar instance
                        logger = Logger.getLogger(cal.getTime()+"");
    strLogLevel=CAeroConstants.getProperty(CAeroConstants.PROPTYPE_CONFIG,CAeroConstants.CONFIGPROP_LOG_LEVEL);
                             logger.setLevel(Level.DEBUG);
                        else if ( strLogLevel.equalsIgnoreCase("DEBUG") ) {
                             logger.setLevel(Level.DEBUG);
                        else if ( strLogLevel.equalsIgnoreCase("ERROR") ) {
                             logger.setLevel(Level.ERROR);
                        cAeroAppender = new DailyRollingFileAppender(new SimpleLayout(),strLogPath+".log","'_'MM-dd-yyyy");
                        logger.addAppender(cAeroAppender);     
    06/04/18 20:50:01 log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResource
    s).
    06/04/18 20:50:01 log4j:WARN Please initialize the log4j system properly.
    Raghu

    It's not an error; it is merely a warning saying that the system is unable to find any log4j configuration. Create a log4j.properties and add it to the server classpath.

  • Logging exceptions

    How can I avoid to log only a particular kind of exception? I tryed to setting "toplink.logging.level" property to SEVERE in persistence.xml. It works but I think it may hide also other kind of exception.

    If you use Java logging with TopLink you can configure different logging levels for each logging category.
    You could also set logging to severe and then explicitly log just the exceptions you want through SessionLog.logThrowable(SEVERE, error), or potentially use an ExceptionHandler to log certain exceptions as they occur. You could also log the exceptions yourself in your application to your application log, such as using Java logging.
    -- James : http://www.eclipselink.org

  • Log exception 'iView not found: style.css'

    We keep seeing the following exception in our server (EP6 SP2)logs but have no idea what is causing it? Any ideas as to what it relates to and how to fix it?
    Cheers,
    Steve
    [code]Exception ID:02:44_02/08/05_0063
    com.sapportals.portal.prt.runtime.PortalRuntimeException: iView not found: style.css
         at com.sapportals.portal.prt.deployment.DeploymentManager.getPropertyContentProvider(DeploymentManager.java:1701)
         at com.sapportals.portal.prt.core.broker.PortalComponentContextItem.refresh(PortalComponentContextItem.java:193)
         at com.sapportals.portal.prt.core.broker.PortalComponentContextItem.getContext(PortalComponentContextItem.java:287)
         at com.sapportals.portal.prt.component.PortalComponentRequest.getComponentContext(PortalComponentRequest.java:386)
         at com.sapportals.portal.prt.connection.PortalRequest.getRootContext(PortalRequest.java:433)
         at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:536)
         at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:229)
         at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:555)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:415)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.inqmy.services.servlets_jsp.server.InvokerServlet.service(InvokerServlet.java:126)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.inqmy.services.servlets_jsp.server.RunServlet.runSerlvet(RunServlet.java:149)
         at com.inqmy.services.servlets_jsp.server.ServletsAndJspImpl.startServlet(ServletsAndJspImpl.java:833)
         at com.inqmy.services.httpserver.server.RequestAnalizer.checkFilename(RequestAnalizer.java:672)
         at com.inqmy.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:314)
         at com.inqmy.services.httpserver.server.Response.handle(Response.java:173)
         at com.inqmy.services.httpserver.server.HttpServerFrame.request(HttpServerFrame.java:1288)
         at com.inqmy.core.service.context.container.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:36)
         at com.inqmy.core.cluster.impl5.ParserRunner.run(ParserRunner.java:55)
         at com.inqmy.core.thread.impl0.ActionObject.run(ActionObject.java:46)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.inqmy.core.thread.impl0.SingleThread.run(SingleThread.java:148)
    [email protected]59 #[/code]
    Message was edited by: Steve Archer

    Rajendran,
    We're having the same error after upgrading to NW04s, did you figure out the the root cause for this error?
    Thanks,
    Hanh

  • ASA log exception

    Hi,
    How can i except log generation some ip address on ASA.
    I want to filter for generation syslog message for spesific IP address on ASA.
    Thanks.

    yes you can capture for a perticular host and ip
    you have to define access-list for that
    as instance if you want capture icmp logfor the host 192.168.2.115
    then
    first make a access-list
    access-list 101 permit  icmp host 192.168.2.115 any
    then
    you have too attach this access-list with capture commend
    capture (capture name like newcap) newcap access-list 101 interface (interface name like inside,outside,or dmz1) inside
    then the commend is
    capture newcap access-list 101 interface inside
    then if you ping your inside interface then asa will capture this log
    then you can see the log by sh capture (capture name)
    sh capture newcap
    tell us if it is help you

  • Flex preventing ColdFusion server from logging exceptions!

    Hello all,
    Whenever I invoke a CFC from Flex, if the CFC throws an
    exception, that exception is not logged in the ColdFusion server
    logs. I built an html page that invokes the same page, and when the
    exception is thrown it is indeed logged on the server.
    Why is Flex preventing ColdFusion from logging the
    exceptions!?

    I've never realized that but you can add a cflog tag to your
    CFC or debug the error taking a look at the stacktrace withing FB
    debugger.

  • Logging exception trace

    Hi,
    I am using log4j for logging in my application. How do I log the full exception trace in the problem. the only available method is - log.info(e.getMessage()) which only gives a basic error message, not the trace.
    thanks,
    samit

    Actually, if you look at the [url http://logging.apache.org/log4j/docs/api/org/apache/log4j/Category.html#info(java.lang.Object, java.lang.Throwable)]Log4j API you'll find that there are 2 methods.
    Try this:
    log.info("Some message of your choosing.", e);&#8734; brewman &#8734;

  • How to log exceptions and imp logging info in Portal Service via ILogger?

    Hi Experts,
    I m trying to use ILogger for my application.
    Information about my application:
    I have created a Portal Service and exposed it as a Web Service which is deployed as a PAR file on to the SAP J2EE Engine.
    I need to use the Logging facility of ILogger in this Portal Service.
    I have written the following code in the Init() function of the Portal Service
    public void init(IServiceContext serviceContext)
           mm_logger = serviceContext.getLogger("com.persistent.pankaj");
    I have put the logger.xml in the logger folder of PORTAL-INF
    my logger.xml is as follows:
    <Server>
    <Logger name="testLog" loggerInterface="com.sapportals.portal.prt.logger.ILogger" locationName="com.sap.portal.testLog" pattern="%d # %20t %15s %m #" isActive="true">
    <LoggerClass className="com.sapportals.portal.prt.logger.SimpleFileLogger" level="INFO">
    <param filename="logs/com.persistent.pankaj.log" append="true">
    </param>
    </LoggerClass>
    </Logger>
    </Server>
    On deploying my portal service as a web service
    I m unable to get the logs.
    I even dont know where will i get the log file, means wat is the exact location where i can check my log results
    I m a newbie for this
    Please help me out
    Help will be rewarded n appreciated
    -pankaj

    Hi Pankaj,
    In your init method try this code to create the logger:
    ILogger logger = PortalRuntime.getLogger("testLog");
    In your logger.xml the logger name was testLog and not com.persistent.pankaj so while creating logger you should use testLog in the above code.
    By default all the logs are written to defaultTrace.log files, to check them read this:
    Portal Runtime Logs
    If you want to log in a seperate logfile then you should set a seperate log destination, which is not recommended on productive systems due to performance problems.
    Also read these to know how to set seperate log destinations:
    Netweaver Portal Log Configuration & Viewing (Part 3)
    Netweaver Portal Log Configuration & Viewing (Part 1)
    Netweaver Portal Log Configuration & Viewing (Part 2)
    Regards,
    Praveen Gudapati

  • Log Exception Message in BPM Alert

    Hi all
    I have a problem I am trying to solve. I have searched through the forum to try find pointers to a solution but haven't found anything yet.
    I am trying to process an exception branch in such a way that when it throws an alert, it includes in the alert long text the message from the exception. This means that the person reading the alert will get as much information as possible about the exception that was raised. I can not see how to do this. Is their some way I can "read" the exception, store its contents in a container variable and then add that to the alert message?
    thanks
    malcolm

    You can use the below information for raising an Alert for adapters.
    Specific Error Information from the Adapter Engine:
    Container Element
    ABAP Dictionary Data Type
    Meaning
    SXMS_TO_ADAPTER_TYPE
    CHAR70
    Adapter type
    SXMS_TO_ADAPTER_ERRTXT
    CHAR70
    Error text from the Adapter Engine
    Refer the below link:
    http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm

  • Jvm argument to log exception stack trace?

    I am attempting to debug an application where the developers decided to catch the root exception and throw a generic application exception. Hence the original exception is lost. Is there any arguement that can be passed to the JVM during startup that would tell the JVM's exception handler to write the root exception to standard out?

    You should to fix the application.
    An application may produce exceptions in the normal running of the application. If the application is catching the exception, the JVM would not know which one you didn't want to catch it.
    You could try running the application in a debugger. In many debuggers you can trap on exception. As I my previous point you may need to get through a few irrelevant exceptions.
    Another option is to decompile (e.g. jad) the application main class (one class should be enough) Change it and run with the changed class. You will then see the exception.

  • What is the best practice for logging runtime error  or uncheked exceptions

    hello
    my main problem is logging the nullPointerException to a file
    suppose I have this method
    public void myMethod()
       //..... some declaration here
       User user = obj.findUser("userx"); //this may return null
       System.out.println("user name is "+user.getName()); // I may have a null pointer exception here
    }so what is the best practice to catch the exception ??
    can I log the exception without catching it ???
    thank you

    A terrible way of logging exceptions.Not that im not agreeing with you, but why? (I havent
    actually used this)Because it's always on, for one thing. It's not really configurable either, unless you go to some trouble to make it so. You'd have to provide an InputStream. How? Either at compile-time, which is undesirable, or by providing configuration, which a logging framework has already done, better. Then there's the fact that you can't log anything other than the stacktrace - not particularly helpful a lot of the time. In short, it's a buggy and incomplete solution to something that's already been solved much much better by, for example, Log4J

  • Struts exception handling - Exception handler

    Hi ,
    I need some help for struts exception handling . Global exception is working fine in my struts application . But I need to show the exception stack trace also in the screen whenever the exception occurs.I guess this can be achieved if we use a custom exception handler instead of struts default exception handler . Can anyone please provide me a sample code to deal with a custom ExceptionHandler class ?
    Thanks in advance...
    Regards,
    BG

    The struts provides org.apache.struts.action.ExceptionHandler class for creating the custom exception handlers. All the custom Exception Handlers should extend the ExceptionHandler class and override the execute() method.
    //An Example
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ExceptionHandler;
    import org.apache.struts.config.ExceptionConfig;
    public class CustomExceptionHandler extends ExceptionHandler {
    public ActionForward execute(Exception exception, ExceptionConfig config, ActionMapping mapping, ActionForm formInstance,
    HttpServletRequest request, HttpServletResponse response) throws ServletException {
    try {
    // TODO CustomeCode
    System.out.println("Exception Handler for the specific error");
    }catch (Exception e) {
    return (super.execute(exception, config, mapping, formInstance, request, response));
    Struts-config.xml File
    <exception key="error.system" type="java.lang.RuntimeException"
    handler="com.visualbuilder.handler.CustomExceptionHandler" path="/index.jsp" />
    Note:- This will transfer the control to the index.jsp after calling the exception handler. In the struts-config.xml we are adding the global exception for RuntimeException. You can add any exception like the previous example to some actions only.
    I have taken this example from following link. You may visit it.
    http://www.visualbuilder.com/jsp/struts/tutorial/pageorder/38/
    I would like if you share knowledge with me.

Maybe you are looking for

  • Mounting drives on a udev+hal+gnome-volume-manager setup

    Hi, I set up Arch Linux on a friends computer. The setup seems to work, for example gnome-cd is started when one inserts an Audio CD. However, everything that involves mounting does not work. The error message given by gnome-volume-manager is mount:

  • Net requirement in MRP

    Hi I have following scenario In production order of  material  A there is one bought out  material  B with quantity 10 KG. Quantity of material B require can be +/- 5 % in any production order Overdelivery of 5 % allowed from vendor. After MRP, PR is

  • Adding email to Final Cut Pro destination

    when I add a destination email does't appear in my possible choices for export with FCP 10. 0.9 How can I make it appear ?

  • Implementing Runnable interface  Vs  extending Thread class

    hi, i've come to know by some people says that Implementing Runnbale interface while creating a thread is better option rather than extending a Thread class. HOw and Why? Can anybody explain.?

  • Modulepool-screen

    hi, why do we use the Loop at screen. if screen-group = grp. Screen-invisible = 0 / 1. endif. endloop.