<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How to avoid IllegalStateException during login &amp; logout in a Script-Step?</title><link>https://answers.axonivy.com/questions/694/how-to-avoid-illegalstateexception-during-login-logout-in-a-script-step</link><description>&lt;p&gt;We have a certain situation where the current named user shall be logged out and be logged in as a different user. The problem is, that this results in an illegal task state. Code in the script step:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ivy.session.loginSessionUser("user1", "user1");

if(in.isSuperior == true) {
    ivy.session.loginSessionUser("superiorUser", "superiorUser");
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Exception:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Exception at element [13B4B87B3A16CFA4-f15-io0]: java.lang.IllegalStateException: State of Task must be one of the following values CREATED, RESUMED but is ZOMBIE:
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is there a way to avoid this behavoir?&lt;/p&gt;
&lt;p&gt;Xpert.ivy 4.3. - error occurs on Designer &amp;amp; Server level.&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/694/how-to-avoid-illegalstateexception-during-login-logout-in-a-script-step" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 16 May 2014 08:58:38 -0400</lastBuildDate><item><title>Comment by Nikel Weis on Reto Weiss's answer</title><link>https://answers.axonivy.com/questions/694/how-to-avoid-illegalstateexception-during-login-logout-in-a-script-step#700</link><description>&lt;p&gt;Thanks. The API was not quite clear on the effect of this parameter. Works like a charm.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nikel Weis</dc:creator><pubDate>Fri, 16 May 2014 08:58:38 -0400</pubDate><guid>https://answers.axonivy.com/questions/694/how-to-avoid-illegalstateexception-during-login-logout-in-a-script-step#700</guid></item><item><title>Answer by Reto Weiss</title><link>https://answers.axonivy.com/questions/694/how-to-avoid-illegalstateexception-during-login-logout-in-a-script-step/699</link><description>&lt;p&gt;If you login a session user all tasks that were resumed by the session are reset. This also includes the current task that executes the script step with the login statements. To avoid this use the overloaded method that takes an additional third parameter an provide it the identifier of the current task. &lt;/p&gt;
&lt;p&gt;E.g. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ivy.session.loginSessionUser("user1", "password1", ivy.task.getId());
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this case all tasks that were resumed by the session are reset except the one with the given id.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reto Weiss</dc:creator><pubDate>Thu, 15 May 2014 17:41:52 -0400</pubDate><guid>https://answers.axonivy.com/questions/694/how-to-avoid-illegalstateexception-during-login-logout-in-a-script-step/699</guid></item></channel></rss>