[英]Dependency injection conflict when more than one user uses the system
I made a single Java Application using Tomcat(Prod) and Jetty(Dev) + Hibernate + Spring + Spring MVC + Fremarker I have a issue to solve, 'cause the users are reporting that only one user can do login without conflict. 我使用Tomcat(Prod)和Jetty(Dev)+ Hibernate + Spring + Spring MVC + Fremarker创建了一个Java应用程序。我有一个要解决的问题,因为用户报告说只有一个用户可以进行登录而不会发生冲突。 If a user does login and tries to create a new entity Payment, he have a successfull transaction.
如果用户登录并尝试创建新的实体“付款”,则表示他已成功完成交易。 But when another user does login, since then, nobody can create a new Payment.
但是从那时起,当另一个用户登录时,没有人可以创建新的付款。
There is no exception, a POST is executed, but seems like the Controller is not able for delivery the form to services classes. 也不例外,将执行POST,但似乎Controller无法将表单传递给服务类。
@MappedSuperclass
@Getter
@Setter
public abstract class AbstractEntity implements Persistable, Cloneable {
//code...
}
@Entity
@Getter
@Setter
public class Pagamento extends AbstractEntity{
//code...
}
@Component
@Transactional
public class PagamentoService {
//code...
}
@Controller
@RequestMapping("/payments")
public class PagamentosController {
//code...
}
Is everything okay about Annotations and CDI? 关于注释和CDI的一切都可以吗? What could to be happening?
可能会发生什么?
A common use case for that is using attributes of controller (or service, dao, etc.) classes. 常见的用例是使用控制器(或服务,Dao等)类的属性。 All those beans are singleton beans and are shared between all requests and sessions.
所有这些bean是单例bean,并且在所有请求和会话之间共享。 You should only use local variables in all those singleton beans - except of course for attributes that are common for the whole application ...
您只应在所有这些单例bean中使用局部变量-当然,对于整个应用程序共有的属性除外。
可能是因为您使用的是单连接数据源,所以一旦一个请求建立了连接,那么在第一个释放单个数据库连接之前,没有其他请求可以访问它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.