Skip to main content
December 14, 2011
Answered

java.lang.IllegalArgumentException: MONTH Error

  • December 14, 2011
  • 1 reply
  • 8176 views

I am maintaining an very old website built with ColdFusion 7 in my org, but I am very new to ColdFusion. We have a newsbriefs module which worked very well before last week. However, from last week, it started throwing me an error when I try to search the articles (Please see below for the error messages). Can anybody tell me what's wrong? Is it something wrong with the java environment on the server or something wrong with the code? How should I fix this problem? Everything else works fine on this site except for the searching articles by date or keywords. Any advices or suggestions would be greatly appreciated!!!

Resources:   
Browser 

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ;

InfoPath.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)

Remote Address  192.198.46.55
Referrer  http://siteroot/sitename/newsbriefs/CF/viewbydate.cfm
Date/Time  14-Dec-11 09:54 AM
Stack Trace (click to expand)
at cfviewbydate_action2ecfm1313219662.runPage(E:\InetPub\wwwroot\sitename\newsbriefs\CF\viewbydate_action.cfm:49)

java.lang.IllegalArgumentException: MONTH 
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2482) 
at java.util.Calendar.updateTime(Calendar.java:2463) 
at java.util.Calendar.getTimeInMillis(Calendar.java:1082) 
at java.util.Calendar.getTime(Calendar.java:1055) 
at coldfusion.runtime.CFPage.CreateDate(CFPage.java:937) 
at cfviewbydate_action2ecfm1313219662.runPage(E:\InetPub\wwwroot\sitename\newsbriefs\CF\viewbydate_action.cfm:49) 
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:192) 
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:366) 
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) 
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:279) 
at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) 
at coldfusion.filter.PathFilter.invoke(PathFilter.java:86) 
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) 
at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:74) 
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) 
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) 
at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) 
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) 
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) 
at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:126) 
at coldfusion.CfmServlet.service(CfmServlet.java:175) 
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) 
at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) 
at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) 
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) 
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) 
at jrun.servlet.FilterChain.service(FilterChain.java:101) 
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) 
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) 
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:284) 
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) 
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) 
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) 
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
  at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) 
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66) 
This topic has been closed for replies.
Correct answer -__cfSearching__-

Sorry for the long post and reposting ( did not figure out how to edit the previous post).

Here is the code having the issue:

47 : </cfquery>

48 : <cfloop query="x">

49 : <cfset storydate = '#dateformat(createdate(x.news_year,x.news_month,x.news_day), 'd mmmm yyyy')#'>

50 : <cfif #form.criteria# eq 'story'>

51 : <cfif #storydate# gte #fromdate# and #storydate# lte #todate#>

And here is the code at the beginning of this page:

<!--- CREATE DATES FOR THE FROM AND TO DATES ON SUBMIT PAGE --->

<cfif isdefined('form.fromyear')>

<cfset fromdate = #createdatetime(form.fromyear,form.frommonth,form.fromday,0,0,0)#>

<cfset todate = #createdatetime(form.toyear,form.tomonth,form.today,23,59,59)#>

</cfif>

Would you please advise me where to fix the problem? Thank you!


createdate(x.news_year,x.news_month,x.news_day)

Like I mentioned, it sounds like your input contains an invalid month (ie outside the valid range of 1-12).  Dump your query and check the news_month values. It sounds like one of them is invalid. and that is why you are getting the error.

<cfdump var="#x#">

Would you please advise me where to fix the problem? Thank you!

If that is the problem, you need to fix the invalid data in your database table first. Then add some form validation to prevent those invalid values from occurring again.

Message was edited by: -==cfSearching==-

1 reply

Inspiring
December 14, 2011

It's pretty much impossible to say much that's sensible about this without you posting the code that the error msg is identifying as being a problem.

--

Adam

December 14, 2011

Thanks very much for you quick response! Here are some codes related to this action:

Page viewbydate.cfm (no problem on this page, but on the following page):

<cfoutput>
<cfinclude template="menu.cfm">
<cfif isdefined('news_title')>
<cfupdate datasource="newsbriefs" tablename="news">
The article titled #news_title# has been updated in the database.<br />
</cfif>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>View By Date</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form" method="post" action="viewbydate_action.cfm">
<cfif isdefined('makeissue') and #makeissue# eq true>
<cfquery datasource="newsbriefs" name="ii">
SELECT TOP 1 ISSUE.ISSUE_ID, finalize
FROM ISSUE
ORDER BY ISSUE.ISSUE_ID DESC;
</cfquery>
<cfif #ii.finalize# eq false>
<cfset form.issue_id = #ii.issue_id#>
<cfelse>
<cfset form.issue_id = #ii.issue_id#+1>
</cfif>
Create Issue: Step 1<input type="hidden" name="issue_id" value="#form.issue_id#"></cfif>
  <table border="0">
    <tr>
      <td colspan="3"><div align="right">Select stories by </div></td>
      <td colspan="3"><select name="criteria">
          <option value="added">date added</option>
          <option value="story">story date</option>
            </select></td>
    </tr>
<cfset current = now()>
<cfset twoweeks = current-14>
    <tr>
      <td colspan="6"> </td>
    </tr>
    <tr>
      <td>Month</td>
      <td>
<select name="frommonth">
<cfloop from="0" to="11" step="1" index="add">
<option value="#dateformat(dateadd('m', add, twoweeks), 'm')#">
#dateformat(dateadd('m', add, twoweeks), 'mmmm')#</option>
</cfloop>
</select>
   </td>
      <td>Day</td>
      <td>
   <select name="fromday">
<cfloop from="1" to="31" step="1" index="add">
<option value="#add#" <cfif #dateformat(twoweeks, 'd')# eq #add#>selected</cfif>>#add#</option>
</cfloop>
</select>
</td>
      <td>Year</td>
      <td>
   <select name="fromyear">
<cfloop from="-1" to="1" step="1" index="add">
<option value="#dateformat(dateadd('yyyy', add, twoweeks), 'yyyy')#"
<cfif #dateformat(dateadd('yyyy', add, twoweeks), 'yyyy')# eq #dateformat(twoweeks, 'yyyy')#>selected</cfif>>
#dateformat(dateadd('yyyy', add, twoweeks), 'yyyy')#</option>
</cfloop>
</select>
</td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td>Month</td>
      <td><select name="tomonth">
<cfloop from="0" to="11" step="1" index="add">
<option value="#dateformat(dateadd('m', add, current), 'm')#">
#dateformat(dateadd('m', add, current), 'mmmm')#</option>
</cfloop>
</select>
</td>
      <td>Day</td>
      <td>   <select name="today">
<cfloop from="1" to="31" step="1" index="add">
<option value="#add#" <cfif #dateformat(current, 'd')# eq #add#>selected</cfif>>#add#</option>
</cfloop>
</select>
</td>
      <td>Year</td>
      <td>   <select name="toyear">
<cfloop from="-1" to="1" step="1" index="add">
<option value="#dateformat(dateadd('yyyy', add, current), 'yyyy')#"
<cfif #dateformat(dateadd('yyyy', add, current), 'yyyy')# eq #dateformat(current, 'yyyy')#>selected</cfif>>
#dateformat(dateadd('yyyy', add, current), 'yyyy')#</option>
</cfloop>
</select>
</td>
    </tr>
    <tr>
      <td colspan="6"><input type="submit" value="Get Articles"></td>
    </tr>
  </table>
</form>
</body>
</html>
</cfoutput>

Here is the viewbydateaction.cfm (error message returned on this page):

<cfoutput>
<!--- CREATE DATES FOR THE FROM AND TO DATES ON SUBMIT PAGE --->
<cfif isdefined('form.fromyear')>
<cfset fromdate = #createdatetime(form.fromyear,form.frommonth,form.fromday,0,0,0)#>
<cfset todate = #createdatetime(form.toyear,form.tomonth,form.today,23,59,59)#>
</cfif>
<!--- GET ALL STORIES --->
<cfquery name="z" datasource="newsbriefs" cachedwithin="#createtimespan(0,0,15,0)#">
select *
from news
</cfquery>
<cfquery  datasource="newsbriefs" name="y">
select distinct news_category
from news
order by news_category
</cfquery>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>View Articles</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<cfinclude template="menu.cfm">
<form name="form" method="post" action="preview.cfm">
<cfif isdefined('form.issue_id') and #form.issue_id# neq "">Create Issue: Step 2<input type="hidden" name="issue_id" value="#form.issue_id#"><cfset makeissue = true></cfif>

<table border="1">
<cfloop query="y">
<cfquery datasource="newsbriefs" name="a">
select *
from category
where category_id = #y.news_category#
</cfquery>
<tr><td colspan="2"><h1>#a.category_name#</h1></td></tr>
<cfquery datasource="newsbriefs" name="x">
select *
from news
where news_category = #y.news_category#
order by news_category,news_year desc,news_month desc,news_day desc
</cfquery>
<cfquery datasource="newsbriefs" name="ii">
SELECT TOP 1 ISSUE.ISSUE_ID, finalize
FROM ISSUE
ORDER BY ISSUE.ISSUE_ID DESC;
</cfquery>
<cfloop query="x">
<cfset storydate = '#dateformat(createdate(x.news_year,x.news_month,x.news_day), 'd mmmm yyyy')#'>
<cfif #form.criteria# eq 'story'>
<cfif #storydate# gte #fromdate# and #storydate# lte #todate#>
#x.news_title#<br>
#storydate#
<br>
<br></cfif>
<cfelse>
<cfif #x.added# gte #fromdate# and #x.added# lte #todate#>
<tr><td rowspan="4" width="20">
<cfif isdefined('makeissue') and #makeissue# eq true><input type="checkbox" name="storyid" value="#x.news_id#">Add
<cfif #ii.finalize# eq false>to temp issue</cfif></cfif><br>
<br>

<cfquery datasource="newsbriefs" name="b">
select *
from news_issue
where news_id = #x.news_id#
</cfquery>
<cfif isdefined('b.issue_id') and #b.issue_id# neq "">
<cfloop query="b">
issue #b.issue_id#<Br>
</cfloop><cfelse> </cfif>
</td><td><a href="editarticle.cfm?news_id=#x.news_id#">#x.news_title#</a></td></tr>
<tr><td>#storydate#</td></tr>
  <tr><td>#news_text#</td></tr>
    <tr><td>#news_source#</td></tr>

</cfif>
</cfif>
</cfloop>
<tr><td colspan="2"> </td></tr>
</cfloop>
</table>
<input type="submit" value="NEXT >>">
</form>
</body>
</html>
</cfoutput>

Inspiring
December 14, 2011

That is a little too much code to wade through ;-). Can you narrow it down to code within the vicinity of the error? The error message reports the problem is near line 49.

I have only skimmed, but based on the error my guess is you are trying to create a date with an invalid month number. For example, using createDate(2011, 0, 14) would cause that error because "0" is not a valid month number ie (January=1 to December=12)

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7f80.html