Solved

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

Posted on 2009-04-06
22
5,580 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet example issue 6 46
MySqlDump not dumping triggers 1 43
how to see all occupied ports on windows 10 laptop 15 75
Eclipse for Java EE development 2 25
Most of the developers using Tomcat find it easy to configure the datasource in Server.xml and use the JNDI name in the code to get the connection.  So the default connection pool using DBCP (or any other framework) is made available and the life go‚Ķ
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

765 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