How to handle the global exception at servlet filter?
I cannot redirect the page or add the error message to faces context after the rollback. How do I can show the error to the client?
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
UserTransaction utx = null;
try {
InitialContext ctx = new InitialContext();
utx = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
utx.begin();
EntityManager em = EntityManagerUtil.getEntityManager();
chain.doFilter(request, response);
em.flush();
utx.commit();
em.clear();
}catch(Throwable t) {
logger.error(t, t);
try {
utx.rollback();
}catch(SystemException se) {
logger.error(se, se);
} finally {
EntityManagerUtil.closeEntityManager();
}
If I send the error code, it will throw the following exception because the response is committed.
java.lang.IllegalStateException
java.lang.IllegalStateException
at org.apache.coyote.tomcat5.CoyoteResponseFacade.sendError(CoyoteResponseFacade.java:433)
at mo.gov.safp.eform.web.filter.EntityManagerFilter.doFilter(EntityManagerFilter.java:57)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
Should I solve it?
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
UserTransaction utx = null;
try {
// Define the request and the response encoding.
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
InitialContext ctx = new InitialContext();
utx = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
utx.begin();
EntityManager em = EntityManagerUtil.getEntityManager();
chain.doFilter(request, response);
em.flush();
utx.commit();
em.clear();
}catch(Throwable t) {
logger.error(t, t);
try {
utx.rollback();
}catch(SystemException se) {
logger.error(se, se);
((HttpServletResponse)response).sendError(500);
}
Similar Messages
-
How to handle the global buttons in PFR
Dear friends,
i want to handle the global buttons in Process From Request
the requirement is in standard page , we have created one custom link as global button
when we click that link we are calling to previous page..now we want handle this global link in PFR
how to go ahead?? please it is very urgent
Thanks
krish.Hi,
We can get handle to global buttons using this:
OAPageLayoutBean page = pageContext.getPageLayoutBean();
page.prepareForRendering(pageContext);
OAGlobalButtonBarBean buttons = (OAGlobalButtonBarBean)page.getGlobalButtons();
//OAF automatically assigns global buttons to their corresponding function name
OAGlobalButtonBean button = (OAGlobalButtonBarBean)buttons.findIndexedChildRecursive("<FUNCTION_NAME>");
You can catch event for your global button in PFR and write the logic there.
--Sushant -
How to handle the remote files in servlets
Hi all,
I want to handle the file remotely in a server side class file by giving the realtive path , let us say some thing like
File f = new File("http://localhost:8080/images/");
here images is a directory, my requirement is to get all the image names in the folder.you don't have to do it through the network layer...
check the servlet context doc
http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletContext.html
(specially the getRealPath an getResource methods
It helps you to know where you are on the localfilesystem, then you can retrieve the files you want -
ORA-02068: following severe error from - How to handle the overgiven Except
Hello again ^^,
hope its okay to write the follwnig question into a new Thread...
I sometimes get errors from remote dbs.
ORA-02068: following severe error from DBLINK
ORA-01089: immediate shutdown in progress - no operations are permitted
ORA-02068: following severe error from DBLINK
ORA-03113: end-of-file on communication channelThese are in one sqlerm. Is it possible to handle the second errors without string operations?
Thanks and regards
Edited by: user10283133 on 28.10.2008 08:33
Try to force the headlineThe remote db is accessible from 6 am to 6 pm. When querring longer than given time span I get the Error ORA-02068. In the sqlerm for this Error is a second Errormessage from an second different Error concatenated.
Now I will tell what I think is happening:
I think the remote db say: >>I will go sleep now<< an throws Error A (ORA-01089 (or ORA-03113, or what else)). This Error A goes to the local db. The local db get the Error A and throw a new Error (Error B = ORA-02068). This Error B is independet from Error A. And I see a String which is "Error B + Error A"
I recieve also three possible Errormessages:
ORA-02068: following severe error from DBLINK
ORA-03113: end-of-file on communication channel
ORA-02068: following severe error from DBLINK_ODS_STBY
ORA-01089: immediate shutdown in progress - no operations are permitted
ORA-02068: following severe error from DBLINK_ODS_STBY
ORA-whatelse: what elseI can handle the ORA-02068. But my questions is, can I handle the second Error (thus Error A) without string operations?
The Relase is 10g2. Please tell me which information you still need ...
Thank you very much.
regrads -
Hello,
Can anyone guide me how to access the calendar exception details from Project Server using PSI?
I need to extract calendar details of enterprise resources , like exception name, exception type, exception start date and exception end date into my SSRS report hosted in SharePoint 2013 and 2010.
I would be helpful if I can get a sample of this. I have read through many PSI documents in fact still going through ,what PSI does and doesn't , PSI methods etc. from Project Server SDK and MSDN . Moreover, I
am a beginner in .NET programming. I am confused and have lots of questions in my mind, like which PSI service should be used in my report(is it just Calendar.svc), can we pull the details as XML type data source my SSRS report ,are
there any other configuration settings apart from " setting up an event handler by installing an event handler assembly on each Project Server computer in the SharePoint farm, and then configuring the event handler
for the Project Web App instance by using the Project Server Settings page in the General Application Settings of SharePoint Central Administration" (as per prerequisites for PSI in SDK) , how can I implement authentication settings
-(when user with proper SharePoint permission
can accesses the SSRS report )
Kindly bear with me if my questions are not appropriate .
Please do guide me, and .
Thanks in Advance!!
Mridhula
Mridhula.SHi Brendan,
Project server reporting database doesn't contain the calendar info. The only supported way to use the PSI to read the calendar info from Published database.
See this
reply from Amit.
Hope this helps,
Guillaume Rouyre, MBA, MVP, P-Seller | -
How to handle the errors in transformations
Hi
I am using SOA, JDev 10.1.3.3.
How to handle the exceptions in transformations.
If any thing goes wrong in transformation then how to handle that situation.
I am not getting any kind of instances like errored out..
Please help me out
Regards
PavankumarI think your issue is that your process is going into manual recovery.
In the console click on the tab BPEL processes. There is a link on the left for manual recovery. Do you see your processes there?
What happens if you put your transformation into a scope. The in that scope you have a catch All. In this catch All routine just do a terminate. This will error your process but you should see it appear in the console.
cheers
James -
How to handle multiple save exceptions (Bulk Collect)
Hi
How to handle Multiple Save exceptions? Is it possible to rollback to first deletion(of child table) took place in the procedure.
There are 3 tables
txn_header_interface(Grand Parent)
orders(parent)
order_items (Child)
One transaction can have one or multiple orders in it.
and one orders can have one or multiple order_items in it.
We need to delete the data from child table first then its parent and then from the grand parent table.if some error occurs anywhere I need to rollback to child record deletion. Since there is flag in child table which tells us when to delete data from database.
Is it possible to give name to Save exceptions?
e.g.
FORALL i IN ABC.FIRST..ABC.LAST SAVE EXCEPTIONS A
FORALL i IN abc.FIRST..ABC.LAST SAVE EXCEPTIONS B
if some error occurs then
ROLLBACK A; OR ROLLBACK B;
Please find the procedure attached
How to handle the errors with Save exception and rollback upto child table deletion.
CREATE OR REPLACE
PROCEDURE DELETE_CONFIRMED_DATA IS
TYPE TXN_HDR_INFC_ID IS TABLE OF TXN_HEADER_INTERFACE.ID%TYPE;
TXN_HDR_INFC_ID_ARRAY TXN_HDR_INFC_ID;
ERROR_COUNT NUMBER;
BULK_ERRORS EXCEPTION;
PRAGMA exception_init(bulk_errors, -24381);
BEGIN
SELECT THI.ID BULK COLLECT
INTO TXN_HDR_INFC_ID_ARRAY
FROM TXN_HEADER_INTERFACE THI,ORDERS OS,ORDER_ITEMS OI
WHERE THI.ID = OS.TXN_HDR_INFC_ID
AND OS.ID = OI.ORDERS_ID
AND OI.POSTING_ITEM_ID = VPI.ID
OI.DW_STATUS_FLAG =4 --data is moved to Datawarehouse
MINUS
(SELECT THI.ID FROM TXN_HEADER_INTERFACE THI,ORDERS OS,ORDER_ITEMS OI
WHERE THI.ID = OS.TXN_HDR_INFC_ID
AND OS.ID = OI.ORDERS_ID
OI.DW_STATUS_FLAG !=4);
IF SQL%NOTFOUND
THEN
EXIT;
END IF;
FORALL i IN TXN_HDR_INFC_ID_ARRAY.FIRST..TXN_HDR_INFC_ID_ARRAY.LAST SAVE
EXCEPTIONS
DELETE FROM ORDER_ITEMS OI
WHERE OI.ID IN (SELECT OI.ID FROM ORDER_ITEMS OI,ORDERS
OS,TXN_HEADER_INTERFACE THI
WHERE OS.ID = OI.ORDERS_ID
AND OS.TXN_HDR_INFC_ID = THI.ID
AND THI.ID = TXN_HDR_INFC_ID_ARRAY(i));
FORALL i IN TXN_HDR_INFC_ID_ARRAY.FIRST..TXN_HDR_INFC_ID_ARRAY.LAST SAVE
EXCEPTIONS
DELETE FROM ORDERS OS
WHERE OS.ID IN (SELECT OS.ID FROM ORDERS OS,TXN_HEADER_INTERFACE THI
WHERE OS.TXN_HDR_INFC_ID = THI.ID
AND THI.ID = TXN_HDR_INFC_ID_ARRAY(i));
FORALL i IN TXN_HDR_INFC_ID_ARRAY.FIRST..TXN_HDR_INFC_ID_ARRAY.LAST SAVE
EXCEPTIONS
DELETE FROM TXN_HEADER_INTERFACE THI
WHERE THI.ID = TXN_HDR_INFC_ID_ARRAY(i);
COMMIT;
DBMS_OUTPUT.PUT_LINE(TO_CHAR(SYSDATE, 'DD-MON-YY HH:MIPM')||':
DELETE_CONFIRMED_DATA: INFO:DELETION SUCCESSFUL');
EXCEPTION
WHEN OTHERS THEN
ERROR_COUNT := SQL%BULK_EXCEPTIONS.COUNT;
DBMS_OUTPUT.PUT_LINE(TO_CHAR(SYSDATE, 'DD-MON-YY HH:MIPM')||':
DELETE_CONFIRMED_DATA: ERROR:Number of errors is ' ||ERROR_COUNT);
FOR indx IN 1..ERROR_COUNT LOOP
DBMS_OUTPUT.PUT_LINE('Error ' || indx || 'occurred during
'||'iteration'||SQL%BULK_EXCEPTIONS(indx).ERROR_INDEX);
DBMS_OUTPUT.PUT_LINE('Error is '
||SQLERRM(-SQL%BULK_EXCEPTIONS(indx).ERROR_CODE));
END LOOP;
END DELETE_CONFIRMED_DATA;
Any suggestion would be of great help.
Thanks in advance
AnuIf you have one or two places in your code that need multiple exceptions, just do it with multiple catch statements. Unless you are trying to write the most compact Programming 101 homework program, inventing tricks to remove two lines of code is not good use of your time.
If you have multiple catches all over your code it could be a code smell. You may have too much stuff happening inside one try statement. It becomes hard to know what method call throws one of those exceptions, and you end up handling an exception from some else piece of code than what you intended. E.g. you mention NumberFormatException -- only process one user input inside that try/catch so it is easy to see what error message is given if that particular input is gunk. The next step of processing goes inside its own try/catch.
In my case, the ArrayIndexOutOfBoundsException and
NumberFormatException should be handled by the same way.Why?
I don't think I have ever seen an ArrayIndexOutOfBoundsException that didn't indicate a bug in the code. Instead of an AIOOBE perhaps there should be an if statement somewhere that prevents it, or the algorithm logic should prevent it automatically. -
How to handle the error handling..its urgent
hi guys...
how to handle the Exception using jsf. for example...in java program we try to connect the server...if server not connect then the exception occur like java.net.ConnectException.. i have to handle exception using jsf and display related error page...plz give me ur valuable words..its need is very urgent..
advance thanx and with regards
DJHi,
1. create a new error bundle (myErrMsg) // copy from javax/faces/Messages.properties in jsf-impl.jar
2. declare this bundle in your faces-config
<application>
<message-bundle>bundle.MyErrMsg</message-bundle>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>de</supported-locale>
<supported-locale>fr</supported-locale>
</locale-config>
</application>
3. handle the Exception in your backing bean
ResourceBundle bdle = ResourceBundle.getBundle("bundle.MyErrMsg",this.getLocale());
context.addMessage(clientId, new FacesMessage(severity, bdle.getString(key), null));
4. add the tag messages in your jsp
<h:messages layout="table" errorClass="TextError" infoClass="Text"/> -
How to handle the bad record while using bulk collect with limit.
Hi
How to handle the Bad record as part of the insertion/updation to avoid the transaction.
Example:
I am inserting into table with LIMIT of 1000 records and i've got error at 588th record.
i want to commit the transaction with 588 inserted record in table and log the error into
error logging table then i've to continue with transaction with 560th record.
Can anyone suggest me in this case.
Regards,
yuva>
How to handle the Bad record as part of the insertion/updation to avoid the transaction.
>
Use the SAVE EXCEPTIONS clause of the FORALL if you are doing bulk inserts.
See SAVE EXCEPTIONS in the PL/SQL Language doc
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/tuning.htm
And then see Example 12-9 Bulk Operation that continues despite exceptions
>
Example 12-9 Bulk Operation that Continues Despite Exceptions
-- Temporary table for this example:
CREATE TABLE emp_temp AS SELECT * FROM employees;
DECLARE
TYPE empid_tab IS TABLE OF employees.employee_id%TYPE;
emp_sr empid_tab;
-- Exception handler for ORA-24381:
errors NUMBER;
dml_errors EXCEPTION;
PRAGMA EXCEPTION_INIT(dml_errors, -24381);
BEGIN
SELECT employee_id
BULK COLLECT INTO emp_sr FROM emp_temp
WHERE hire_date < '30-DEC-94';
-- Add '_SR' to job_id of most senior employees:
FORALL i IN emp_sr.FIRST..emp_sr.LAST SAVE EXCEPTIONS
UPDATE emp_temp SET job_id = job_id || '_SR'
WHERE emp_sr(i) = emp_temp.employee_id;
-- If errors occurred during FORALL SAVE EXCEPTIONS,
-- a single exception is raised when the statement completes.
EXCEPTION
-- Figure out what failed and why
WHEN dml_errors THEN
errors := SQL%BULK_EXCEPTIONS.COUNT;
DBMS_OUTPUT.PUT_LINE
('Number of statements that failed: ' || errors);
FOR i IN 1..errors LOOP
DBMS_OUTPUT.PUT_LINE('Error #' || i || ' occurred during '||
'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX);
DBMS_OUTPUT.PUT_LINE('Error message is ' ||
SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
END LOOP;
END;
DROP TABLE emp_temp; -
How to handle the unique primary key validation when is a multipart key !
I dont know how to handle the primary key validation when the primary key is a multipart key.
Besides would like to know how to catch the TooManyObjectsException in order to custom the default exception message.
thank u.
regards,
Orlando AcostaAre you using EJB's, Toplink, or BC4J?
Thanks,
Rob
Team JDev -
How to handle null pointer exception
dEAR ALL
how to handle null pointer exception
public void xxperscompmatchcase(OAPageContext pageContext,
OAWebBean webBean,String cid,String pid)
xxcrmleadperslastnameVOImpl vo=getxxcrmleadperslastnameVO();
xxcrmleadcompnameVOImpl vo1=getxxcrmleadcompnameVO();
vo.setWhereClauseParams(null);
vo1.setWhereClauseParams(null);
vo.setWhereClauseParam(0,pid);
vo1.setWhereClauseParam(0,cid);
vo.executeQuery();
vo1.executeQuery();
String compname="";
String plname="";
if(vo1.first().getAttribute("CompName")!=null)
compname=(String)vo1.first().getAttribute("CompName");
else
compname="";
if((String)vo.first().getAttribute("PersLastname")!=null)
plname=(String)(String)vo.first().getAttribute("PersLastname");
else
plname="";
OAFormattedTextBean p =
(OAFormattedTextBean)webBean.findChildRecursive("personmatchcase");
OAFormattedTextBean b =
(OAFormattedTextBean)webBean.findChildRecursive("matchcase");
b.setValue(pageContext,
"The Lead is matched to company " + compname.toUpperCase());
p.setValue(pageContext,
"The Lead is matched to person " + plname.toUpperCase());
it is going to null pointer exception
how to handle this exceptionHi,
try
//Write your logic here, which can generate any exception
catch(Exception e)
//Write your exception specific code here
Regards,
Reetesh Sharma -
How to handle the OK button of the parameters prompt of a crystal report
Hi,
how to handle the OK button of the parameters prompt of a crystal report in vba.NET?
I want to use the parameter prompt from the crystal report itself and I want to know when the report is ready. I need to export programatically by sending email to a list of employees after the parameters has been set. The emails I send depends on the results of the report.
Im using a CrystalReportViewer control in VS2010 and Crystal Report for VS2010 v13.0.1.220.Right. But the parameter screen is driven by the viewer. Unless you create your own parameter screen and pass the parameters to the report via code.
Another thing I am not sure about:
"Then by code I want to read all the employees id from the report and send email to them with specified pages of the report. (1 page per employee)"
How do you plan on reading the employee ID from the report? I am not aware of any API that will read a value in a report so that you can then decide what page to send to whom.
I think you're approaching this kinda backwards. A question to ask is; can you do what you are trying to do in code in the CR designer? If not, using APIs will not work either. I suspect your approach should be a report that uses an employee filter. Run the report for employee x, get the report populated with the data for that employee and email it. Repeat for employee x1, employee x2, etc.
- Ludek -
How to access the global data in user exit.
Hi All,
How to access the global data in user exit.
the question is that when we were writing a code in the FM. i need to read data from the standard program like newly created documen and this document number need to be accessed in my program.
this document number is not imported to the FM i needed to access for frther proceed.
Thanks in advance.Hi,
See the below PDF file by Jeff Goldstein. There you can find all the details about accessing data outside of the exit.
[SAP User Exits and the People Who Love Them|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/208811b0-00b2-2910-c5ac-dd2c7c50c8e8]
This will help you to solve your problem.
Regards
Karthik D
Edited by: Karthik D on Dec 2, 2008 4:18 PM -
How to handle the control records in case of file to idoc scenario.
Hi All,
can you please clarify me how to handle the control records in case of file to idoc scenario.Hi,
In File to Idoc scenario even though you selected apply control record values from payload and you are not getting those correct values which you have provided in the mapping.
Also check the checkboxes Take sender from payload and Take receiver from payload along with the Apply control record values from payload checkbox
Regards
Seshagiri -
How to handle the different pricing conditions changes in BI.
Dear Friends
can any one send me Regarding
How to handle the different pricing conditions changes in BI.
Thanks & Regards
RamanaHi,
Take a look at the 0sd_o06 ODS and 2lis_13_vdkon datasource for sales billing conditions.
http://help.sap.com/saphelp_nw70/helpdata/EN/36/8188408bc0bb4de10000000a1550b0/frameset.htm
http://help.sap.com/saphelp_nw70/helpdata/EN/7f/0f8c4037fba62be10000000a1550b0/frameset.htm
Regards.
Maybe you are looking for
-
Transfering Data from One table to another
Hi all, Can we transfer data from Cluster Table to ZTABLE (Transparent Table)? if Yes, How can we do that? Thanks Devinder
-
Need (procedure or function or sql query )for Email filter
Hi All, in (procedure or function or sql query ) ,if i pass the a input parameter like (anbu@y or anbu@ or anbu@yahjjj ) ,i need to get output like [email protected] . please give me code for this ...
-
AD Replication Failure Between 2 Server 2008 R2 - LDAP bind failed with error 8341,
Hi everybody, I've having 2 AD Server : GDS and DC1. They can't replicate with each other for a long time ( more than 60 days ) They placed at 2 diffirent subnet, no FW rule. I can ping, resolve the DNS by nslookup both Servers When i use cmd command
-
PCP in non-shared appl_top application tier
Hi Guru's, I wanted to know few information about non-shared appl_top in application tier. Can we implement PCP(Parallel Concurrent Processin) in non-shared appl_top application tier.? What should be design of oracle application node in case of non-s
-
Hello sap gurus, I have a problem with cancel credit memo in transaction VF11. In the log I can see an error message " Delivery does not exist" Can I delete this credit memo in other transaction or what I have to do for cancel this credit memo? Thank