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

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

LVL 10
aman0711Asked:
Who is Participating?
 
VenabiliConnect With a Mentor Commented:
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
 
VenabiliCommented:
>>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
 
aman0711Author Commented:
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
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
VenabiliCommented:
>>conn = db.getConnection()
Is db initialized? Does this return a valid connection?
0
 
aman0711Author Commented:
Hmmm.. Yup :)
0
 
VenabiliCommented:
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
 
aman0711Author Commented:
I didnt try it that way.
                 It has something to do with AutoCommitt... just dont know what exactly :(
0
 
VenabiliCommented:
OK. Why do you have conn.setAutoCommit(false); just before you close the connection?
0
 
aman0711Author Commented:
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
 
VenabiliCommented:
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
 
aman0711Author Commented:
Thanks Venabili, let me try this real quick and get back to you with results
0
 
aman0711Author Commented:
Hi Venabili,
                    I used  rs = pstmt.executeQuery(); and rs1 = subpstmt.executeQuery(); this time, but still the same output :(
0
 
aman0711Author Commented:
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
 
VenabiliCommented:
The second one - you want to execute subpstmt but you prepare pstmt  again :) So when you try to execute subpstmt , it is null.
0
 
aman0711Author Commented:
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
 
VenabiliCommented:
:)) 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
 
VenabiliCommented:
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
 
aman0711Author Commented:
yes GODDESS :-)

Thank you so much :-)
0
 
aman0711Author Commented:
thank you so much..
0
 
aman0711Author Commented:
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
 
mahesh reddyCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.