# Versioning doesn't work

**URL:** <https://community.temporal.io/t/versioning-doesnt-work/3544>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [December 7, 2021, 11:32am UTC](https://community.temporal.io/t/versioning-doesnt-work/3544 "2021-12-07T11:32:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrei\_Yaraha](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/andrei_yaraha/32/1561_2.png) [@Andrei\_Yaraha](https://community.temporal.io/u/Andrei_Yaraha)\
**Post date:** [December 7, 2021, 11:32am UTC](https://community.temporal.io/t/versioning-doesnt-work/3544/1 "2021-12-07T11:32:43Z")

</div>

Hi!  
I faced an issue with versioning. In my case, it doesn’t work…  
I tried the following code:

```auto

int version = Workflow.getVersion("removeScenario", Workflow.DEFAULT_VERSION, 1);
if (version == Workflow.DEFAULT_VERSION) {
        configs.add(generateScenarioConfiguration());
}

```

When I create a fresh workflow everything is fine. But for the existing workflow which in the running state this code is failed with the following exception:

```auto
io.grpc.StatusRuntimeException: INVALID_ARGUMENT: io.temporal.internal.replay.InternalWorkflowTaskException: Failure handling event 40 of 'EVENT_TYPE_MARKER_RECORDED' type. IsReplaying=true, PreviousStartedEventId=36, workflowTaskStartedEventId=0, Currently Processing StartedEventId=36
	at io.temporal.internal.statemachines.WorkflowStateMachines.handleEvent(WorkflowStateMachines.java:193)
	at io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleEvent(ReplayWorkflowRunTaskHandler.java:140)
	at io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTaskImpl(ReplayWorkflowRunTaskHandler.java:180)
	at io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleQueryWorkflowTask(ReplayWorkflowRunTaskHandler.java:254)
	at io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleQueryOnlyWorkflowTask(ReplayWorkflowTaskHandler.java:257)
	at io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTask(ReplayWorkflowTaskHandler.java:112)
	at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:319)
	at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:279)
	at io.temporal.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:73)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalStateException: Unexpected local activity id: 03a0f33c-030b-3190-8f2c-9be79d8fa6f8
	at io.temporal.internal.statemachines.WorkflowStateMachines.handleLocalActivityMarker(WorkflowStateMachines.java:369)
	at io.temporal.internal.statemachines.WorkflowStateMachines.handleCommandEvent(WorkflowStateMachines.java:231)
	at io.temporal.internal.statemachines.WorkflowStateMachines.handleEventImpl(WorkflowStateMachines.java:199)
	at io.temporal.internal.statemachines.WorkflowStateMachines.handleEvent(WorkflowStateMachines.java:178)
	... 11 more

	at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
	at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
	at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.queryWorkflow(WorkflowServiceGrpc.java:2970)
	at io.temporal.internal.external.GenericWorkflowClientExternalImpl.lambda$query$5(GenericWorkflowClientExternalImpl.java:216)
	at io.temporal.internal.common.GrpcRetryer.retryWithResult(GrpcRetryer.java:97)
	at io.temporal.internal.external.GenericWorkflowClientExternalImpl.query(GenericWorkflowClientExternalImpl.java:209)
	at io.temporal.internal.sync.WorkflowStubImpl.query(WorkflowStubImpl.java:470)
	at io.temporal.internal.sync.WorkflowInvocationHandler$SyncWorkflowInvocationHandler.queryWorkflow(WorkflowInvocationHandler.java:312)
	at io.temporal.internal.sync.WorkflowInvocationHandler$SyncWorkflowInvocationHandler.invoke(WorkflowInvocationHandler.java:275)
	at io.temporal.internal.sync.WorkflowInvocationHandler.invoke(WorkflowInvocationHandler.java:181)
	at com.sun.proxy.$Proxy119.getConfiguration(Unknown Source)
	at ai.test.api.scenario.api.plans.AssortmentPlanCommandController.getPlan(AssortmentPlanCommandController.java:47)
	at ai.test.api.scenario.api.plans.AssortmentPlanCommandController$$FastClassBySpringCGLIB$$29884fde.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
	at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:61)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)
	at ai.test.api.scenario.api.plans.AssortmentPlanCommandController$$EnhancerBySpringCGLIB$$2df8dd2d.getPlan(<generated>)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1060)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:962)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:327)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:105)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:178)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
	at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90)
	at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:110)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)

```

Do you know how we can handle this case?

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [December 7, 2021, 2:42pm UTC](https://community.temporal.io/t/versioning-doesnt-work/3544/2 "2021-12-07T14:42:51Z")

</div>

> [@Andrei\_Yaraha](#):
>
> `configs.add(generateScenarioConfiguration());`

is this line of code being added as part of the new version or was it there before and you want to exclude it from workflow execs that run with version 1?  
If its the former, your “if” should be:

`if (version == 1) { ... }`

---

<div class="post-metadata">

**Author:** ![Andrei\_Yaraha](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/andrei_yaraha/32/1561_2.png) [@Andrei\_Yaraha](https://community.temporal.io/u/Andrei_Yaraha)\
**Post date:** [December 7, 2021, 2:55pm UTC](https://community.temporal.io/t/versioning-doesnt-work/3544/3 "2021-12-07T14:55:36Z")

</div>

> [@tihomir](#):
>
> is this line of code being added as part of the new version or was it there before and you want to exclude it from workflow execs that run with version 1?  
> If its the former, your “if” should be:

I want to exclude this line in the future process

---

<div class="post-metadata">

**Author:** ![Andrei\_Yaraha](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/andrei_yaraha/32/1561_2.png) [@Andrei\_Yaraha](https://community.temporal.io/u/Andrei_Yaraha)\
**Post date:** [December 7, 2021, 3:19pm UTC](https://community.temporal.io/t/versioning-doesnt-work/3544/4 "2021-12-07T15:19:18Z")

</div>

In case of running and existing workflow code with versioning code (Workflow.getVersion(“removeScenario”, Workflow.DEFAULT\_VERSION, 1)) is failed…

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [December 7, 2021, 5:26pm UTC](https://community.temporal.io/t/versioning-doesnt-work/3544/5 "2021-12-07T17:26:06Z")

</div>

> [@Andrei\_Yaraha](#):
>
> `Caused by: java.lang.IllegalStateException: Unexpected local activity id: 03a0f33c-030b-3190-8f2c-9be79d8fa6f8`

Does your code:

`configs.add(generateScenarioConfiguration());`

invoke any local activities? Also what’s the Java SDK version you are using?

---

<div class="post-metadata">

**Author:** ![Andrei\_Yaraha](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/andrei_yaraha/32/1561_2.png) [@Andrei\_Yaraha](https://community.temporal.io/u/Andrei_Yaraha)\
**Post date:** [December 8, 2021, 8:12am UTC](https://community.temporal.io/t/versioning-doesnt-work/3544/6 "2021-12-08T08:12:08Z")

</div>

No, this method just creates an object with a few fields. We use Java 11 and temporal-sdk 1.0.6

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [December 8, 2021, 4:34pm UTC](https://community.temporal.io/t/versioning-doesnt-work/3544/7 "2021-12-08T16:34:02Z")

</div>

There has to be something else going on imo. The code you have, and if indeed configs.add is just a util method this should be ok.

Can you show your workflow history? Also are you sure this is the only change that you are making to your code between versions?  
Worth also updating your java sdk to latest release and try - [java sdk releases](https://github.com/temporalio/sdk-java/releases).

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [December 8, 2021, 5:00pm UTC](https://community.temporal.io/t/versioning-doesnt-work/3544/8 "2021-12-08T17:00:57Z")

</div>

> No, this method just creates an object with a few fields. We use Java 11 and temporal-sdk 1.0.6

Such change is fully backward compatible even without versioning assuming that this object is not used later to take a different path in the workflow code.
