Ошибка RestAPi в custom RestController-е java.lang.SecurityException: No security context bound to the current thread
Версия cuba 7.2.13 version.
Error: Request processing failed; nested exception is java.lang.SecurityException: No security context bound to the current thread
ниже код:
Copy
package com.sample.app.web.rest;
import com.haulmont.cuba.core.global.DataManager;
import com.haulmont.cuba.core.global.Metadata;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.inject.Inject;
import java.util.Map;
@RestController
@RequestMapping(“restController”)
public class RestController {
@Inject
protected DataManager dataManager;
@Inject
protected Metadata metadata;
@PostMapping("create")
public ResponseEntity<Map> create() {
Person person = metadata.create(Person.class);
person.setName("Johnny");
dataManager.commit(person);
return new ResponseEntity<>(HttpStatus.CREATED);
}
}
com.haulmont.cuba.security.app.Authentication мне не доступен в restController-е так как он находится в пакете com.sample.app.web.rest