String index out of range - Postgresql 7.3.4, Resin & JDBC

Поиск
Список
Период
Сортировка
Искать

String index out of range - Postgresql 7.3.4, Resin & JDBC

От:
"Antony Brooke-Wood" <antony@l-o-u-d.com>
Дата:
HI,
 
We are getting the following error through a JSP.
 
We received the same error for both 7.3.1 through 7.3.4 and several JDBC
driver changes (currently running the latest).
 
The strange thing is that this actual page was working fine, then, after
we modified a different separate page, this page started producing the
following error.
 
Is anyone else receiving Out Of Bound errors?
 
Can anyone suggest how I could get a more descriptive error?
 
I have included full source code for the page (sorry it is so long), as
well as the error that is shown in Resin's Standard Error log whenever
the page is loaded.
 
Thanks for any help.
 
Regards,
 
Antony 
 
___________________
 
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(String.java:444)
        at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.toBoolean(AbstractJdbc1Resul
tSet.java:684)
        at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getBoolean(AbstractJdbc1Resu
ltSet.java:102)
        at
_ejb.com.nortelleads.LeadBean__QPersist._caucho_load(LeadBean__QPersist.
java:2903)
        at
_ejb.com.nortelleads.ManagerBean__QPersist.ejbSelectAllWithManager(Manag
erBean__QPersist.java:2713)
        at
com.nortelleads.ManagerBean.getAllWithManager(ManagerBean.java:169)
        at
_ejb.com.nortelleads.ManagerBean__EJB$Local.getAllWithManager(ManagerBea
n__EJB.java:921)
        at _lead_0listing__jsp._jspService(_lead_0listing__jsp.java:373)
        at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
        at com.caucho.jsp.Page.subservice(Page.java:506)
        at
com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182
)
        at
com.caucho.server.http.Invocation.service(Invocation.java:315)
        at
com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
        at
com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
        at
com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163
)
        at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
        at java.lang.Thread.run(Thread.java:534)
___________________
 
<%@ page import="com.nortelleads.*, javax.naming.*, java.util.*,
java.net.*, java.text.DateFormat" session="true" errorPage="error.jsp"%>

<%@ taglib uri="ejbtags" prefix="ejb" %>

<%!

private CountryHome countryHome = null;

private LeadHome leadHome = null;

private LanguageHome languageHome = null;

private CampaignHome campaignHome = null;

public void jspInit()

{

try

{

Context ejb = (Context) new
InitialContext().lookup("java:comp/env/nortel");

countryHome = (CountryHome)ejb.lookup("Country");

leadHome = (LeadHome)ejb.lookup("Lead");

languageHome = (LanguageHome)ejb.lookup("Language");

campaignHome = (CampaignHome)ejb.lookup("Campaign");

}

catch (NamingException ignore)

{

}

}

private String getDisplayForActions(Integer action)

{

if (action == null)

return null;

switch (action.intValue())

{

case 1: return "";

case 0: return "";

case -1: return "";

case -2: return "";

default: return null;

}

} 

%>

<%

response.setHeader("Pragma", "no-cache");

response.setHeader("Cache-Control", "no-cache");

response.setDateHeader("Expires", 0);

Manager currentUser = (Manager)session.getAttribute("currentUser");

if (currentUser == null)

{

// If moving to archive change login.jsp to ../login.jsp

response.sendRedirect("login.jsp");

return;

}

// If moving to archive change false to true

CombinedPrivilege cp = currentUser.getPrivilege(false);

Hashtable pageInfo = (Hashtable)session.getAttribute("pageInfo");

Language language = (Language)pageInfo.get("language");

Campaign campaign = (Campaign)pageInfo.get("campaign");

Country country = (Country)pageInfo.get("country");

Vector managerFilter = (Vector)pageInfo.get("managerFilter");

String managerFocus = (String)pageInfo.get("managerFocus");

String managerFilterStatus =
(String)pageInfo.get("managerFilterStatus");

Collection countryManagers = null;

boolean noManagers = true;

if (country == null)

countryManagers = currentUser.getCountryManagerLists();

else

countryManagers = currentUser.getCountryManagerLists(country);

%>





Lead Listing













<%@ include file="menuBar.jsp" %>



  LEAD LISTING  
  Reassig n checked     Delete  ;checked     Archive&nb sp;checked     Manager Filter< /a> <%=managerFilterStatus%>  < /TD>

<% Collection leads = null; String output = ""; StringBuffer outputStringBuffer = new StringBuffer(); // If moving to archive change false to true long numberOfLeads = (campaign == null) ? manager.getCountAllWithManager(false).longValue() : manager.getCountAllWithManagerInCampaign(campaign, false).longValue(); if (managerFilterStatus.equals("On")) { if (managerFilter.contains(manager.getId())) noManagers = false; else continue; } if (numberOfLeads > 0) { if (cp.getViewLeadsPerPage()) { int current = 1; int fromIndex = 0; long numberOfLinks = (long)Math.ceil((double)numberOfLeads / 10.0d); if (numberOfLinks > 1) { String sessionKey = manager.getCountry().getName() + manager.getFirstName() + manager.getLastName(); sessionKey = sessionKey.replace(' ', '_'); String currPage = request.getParameter(sessionKey); Hashtable sessionObj = (Hashtable)pageInfo.get(sessionKey); if (sessionObj == null) { sessionObj = new Hashtable(); pageInfo.put(sessionKey, sessionObj); } if (currPage == null) { if (sessionObj.get("currpage") == null) { sessionObj.put("currpage", new Integer(1)); pageInfo.put(sessionKey, sessionObj); } } else { sessionObj.put("currpage", new Integer(currPage)); pageInfo.put(sessionKey, sessionObj); } current = ((Integer)sessionObj.get("currpage")).intValue(); for (int i = 0; i < numberOfLinks; i++) { if (current == (i+1)) { fromIndex = i * 10; outputStringBuffer.append(""); outputStringBuffer.append(i+1); outputStringBuffer.append(" "); } else { outputStringBuffer.append(""); outputStringBuffer.append(i+1); outputStringBuffer.append(" "); } } // If moving to archive change false to true leads = (campaign == null) ? manager.getAllWithManagerWithIndex(fromIndex, false) : manager.getAllWithManagerInCampaignWithIndex(campaign, fromIndex, false); output = outputStringBuffer.toString(); } else // If moving to archive change false to true leads = (campaign == null) ? manager.getAllWithManager(false) : manager.getAllWithManagerInCampaign(campaign, false); } else // If moving to archive change false to true leads = (campaign == null) ? manager.getAllWithManager(false) : manager.getAllWithManagerInCampaign(campaign, false); } else continue; %>
  <%=manager.getFirstName()%> <%=manager.getLastName( )%>, <%=manager.getLob()%>, <%=manager.getState()%>, <%=c ountryManager.getName()%>     Send reminder (last sent <%=((manager.getLastReminder() != null) ? DateFormat.getDateTimeInstance(DateFormat.MEDIUM , DateFormat.MEDIUM).format(manager.getLastReminder()): "N/A")%>)     <%=output%>  
<% String dealSize = ""; if (lead.getDealSize().trim().length() > 0) { dealSize = lead.getDealSize().trim(); if (!dealSize.startsWith("?")) dealSize = "$" + dealSize; } %>
Client Actions Results
Called Lead Sent Info Closed Lead In Progress Made Sale Deal Size $US
<%=lead.getPriority().getName()%> <%=lead.getCampaign() == null ? "No Campaign" : lead.getCampaign().getName()%> <%=lead.getCompanyName()%>< /B> <%=lead.getDisplayDate()%> <%=getDisplayForActions(lead.getCalled())%> <%=getDisplayForActions(lead.getBrochureSent())%> <%=(lead.getResult().intValue() == 1) ? "" : " "%> <%=(lead.getResult().intValue() == 2) ? "" : " "%> <%=(lead.getResult().intValue() == 3) ? "" : " "%> <%=dealSize%>

<% if (managerFilterStatus.equals("On") && noManagers) { %>
  All managers have been blocked by the filter  
<% } %> <%@ include file="footer.html" %>

Re: String index out of range - Postgresql 7.3.4, Resin & JDBC

От:
Richard Huxton <dev@archonet.com>
Дата:
On Monday 24 November 2003 12:22, Antony Brooke-Wood wrote:
> HI,
>
> We are getting the following error through a JSP.

Since I don't see any expert answers, I'll offer my inexpert one.

> java.lang.StringIndexOutOfBoundsException: String index out of range: 0
>         at java.lang.String.charAt(String.java:444)
>         at
> org.postgresql.jdbc1.AbstractJdbc1ResultSet.toBoolean(AbstractJdbc1Resul
> tSet.java:684)
>         at
> org.postgresql.jdbc1.AbstractJdbc1ResultSet.getBoolean(AbstractJdbc1Resu
> ltSet.java:102)

Since it's complaining about a string index = 0, that suggests to me it's 
trying to check charAt(0) when the string is empty (converting "T" or "F" to 
a java true/false?). Possibly the toBoolean() call is having problems with a 
boolean field that is null in PG.

I'd have a look at the source for the jdbc driver near the line mentioned and 
see if you can see anything suspicious. Can't help you there since my java 
skills don't extend much past "hello world".

-- 
  Richard Huxton
  Archonet Ltd

Re: String index out of range - Postgresql 7.3.4, Resin &

От:
Kris Jurka <books@ejurka.com>
Дата:
On Mon, 24 Nov 2003, Antony Brooke-Wood wrote:

> HI,
>
> We are getting the following error through a JSP.
>
> We received the same error for both 7.3.1 through 7.3.4 and several JDBC
> driver changes (currently running the latest).
>
> java.lang.StringIndexOutOfBoundsException: String index out of range: 0
>         at java.lang.String.charAt(String.java:444)
>         at
> org.postgresql.jdbc1.AbstractJdbc1ResultSet.toBoolean(AbstractJdbc1Resul
> tSet.java:684)
>         at
> org.postgresql.jdbc1.AbstractJdbc1ResultSet.getBoolean(AbstractJdbc1Resu
> ltSet.java:102)
>         at

This problem was fixed nearly three months ago in a patch from Kim Ho, but
unfortunately the builds on jdbc.postgresql.org have not been updated in
some time.  This fix is in the 7.4 and HEAD cvs branches, but a source
build is the only way to get it at this point.

Kris Jurka
FAQ