• Welcome to KonaKart Community Forum. Please login or sign up.
 

StringIndexOutOfBoundsException during sendTemplateEmailToCustomers1WithOptions

Started by impiastro, September 16, 2010, 11:26:47 am

Previous topic - Next topic

impiastro

I used many times sendTemplateEmailToCustomers1WithOptions using SOAP API from my application successfully.

I customized the bundled velocity templates and I created new ones starting from them.

Now I changed the html code of one of them and I receive a strange StringIndexOutOfBoundsException from tomcat error console.
This is the generated exception:


java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(Unknown Source)
at com.konakartadmin.bl.AdminEmailMgr.sendTemplateEmail(Unknown Source)
at com.konakartadmin.bl.AdminTemplateEmailSender.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


This is the template with error:


$subject
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>$subject</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
html {
background: #FFF;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
body {
margin: 0px;
padding: 0px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
color: #333;
background-color: #FFF;
font-size: 10pt;
}
a, a:link, a:active, a:visited {
color: #9F824A;
font-weight: bold;
text-decoration: underline;
}
a:hover {
text-decoration: none;
}

p.prezzo {
color:#666;
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 16px;
}
h1 {
margin: 0px;
padding: 0px;
font-family: Georgia, "Times New Roman", Times, serif;
color: #9F824A;
font-size: 24px;
font-weight: normal;
}
h2 {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 20px;
font-weight: normal;
color: #bc1010;
margin: 0px;
padding: 0px;
}
li {
margin: 3px 0px 3px 0px;
}
</style>
</head>
<body>
<table cellpadding="5" cellspacing="0" width="100%;" align="center">
<tbody>
<tr bgcolor="#000000">
<td style="border-bottom: 5px solid rgb(139, 22, 24);">
<table width="660px" align="center">
<tbody>
<tr>
<td style="font-family: Georgia,'Times New Roman',Times,serif; color: rgb(255, 255, 255); font-size: 24px;">&nbsp;</td>
</tr>
</tbody>
</table>
    </td>
</tr>
<tr>
<td>
<table width="660px" align="center">
<tbody>
<tr>
<td><h1>$subject</h1></td>
</tr>
<tr>
<td>
  <p>
  $message
      </p>
    </td>
</tr>

<tr>
<td style="color: rgb(153, 153, 153);">&copy;<strong>TEST footer</strong></td>
</tr>

</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>

</html>




This is instead the template with no error before this change:


$subject
<html>
<head>
<title>$subject</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<a href="http://${host}/" target="_blank">
ecommerce site
</a>
<br/>
<br/>

$message
<br/>
<br/>

## email: $cust.emailAddr <br/>
## newPassword: $newPassword <br/>
</body>
</html>




Any ideas about this problem?
Maybe the sendTemplateEmail() of the AdminEmailMgr class cannot parse the new template?

Thank you,

ROb

P.S.: I'm using KK version 4.1.0.0

ming

You're right about the parsing.

Can you use <html> instead of what you have?

The code looks for <html> to find the start.

Hopefully this will not be a problem for you?

We'll change this in future to allow your format.

impiastro