Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

java.lang.IllegalArgumentException: MONTH Error

Guest
Dec 14, 2011 Dec 14, 2011

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) 
8.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Dec 14, 2011 Dec 14, 2011
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

...
Translate
LEGEND ,
Dec 14, 2011 Dec 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 14, 2011 Dec 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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 14, 2011 Dec 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 14, 2011 Dec 14, 2011

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 14, 2011 Dec 14, 2011
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==-

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 14, 2011 Dec 14, 2011

Thanks for your responses and advices. While I am still searching for a solution, if you do not mind, I'd like to ask why this stopped working suddenly (no any changes made in at least 2 years)? We are using MS Access 2000 as the DB, and this module had been working correctly many years. I checked with the server admin, he told me that there were just some regular daily updates on the server before the errors appeared. The news_year, news_month, and news_day are "number" type in DB. Since other pages involving the search by date actions are also having this problem, I do not know if it is a good idea to make some changes to the code one by one. Scratching my head now...

As advised, I used <cfdump var=#z.news_month#> after query:

<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>

And the returned value is 11, but in the database, the news_month value of the very first record is 12, and the last record is 1.

Then I tried the dump on another page which having the same error (see below) and the returned value is correct: 12 (the newest record's month in DB).

294 : <cfset date="#CreateDate(news_year,news_month,1)#">

295 : <cfelse>

296 : <cfset datef="#DateFormat(CreateDate(news_year,news_month,news_day),'d mmmm yyyy')#">

297 : <cfset date="#CreateDate(news_year,news_month,news_day)#">

298 : </cfif>

What should I do to fix? I know I am asking a very dumb question, please forgive my ignorance.

Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 14, 2011 Dec 14, 2011

Ha, I figured out where the problem is: there was a date in the database which is wrong: Nov 31, 2011. Obviously there is no 31 in November, so I changed the date in the database and it worked! Horary!!!

Many thanks to cfsearching and Adam for your responses and ideas!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 14, 2011 Dec 14, 2011

Pre-database validation for the win. Guess you're storing them as some kind of number of varchar then? If only there was a data type for dates...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 14, 2011 Dec 14, 2011

Pre-database validation for the win. Guess you're storing them as some kind of number of varchar then? If only there was a data type for dates...

I think he is storing the month, day and year separately.  But agreed they need to add validation or this could easily happen again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 15, 2011 Dec 15, 2011

You are right, the date, month, and year are stored separatly. I am learning things from you responses . I probably will not have extra time to update this module or something as long as it works for now because I am developing a new system. Very much appreciate your help and appologize for the wrong marking actions (new user and do not know the rules).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 15, 2011 Dec 15, 2011

wangchoyqz wrote:

Ha, I figured out where the problem is: there was a date in the database which is wrong: Nov 31, 2011. Obviously there is no 31 in November, so I changed the date in the database and it worked! Horary!!!

Many thanks to cfsearching and Adam for your responses and ideas!

Wangchoyqz,

You shouldn't have offered the points to yourself. You contributed nothing to the solution. I would have done the decent thing, and offered the points as follows:

5 points to Adam for:

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

5 points to -==cfSearching==- for:

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

10 points to -==cfSearching==- for:

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 15, 2011 Dec 15, 2011

Sorry, I did not know the rules here. I just wanted to mark the problem was solved and did not aware there was an earning points thing. I do not care the points at all, was just seeking for solution. I really appreciate CFsearching and Owain's advices. Can anybody direct me how to change the marks? Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 15, 2011 Dec 15, 2011

I do not care the points at all,

I doubt many people do... I mean... what purpose do they serve?

I think marking the actual answer as "the answer" (irrespective of who posts it, and how many other people helped on the journey) is more useful than doling out points to people.  So I think you have done exactly the right thing, marking your own follow-up as the answer.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 15, 2011 Dec 15, 2011
LATEST

Thanks Adam! That's all right. The only thing I care is the ways to the solution

I figured out how to change the marks and made the changes

Let's close the discussion on this thread. The problem is solved, thank you all!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources