Solved

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

Posted on 2009-04-06
22
5,230 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Configure Web Service (server application) I. Configure security for Web Services methods First, we need to protect Session bean which implements the service: 1. Open EJB deployment descriptor (ejb-jar.xml) in the EJB project that contains you…
This article is about some of the basic and important steps to be used to improve the performance in web-sphere commerce application development. 1) Always leverage the Dyna-caching facility provided by the product 2) Remove the unwanted code …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now