0

When I send POST request to the server for SignUp I receive an error that session is outdated or not initialized. How could it be solved?

// create request
@BeforeClass
private void createRequestSpecification() {
    test_user = new User();
    requestSpec = new RequestSpecBuilder().
            setBaseUri(ApiTestBase.currentEnvironment.getUrl()).
            setPort(443).
            setContentType(ContentType.JSON).
            setBasePath("/Server/user/registerUser").
            build();
}
// post request
@Test
private void correctSignUp() {
    Response response = given().
            spec(requestSpec).
            and().
            queryParam("companyName", test_user.getCompany()).
            queryParam("firstName", test_user.getFName()).
            queryParam("lastName", test_user.getLName()).
            queryParam("loginName", test_user.getEmail()).
            queryParam("password", DigestUtils.sha256Hex(test_user.getPass())).
            when().
            post().
            then().
            log().all().
            assertThat().statusCode(200).
            and().
            extract().
            response();
    checkIfSignUp(true, response);
}

Response

    <body>
    <h1>HTTP Status 500 – Internal Server Error</h1>
    <hr class="line"/>
    <p>
    <b>Type</b>
 Exception Report 
    <p>
    <b>Message</b>
 Request processing failed; nested exception is java.lang.RuntimeException: session is outdated or not initialized, re-login    </p>
    <p>
    <b>Description</b>
 The server encountered an unexpected condition that prevented it from fulfilling the request.    </p>
    <p>
    <b>Exception</b>
    </p>
    <pre>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.RuntimeException: session is outdated or not initialized, re-login
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
</pre>
    <p>
      <b>Root Cause</b>
    </p>
    <pre>java.lang.RuntimeException: session is outdated or not initialized, re-login
    com.novisign.server.user.controller.SessionSecureData.get(SessionSecureData.java:37)
    com.novisign.server.user.controller.UserController.registerUser(UserController.java:306)
    sun.reflect.GeneratedMethodAccessor855.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:498)
    org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
</pre>
  • I am not sure queryParam is the proper method to send credentials data. Try to use params(...) instead – Alexey R. Jan 18 at 12:35
  • It doesn't work this way. Login tests works Ok even with queryParam using POST, but SignUp tests don't. – Artur Jan 18 at 19:58
-1

Cookies should be sent with Request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.