You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Philip Brown <ph...@primeradesigns.com> on 2007/05/01 17:24:21 UTC

mailer-taglib v1.1 error when changing database

Hi, 

I have been setting up a site and have tested mailer-taglib v1.1 on a
dummy-database (mysql) with about 10 users. All ok!

Now I have changed the database over to the real mailing list. 

There has been no other changes to code than the name of the database
(and of course contents of database).

Now, mailer is not very happy. 

I get the error which follows.

I would greatly appreciate if a taglib-expert could help me troubleshoot
this problem.

Kind regards,

Phil

;-------------------------------------------------------------------
;- error -----------------------------------------------------------
;-------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented
it from fulfilling this request.

exception

org.apache.jasper.JasperException: String index out of range: -1

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	java.lang.String.substring(String.java:1768)
	org.apache.taglibs.mailer.SendTag.doStartTag(SendTag.java:265)

org.apache.jsp.admin.newsletter.viewnewsletter_jsp._jspx_meth_mt_send_0(org.apache.jsp.admin.newsletter.viewnewsletter_jsp:558)

org.apache.jsp.admin.newsletter.viewnewsletter_jsp._jspx_meth_mt_mail_0(org.apache.jsp.admin.newsletter.viewnewsletter_jsp:397)

org.apache.jsp.admin.newsletter.viewnewsletter_jsp._jspx_meth_c_if_0(org.apache.jsp.admin.newsletter.viewnewsletter_jsp:341)

org.apache.jsp.admin.newsletter.viewnewsletter_jsp._jspService(org.apache.jsp.admin.newsletter.viewnewsletter_jsp:119)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache
Tomcat/5.5.9 logs.







---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: mailer-taglib v1.1 error when changing database

Posted by Rashmi Rubdi <ra...@gmail.com>.
Hi Navas,

On 5/2/07, José Navas <jn...@gmail.com> wrote:
> Philip
>
> It seems that there is no validation on ae.getPos( ), may be it's beyond
> ref.length( )

SendTag.java is in the Mailer JAR file, so if the problem is indeed in
SendTag.java and we could fix it here, I think it would be equivalent
to submitting a patch.


> When you change the database, the data changes, so the problem occurs.

I agree too.

> Just a hunch.
>
> Regards,
> Navas
>

-Regards
Rashmi

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: mailer-taglib v1.1 error when changing database

Posted by José Navas <jn...@gmail.com>.
Philip

It seems that there is no validation on ae.getPos( ), may be it's beyond
ref.length( )

When you change the database, the data changes, so the problem occurs.

Just a hunch.

Regards,
Navas


On 5/2/07, phil@primeradesigns.com <ph...@primeradesigns.com> wrote:
>
> > Hi Philip,
> >
> > I haven't worked with the mailer-taglib, but I'm familiar with other
> > taglibs and some basic concepts of taglibs and also the specific error
> > you are getting, I'm not sure if I can help but I'll try.
> >
> > It would be useful for us to see relevant snippets of code that causes
> > this error, in order to diagnose the problem.
> >
> > Please post the section between
> >       <mt:send>
> >
> >       </mt:send>
> >
> > and also post any other code that you think is relevant.
> >
> > According to the documentation
> >
> http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringIndexOutOfBoundsException.html
> > this error java.lang.StringIndexOutOfBoundsException: String index out
> > of range: -1 is caused when "..... indicate that an index is either
> > negative or greater than the size of the string."
> >
> > And the above error is occurring when the substring method is invoked
> > on something in
> > org.apache.taglibs.mailer.SendTag.doStartTag(SendTag.java:265)
> >
> > Looking at line 265 of SendTag.java would give additional clues.
> >
> > -Regards
> > Rashmi
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> >
> >
> Hi Rashmi,
>
> Thanks for your interest:
>
> as follows is info as requested. It is odd because it is exactly same code
> as when I use dummy database, which works. I have verified correct mysql
> parameters however will look into what the database is actually pulling up
> and see if there are problems there.
> thanks
>
>
> -------------------------------------------------------------
> block of code around 265:sendtag.java
> -------------------------------------------------------------
>                 // check for more than one address
>                 if (ref.indexOf(',') != -1) {
>                     // position of the start of the error inducing address
>                     int pos = ref.substring(0, ae.getPos()).indexOf(',') +
> 1;
>                     // extract the error inducing address
>                     ref = ref.substring(pos, ref.indexOf(','));
>                 }
>
>
> -------------------------------------------------------------
> mt code:
> -------------------------------------------------------------
> <mt:mail server="mail.strangecargo.org.uk"
> to="newsletter@strangecargo.org.uk" authenticate="true"
> user="mail.agent@strangecargo.org.uk" password="xxxxxxxx" subject="Strange
> Cargo Newsletter" >
>
> <c:forEach var="subs" items="${subscribers.rows}" varStatus="status">
> <mt:addrecipient type ="bcc">${subs.subscriberemail}</mt:addrecipient>
> </c:forEach>
>
> <mt:from>info@strangecargo.org.uk</mt:from>
> <mt:message type="html">
> ${testhere}</mt:message>
> <mt:send/>
> </mt:mail>
> -------------------------------------------------------------
> mt info:
> -------------------------------------------------------------
> to: is populated
> bcc: is populated with correct mysql parameters
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>

Re: mailer-taglib v1.1 error when changing database

Posted by Vikram Reddy <vi...@gmail.com>.
hello guys,
Did any one use I18N Tag Library from Apache,  I have a question on that.

I have some of the labels hardcoded in the java bean which are displayed on
the UI, not sure how I can convert them using the Tag, Can any one throw
some light on this please.. I would really appreciate that.

right now, in my jsp page, I am simply using this tag : <i18n:message key="
label.name" />  for converting.

- V



On 5/3/07, Rashmi Rubdi <ra...@gmail.com> wrote:
>
> On 5/3/07, Rashmi Rubdi <ra...@gmail.com> wrote:
>
> > The actual data that is being passed to SendTag.java would give clues
> here.
>
> But please do not post the actual data , this is just for your
> information.
>
> I personally avoid posting my e-mail addresses or other e-mail
> addresses on forums and mailing lists to avoid my e-mails being
> harvested by spam bots roaming the Internet :-)
>
>
> > -Regards
> > Rashmi
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>

Re: mailer-taglib v1.1 error when changing database

Posted by Rashmi Rubdi <ra...@gmail.com>.
On 5/3/07, Rashmi Rubdi <ra...@gmail.com> wrote:

> The actual data that is being passed to SendTag.java would give clues here.

But please do not post the actual data , this is just for your information.

I personally avoid posting my e-mail addresses or other e-mail
addresses on forums and mailing lists to avoid my e-mails being
harvested by spam bots roaming the Internet :-)


> -Regards
> Rashmi
>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: mailer-taglib v1.1 error when changing database

Posted by Rashmi Rubdi <ra...@gmail.com>.
Hi Philip,

On 5/2/07, phil@primeradesigns.com <ph...@primeradesigns.com> wrote:
> -------------------------------------------------------------
> block of code around 265:sendtag.java
> -------------------------------------------------------------
>                 // check for more than one address
>                 if (ref.indexOf(',') != -1) {
>                     // position of the start of the error inducing address
>                     int pos = ref.substring(0, ae.getPos()).indexOf(',') + 1;
>                     // extract the error inducing address
>                     ref = ref.substring(pos, ref.indexOf(','));
>                 }

As Navas mentioned, the error is occurring, because the input data
changed and something in the input data is triggering the error. But,
we could patch SendTag.java in case it needs to be fixed.

In the above lines of code, ref is a String variable that contains
comma separated values.

I don't know what the variable ae holds, if ae.getPos() returns a
value that is either less than 0 or greater than ref.length() - 1 then
you'd get the java.lang.StringIndexOutOfBoundsException

Also if pos is greater than or equal to ref.length() , or less than 0
or if ref.indexOf(',') is 0 and pos is greater than 0 , you get
java.lang.StringIndexOutOfBoundsException

I would temporarily put System.out.println statements and see what's in the
ref, pos and ae variables --- but that might not be a good idea in
this case if there are thousands of e-mail addresses.

Another way to debug the above would be with a debugging tool (most
IDEs have them), set a breakpoint and watch the values of  ref, ae and
pos variables.


>
>
> -------------------------------------------------------------
> mt code:
> -------------------------------------------------------------
> <mt:mail server="mail.strangecargo.org.uk"
> to="newsletter@strangecargo.org.uk" authenticate="true"
> user="mail.agent@strangecargo.org.uk" password="xxxxxxxx" subject="Strange
> Cargo Newsletter" >
>
> <c:forEach var="subs" items="${subscribers.rows}" varStatus="status">
> <mt:addrecipient type ="bcc">${subs.subscriberemail}</mt:addrecipient>
> </c:forEach>
>
> <mt:from>info@strangecargo.org.uk</mt:from>
> <mt:message type="html">
> ${testhere}</mt:message>
> <mt:send/>
> </mt:mail>

The actual data that is being passed to SendTag.java would give clues here.

-Regards
Rashmi

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: mailer-taglib v1.1 error when changing database

Posted by ph...@primeradesigns.com.
> Hi Philip,
>
> I haven't worked with the mailer-taglib, but I'm familiar with other
> taglibs and some basic concepts of taglibs and also the specific error
> you are getting, I'm not sure if I can help but I'll try.
>
> It would be useful for us to see relevant snippets of code that causes
> this error, in order to diagnose the problem.
>
> Please post the section between
> 	<mt:send>
>
> 	</mt:send>
>
> and also post any other code that you think is relevant.
>
> According to the documentation
> http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringIndexOutOfBoundsException.html
> this error java.lang.StringIndexOutOfBoundsException: String index out
> of range: -1 is caused when "..... indicate that an index is either
> negative or greater than the size of the string."
>
> And the above error is occurring when the substring method is invoked
> on something in
> org.apache.taglibs.mailer.SendTag.doStartTag(SendTag.java:265)
>
> Looking at line 265 of SendTag.java would give additional clues.
>
> -Regards
> Rashmi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
Hi Rashmi,

Thanks for your interest:

as follows is info as requested. It is odd because it is exactly same code
as when I use dummy database, which works. I have verified correct mysql
parameters however will look into what the database is actually pulling up
and see if there are problems there.
thanks


-------------------------------------------------------------
block of code around 265:sendtag.java
-------------------------------------------------------------
		// check for more than one address
		if (ref.indexOf(',') != -1) {
		    // position of the start of the error inducing address
		    int pos = ref.substring(0, ae.getPos()).indexOf(',') + 1;
		    // extract the error inducing address
		    ref = ref.substring(pos, ref.indexOf(','));
		}


-------------------------------------------------------------
mt code:
-------------------------------------------------------------
<mt:mail server="mail.strangecargo.org.uk"
to="newsletter@strangecargo.org.uk" authenticate="true"
user="mail.agent@strangecargo.org.uk" password="xxxxxxxx" subject="Strange
Cargo Newsletter" >

<c:forEach var="subs" items="${subscribers.rows}" varStatus="status">
<mt:addrecipient type ="bcc">${subs.subscriberemail}</mt:addrecipient>
</c:forEach>

<mt:from>info@strangecargo.org.uk</mt:from>
<mt:message type="html">
${testhere}</mt:message>
<mt:send/>
</mt:mail>
-------------------------------------------------------------
mt info:
-------------------------------------------------------------
to: is populated
bcc: is populated with correct mysql parameters

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: mailer-taglib v1.1 error when changing database

Posted by Rashmi Rubdi <ra...@gmail.com>.
Hi Philip,

I haven't worked with the mailer-taglib, but I'm familiar with other
taglibs and some basic concepts of taglibs and also the specific error
you are getting, I'm not sure if I can help but I'll try.

It would be useful for us to see relevant snippets of code that causes
this error, in order to diagnose the problem.

Please post the section between
	<mt:send>

	</mt:send>

and also post any other code that you think is relevant.

According to the documentation
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringIndexOutOfBoundsException.html
this error java.lang.StringIndexOutOfBoundsException: String index out
of range: -1 is caused when "..... indicate that an index is either
negative or greater than the size of the string."

And the above error is occurring when the substring method is invoked
on something in
org.apache.taglibs.mailer.SendTag.doStartTag(SendTag.java:265)

Looking at line 265 of SendTag.java would give additional clues.

-Regards
Rashmi

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org