Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Array index out-of-bounds and String is not a date Exception

SA-9486

Summary



A custom business solution that implements an Agent configuration utilizing AGENT ADVANCED mode is created . Agent is configured to run four separate threads against the same common agent activity.

As a result, at runtime, the agent launches four threads to run the common activity, but at runtime, three agents (random and never the same agent instances) fail, with an error in the log. No error messages are displayed on screen, however, the SMA confirms that three of the Agents are disabled due to runtime error messages.
 

Error Messages

2015-04-24 14:17:34,065 [             PegaRULES-Batch-5] [  STANDARD] [       CAMS:01.01.01] (ernal.async.BatchRequestorTask) ERROR   - Batch activity "your_class-Work.TestActivity" threw:

java.lang.ArrayIndexOutOfBoundsException: 13
 at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:436)
 at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2081)
 at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:1996)
 at java.util.Calendar.setTimeInMillis(Calendar.java:1110)
 at java.util.Calendar.setTime(Calendar.java:1076)
 at java.text.SimpleDateFormat.format(SimpleDateFormat.java:875)
 at java.text.SimpleDateFormat.format(SimpleDateFormat.java:868)
 at java.text.DateFormat.format(DateFormat.java:316)
 at com.pega.pegarules.data.internal.access.PageDatabaseMapperImpl.setResultStringFromResultSet(PageDatabaseMapperImpl.java:797)
 at com.pega.pegarules.data.internal.access.PageDatabaseMapperImpl.setResultPropertyFromResultSet(PageDatabaseMapperImpl.java:863)
 at com.pega.pegarules.data.internal.access.PageDatabaseMapperImpl.populatePageFromExposedColumns(PageDatabaseMapperImpl.java:564)
 at com.pega.pegarules.data.internal.access.ResultPageIteratorImpl.getClipboardPage(ResultPageIteratorImpl.java:1070)

 

Steps to Reproduce



1. Define a new instance of RULE-AGENT-QUEUE. Configure the agent definition on the correct Ruleset, and disable Authenticate on Activity startup.
2. Configure the Agent definition with four separate calls to the same Agent activity. Pass requisite parameters as necessary.
3. Trigger the start of the Agent through the SMA.  Observe error condition in the Pega logfile.
 

Root Cause



The root cause of this issue was not related to the previously provided software fixes; rather, the design and configuration of the Agent Activity was found to be a problem.

Advanced mode Agent leaves control of managing resource management and thread contention to the developer. Further, a close examination of this error message indicates that the root cause of the error was a collision of threads using a non-thread-safe Java Library (DateFormat).  As a result, the collision of Agent threads was certain.
 

Resolution



The following are two ways to resolve this issue:

  • Configure the Agent Activity with a call to standard Java method Thread.sleep(), and change the amount of sleep. Configure the activity and subsequent activity method steps to run out-of-order of each other (different threads), thereby reducing or eliminating the chance of this error from occurring.

The Activity Java Method code is:

try {
  Thread.sleep(time);
}  catch (InterruptedException ex) {
  Thread.currentThread().interrupt();
}

For each Agent call, pass a parameter from the Agent call to the activity that provides a different value for sleep time.
For example: four Agent calls - first call has a value of zero (0); second call has a value of 500; subsequent calls each have a value larger (by 500) for each call.  Time is in milliseconds.  

Do not modify the Agent INTERVAL configuration value. For each call, let the value remain at a common value (30 seconds).

  • Update the design:

Limit each PRPC Node agent definition to call one instance of this activity. Therefore, in a four node environment, you can acheive the same result (four simultaneous calls) with one on each node.

Suggest Edit

Published November 9, 2015 - Updated October 8, 2020

Did you find this content helpful? Yes No

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us