Solved

How to handle WLTC0017E: Resources rolled back error in WAS 6.1

Posted on 2009-04-06
22
5,481 Views
Last Modified: 2016-10-20
I just create a simple JSP page with some database access code.
Whenever I am trying to run the page, its giving me ERROR 500.

Does anyone know what mistake I am making or how do I get rid of this?

Thanks :-)
On the console I am seeing the following output:
WLTC0017E: Resources rolled back due to setRollbackOnly() being called.   
[4/6/09 12:33:28:245 CDT] 0000002a WebApp        E   [Servlet Error]-[/jsp/DEMO.jsp]: java.lang.NullPointerException   
    at com.ibm._jsp._DEMO._jspService(_DEMO.java:122)   
    at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)   
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)   
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)

Open in new window

0
Comment
Question by:aman0711
  • 11
  • 9
22 Comments
 
LVL 20

Expert Comment

by:Venabili
ID: 24080497
>>java.lang.NullPointerException - that is what causes the other exception.
check your code to see what you call with a null reference or post some code so experts  can see it
0
 
LVL 10

Author Comment

by:aman0711
ID: 24080544
Thanks Venabili :-)
I duoble checked it, there is no problem in the code. One of the experts here helped me out with the code.

I have attached the code



<table border="1" cellspacing="1" bgcolor="#FFFFFF" width=99%>
	<tr>
		<th><b>Application</b></th>
		<%
			Calendar cal = Calendar.getInstance();
			SimpleDateFormat sdf = new SimpleDateFormat("MMM");
			for (int i = 0; i < 12; i++) {
				java.util.Date month = cal.getTime();
		%>
		<TH><%=sdf.format(month)%></TH>
		<%
			cal.roll(Calendar.MONTH, -1);
			}
		%>
	</tr>
	<%
		Connection conn = null;
		conn = db.getConnection();
 
		String sql = "";
		PreparedStatement pstmt, subpstmt = null;
		ResultSet rs, rs1 = null;
 
		sql = "Select DISTINCT Application from APM.APM_WEB_EXSUMM_12MONTH_APPL_V";
		pstmt = conn.prepareStatement(sql);
		rs = pstmt.executeQuery(sql);
		while (rs.next()) {
	%>
	<TR>
		<%
				String subquery = "Select SLA_COMPLIANCE from( Select * from APM.APM_WEB_EXSUMM_12MONTH_APPL_V WHERE APPLICATION IN ('"
				+ rs.getString(1)
				+ "') ORDER BY YEAR DESC, DECODE(UPPER(MONTH), 'JAN', 7, 'FEB', 8, 'MAR', 9, 'APR', 10, 'MAY', 11, 'JUN', 12, 'JUL', 1, 'AUG', 2, 'SEP', 3, 'OCT', 4, 'NOV', 5, 'DEC', 6) )DESC WHERE ROWNUM<=12";
				pstmt = conn.prepareStatement(subquery);
				rs1 = subpstmt.executeQuery(subquery);
				while (rs1.next()) {
		%>
		<TD><%=rs1.getFloat(1)%></TD>
		<%
		}
		%>
	</TR>
	<%
		}
		rs.close();
		rs1.close();
		pstmt.close();
		subpstmt.close();
		conn.setAutoCommit(false);
		conn.close();
	%>
</table>

Open in new window

0
 
LVL 20

Expert Comment

by:Venabili
ID: 24080709
>>conn = db.getConnection()
Is db initialized? Does this return a valid connection?
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 10

Author Comment

by:aman0711
ID: 24080727
Hmmm.. Yup :)
0
 
LVL 20

Expert Comment

by:Venabili
ID: 24082032
If you run the same code outside the server - as a standalone class, do you see the results that you expect? (a bit reworked of course -- so that it is a normal class)
0
 
LVL 10

Author Comment

by:aman0711
ID: 24082053
I didnt try it that way.
                 It has something to do with AutoCommitt... just dont know what exactly :(
0
 
LVL 20

Expert Comment

by:Venabili
ID: 24082077
OK. Why do you have conn.setAutoCommit(false); just before you close the connection?
0
 
LVL 10

Author Comment

by:aman0711
ID: 24082130
well thats what i was trying to do, I tried conn.setAutoCommit(true) and with this statement altogether as well.. but still didnt work :(
0
 
LVL 20

Expert Comment

by:Venabili
ID: 24082304
You do not need to commit - you are doing only selects, right?
And do not pass a parameter to the executeQuery methods (both of them - you already prepared the statement so it knows what to execute).
If you do these things - is the error still the same?
0
 
LVL 10

Author Comment

by:aman0711
ID: 24082343
Thanks Venabili, let me try this real quick and get back to you with results
0
 
LVL 10

Author Comment

by:aman0711
ID: 24082371
Hi Venabili,
                    I used  rs = pstmt.executeQuery(); and rs1 = subpstmt.executeQuery(); this time, but still the same output :(
0
 
LVL 20

Accepted Solution

by:
Venabili earned 500 total points
ID: 24082405
ok.  and removed the autocommit?
Are you absolutely sure that the db connection  is valid? I still think that there is a null object somewhere there but short of debugging it, I do not see how to find out which...

Oops. Saw it
you have
pstmt = conn.prepareStatement(subquery);
rs1 = subpstmt.executeQuery();
it should be
subpstmt= conn.prepareStatement(subquery);
rs1 = subpstmt.executeQuery();

subpstmt was remaining null :)
0
 
LVL 10

Author Comment

by:aman0711
ID: 24082441
I am little confused on this now. please forgive me if I am acting real dumb :)

 I have this in my code:
 
           pstmt = conn.prepareStatement(sql);
        rs = pstmt.executeQuery();
 
   
                pstmt = conn.prepareStatement(subquery);
                rs1 = subpstmt.executeQuery();
0
 
LVL 20

Expert Comment

by:Venabili
ID: 24082475
The second one - you want to execute subpstmt but you prepare pstmt  again :) So when you try to execute subpstmt , it is null.
0
 
LVL 10

Author Comment

by:aman0711
ID: 24082504
you are GOD :-D
I am messing with my brain since morning. :-)

At last it worked... though I didnt get the output, My SQL query is wrong but ... it ran this time without null pointer exception. lol :-)


0
 
LVL 20

Expert Comment

by:Venabili
ID: 24082578
:)) These things are the hardest to catch - I usually end up checking every single object one by one for null until I get such things
0
 
LVL 20

Expert Comment

by:Venabili
ID: 24082622
Can I help with something else here because it seems like the problem is solved? (and never pass the query to a PreparedStatement -- it's already taken care of:) )
0
 
LVL 10

Author Comment

by:aman0711
ID: 24082666
yes GODDESS :-)

Thank you so much :-)
0
 
LVL 10

Author Closing Comment

by:aman0711
ID: 31567181
thank you so much..
0
 
LVL 10

Author Comment

by:aman0711
ID: 25851801
code replacement for  ID: 24080544

<table border="1" cellspacing="1" bgcolor="#FFFFFF" width=99%>
        <tr>
                <th><b>App</b></th>
                <%
                        Calendar cal = Calendar.getInstance();
                        SimpleDateFormat sdf = new SimpleDateFormat("MMM");
                        for (int i = 0; i < 12; i++) {
                                java.util.Date month = cal.getTime();
                %>
                <TH><%=sdf.format(month)%></TH>
                <%
                        cal.roll(Calendar.MONTH, -1);
                        }
                %>
        </tr>
        <%
                Connection conn = null;
                conn = db.getConnection();
 
                String sql = "";
                PreparedStatement pstmt, subpstmt = null;
                ResultSet rs, rs1 = null;
 
                sql = "Select DISTINCT App from SAMPLE_TABLE";
                pstmt = conn.prepareStatement(sql);
                rs = pstmt.executeQuery(sql);
                while (rs.next()) {
        %>
        <TR>
                <%
                                String subquery = "Select MIN from( Select * from SAMPLE_TABLE2 WHERE APP IN ('"
                                + rs.getString(1)
                                + "') ORDER BY YEAR DESC, DECODE(UPPER(MONTH), 'JAN', 7, 'FEB', 8, 'MAR', 9, 'APR', 10, 'MAY', 11, 'JUN', 12, 'JUL', 1, 'AUG', 2, 'SEP', 3, 'OCT', 4, 'NOV', 5, 'DEC', 6) )DESC WHERE ROWNUM<=12";
                                pstmt = conn.prepareStatement(subquery);
                                rs1 = subpstmt.executeQuery(subquery);
                                while (rs1.next()) {
                %>
                <TD><%=rs1.getFloat(1)%></TD>
                <%
                }
                %>
        </TR>
        <%
                }
                rs.close();
                rs1.close();
                pstmt.close();
                subpstmt.close();
                conn.setAutoCommit(false);
                conn.close();
        %>
</table>

Open in new window

0
 

Expert Comment

by:mahesh reddy
ID: 41852738
im getting the bellow error while starting my websphere portal 8.0.0.1 cf21
can an one help me to solve this isse

 [10/21/16 0:10:05:463 IST] 0000002b LocalTranCoor E   WLTC0017E: Resources rolled back due to setRollbackOnly() being called.
[10/21/16 0:10:05:465 IST] 0000002b AlarmListener E   SCHD0063E: A task with ID 401 (wcm#WCM_EJBs.jar#EJBScheduler) failed to run on Scheduler WPSTaskScheduler (wps/Scheduler) because of an exception: com.ibm.ejs.container.UnknownLocalException: nested exception is: java.lang.RuntimeException: com.ibm.wps.services.workmanager.WorkException: EJPFD0031E: An error has occurred in the AsynchBeans layer of WebSphere Application Server..
[10/21/16 0:10:05:466 IST] 0000002b DaemonCoordin W   SCHD0132W: Task 401 (wcm#WCM_EJBs.jar#EJBScheduler) for scheduler WPSTaskScheduler (wps/Scheduler) has exceeded the failure threshold limit and has been deactivated.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question