EJB3 + JSF2;像有状态的一样无状态
我在 ejb 容器中有一个无状态会话 bean。如果我从 jsf2 表单调用它,它工作正常,但如果我再次回忆该表单,它会显示我之前插入的相同数据。即使我关闭并重新打开浏览器也会发生这种情况。我必须等待几分钟,直到表单显示空字段。 不会为每个请求重新创建无状态会话 Bean。它的行为就像一个有状态的。有什么问题吗?
应用服务器:Glassfish 3.0.1
I've a stateless session bean in an ejb container. If I invoke it from a jsf2 form it works fine, but if I recall the form again it shows me the same data I've inserted before. It happens even if I close and reopen the browser. I must wait several minutes until the form shows empty fields.
The stateless session bean is not recreated for each request. It behaves like a stateful one. What's the wrong?
Application server: Glassfish 3.0.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是一个正确的术语。不保证为每个请求创建新的无状态 bean 实例。
出于性能原因,容器将池化一些无状态 bean 实例。
池实例的数量取决于容器配置。
this is not a correct term. there is no guaranty to create new instance of stateless bean for each request.
container will pool some instances of stateless bean for performance reason.
the number of pooled instances depends on container configuration.
Struts 本身不执行任何操作,它只执行您告诉他执行的操作。我怀疑你只是误用了东西。显示一些代码来说明问题可能会有所帮助。
一般来说,情况并非如此,您可以获得无状态会话 bean (SLSB) 的任何 实例。即使由于某些原因您在特定情况下获得了相同的实例(可能是因为 beans 池配置),在使用 SLSB 时这根本不应该是问题,您不应该不关心你得到什么实例,当然不依赖于实例的状态(因为它们是无状态的)。
回到你的问题,我怀疑你滥用 SLSB 并期待不正确的事情:
相关问题
Struts doesn't do anything by itself, it only does what you tell him to do. And I suspect that you're just misusing things. Showing some code to illustrate the problem might help.
This is not true in general, you can get any instance of a stateless session bean (SLSB). And even if for some reasons you get the same instance in your particular situation (maybe because of the beans pool configuration), this shouldn't be an issue at all when using SLSB, you should not care of what instance you get and certainly not rely on the state of instances (since they're stateless).
Back to your question, I suspect that you're misusing SLSB and expecting things that are not true:
Related questions