Are there any known issues using P1W as a time duration?

cancel
Showing results for 
Search instead for 
Did you mean: 
kch0313
Active Member

Are there any known issues using P1W as a time duration?

Jump to solution

We have been using time duration with ISO 8601 durations, but have recently tried testing more variations.  Today we received this error, that by the stack trace seems to indicate a problem with resolving the duration, and possibly related to the default business calendar.  Is there some configuration necessary to support a duration of P1W?

We don't use a custom business calendar, just the default.

It seems like it may be an unsupported duration?
    java.lang.IllegalArgumentException: P1W

org.activiti.engine.ActivitiException: couldn't resolve duedate: P1W
at org.activiti.engine.impl.calendar.DurationBusinessCalendar.resolveDuedate(DurationBusinessCalendar.java:37)
at org.activiti.engine.impl.calendar.BusinessCalendarImpl.resolveDuedate(BusinessCalendarImpl.java:22)
at org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl.prepareTimerEntity(TimerDeclarationImpl.java:165)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.initialize(ExecutionEntity.java:351)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:43)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:80)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:116)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:35)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:452)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:430)
at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:140)
at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:66)
at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44)
at org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:47)
at org.activiti.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior.execute(ServiceTaskDelegateExpressionActivityBehavior.java:87)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.jobexecutor.AsyncContinuationJobHandler.execute(AsyncContinuationJobHandler.java:35)
at org.activiti.engine.impl.persistence.entity.JobEntity.execute(JobEntity.java:85)
at org.activiti.engine.impl.persistence.entity.MessageEntity.execute(MessageEntity.java:34)
at org.activiti.engine.impl.cmd.ExecuteAsyncJobCmd.execute(ExecuteAsyncJobCmd.java:52)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:69)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: P1W
at org.apache.xerces.jaxp.datatype.DurationImpl.organizeParts(Unknown Source)
at org.apache.xerces.jaxp.datatype.DurationImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.newDuration(Unknown Source)
at org.activiti.engine.impl.calendar.DurationHelper.parsePeriod(DurationHelper.java:169)
at org.activiti.engine.impl.calendar.DurationHelper.<init>(DurationHelper.java:89)
at org.activiti.engine.impl.calendar.DurationHelper.<init>(DurationHelper.java:107)
at org.activiti.engine.impl.calendar.DurationBusinessCalendar.resolveDuedate(DurationBusinessCalendar.java:34)
... 60 more

1 Solution

Accepted Solutions
gdharley
Intermediate

Re: Are there any known issues using P1W as a time duration?

Jump to solution

Based on the code I see in the DurationHelper class below:

private Calendar add(Calendar date, Duration duration) {
Calendar calendar = (Calendar) date.clone();

// duration.addTo does not account for daylight saving time (xerces),
// reversing order of addition fixes the problem
calendar.add(Calendar.SECOND, duration.getSeconds() * duration.getSign());
calendar.add(Calendar.MINUTE, duration.getMinutes() * duration.getSign());
calendar.add(Calendar.HOUR, duration.getHours() * duration.getSign());
calendar.add(Calendar.DAY_OF_MONTH, duration.getDays() * duration.getSign());
calendar.add(Calendar.MONTH, duration.getMonths() * duration.getSign());
calendar.add(Calendar.YEAR, duration.getYears() * duration.getSign());

return calendar;
}

It doesn't appear as though "W" or week is supported.

I have not run a debugger against this to verify, but this would explain your symptoms.

Greg

View solution in original post

5 Replies
jearles
Established Member II

Re: Are there any known issues using P1W as a time duration?

Jump to solution

Not that I am aware of, but I'll check and follow up with you.

If you could provide any other related information, that would be awesome. Particularly a snippet of the code that triggers this stack trace.


-JEarles

kch0313
Active Member

Re: Are there any known issues using P1W as a time duration?

Jump to solution

I added attachments to my original post, one with the BPMN model you can import and execute.  Basically, it sets a process variable, and the wait intermediate timer activity uses the variable in a JUEL expression in the duration.  Doing this with other ISO 8601 durations worked, but P1W didn't.  I used Activiti Explorer to import this model, deploy, and start an instance to generate the error.  The other attachment added to my original post is the log snippet from Tomcat showing the error reported in Activiti Explorer with errors similar to my original stack trace (with a fragment below).

Caused by: org.activiti.engine.ActivitiException: couldn't resolve duedate: P1W
at org.activiti.engine.impl.calendar.DurationBusinessCalendar.resolveDuedate(DurationBusinessCalendar.java:37)
at org.activiti.engine.impl.calendar.BusinessCalendarImpl.resolveDuedate(BusinessCalendarImpl.java:22)
at org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl.prepareTimerEntity(TimerDeclarationImpl.java:165)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.initialize(ExecutionEntity.java:351)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:43)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)

... ommitted for brevity

Caused by: java.lang.IllegalArgumentException: P1W
at com.sun.org.apache.xerces.internal.jaxp.datatype.DurationImpl.organizeParts(DurationImpl.java:612)
at com.sun.org.apache.xerces.internal.jaxp.datatype.DurationImpl.<init>(DurationImpl.java:524)
at com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl.newDuration(DatatypeFactoryImpl.java:104)
at org.activiti.engine.impl.calendar.DurationHelper.parsePeriod(DurationHelper.java:169)
at org.activiti.engine.impl.calendar.DurationHelper.<init>(DurationHelper.java:89)
at org.activiti.engine.impl.calendar.DurationHelper.<init>(DurationHelper.java:107)
at org.activiti.engine.impl.calendar.DurationBusinessCalendar.resolveDuedate(DurationBusinessCalendar.java:34)
... 138 more

gdharley
Intermediate

Re: Are there any known issues using P1W as a time duration?

Jump to solution

Based on the code I see in the DurationHelper class below:

private Calendar add(Calendar date, Duration duration) {
Calendar calendar = (Calendar) date.clone();

// duration.addTo does not account for daylight saving time (xerces),
// reversing order of addition fixes the problem
calendar.add(Calendar.SECOND, duration.getSeconds() * duration.getSign());
calendar.add(Calendar.MINUTE, duration.getMinutes() * duration.getSign());
calendar.add(Calendar.HOUR, duration.getHours() * duration.getSign());
calendar.add(Calendar.DAY_OF_MONTH, duration.getDays() * duration.getSign());
calendar.add(Calendar.MONTH, duration.getMonths() * duration.getSign());
calendar.add(Calendar.YEAR, duration.getYears() * duration.getSign());

return calendar;
}

It doesn't appear as though "W" or week is supported.

I have not run a debugger against this to verify, but this would explain your symptoms.

Greg

jearles
Established Member II

Re: Are there any known issues using P1W as a time duration?

Jump to solution

For a little bit more context on this:

The code that creates the DueDate based on what is entered in the model editor uses the DatatypeFactory API, calling the method: newDuration(String lexicalRepresentation) - which creates the calendar object based on the string format "PnYnMnDTnHnMnS", which does not include weeks (as defined in the XML Schema 1.0 Section 3.2.6.1).

So the behavior you're seeing is expected and caused by the libraries being used.

-JEarles

kch0313
Active Member

Re: Are there any known issues using P1W as a time duration?

Jump to solution

the obvious work-around for this is to use 7 days (P7D), which for most is an equivalent operation.

 thanks both for your immediate attention and helpful information.