小编Mik*_*sen的帖子

Guice @Transactional不会启动交易

我已经开始使用吉斯方法级交易等中描述的在这里.我有一条消息

@Inject
private EntityManager entityManager;

@Transactional
public UserSession createSession(User user, String browser) {
    UserSession session = new UserSession(user, browser);
    entityManager.persist(session);
}
Run Code Online (Sandbox Code Playgroud)

从简短的描述我认为应该足够了.但是我得到一个错误,因为没有启动任何事务.只有当我自己开始并提交它时,它才有效.

对象由Guice在初始化程序中的应用程序开始时创建.每个请求都使用相同的实例.

为什么不起作用?

java guice

9
推荐指数
1
解决办法
4493
查看次数

JSF中基于表单的身份验证

我想在JSF/Primefaces应用程序中实现一个简单的身份验证.我尝试了很多不同的东西,例如Dialog - Login Demo在对话框上做了一个简单的测试,但是它没有登录用户或者?

我也看了一下Java Security,比如:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Protected Area</web-resource-name>
        <url-pattern>/protected/*</url-pattern>
        <http-method>PUT</http-method>
        <http-method>DELETE</http-method>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>REGISTERED_USER</role-name>
    </auth-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

有了这个/受保护的一切都受到保护,但据我所知,我需要在服务器中定义一个领域进行身份验证.我不想在服务器中指定它,只是在数据库中进行简单的查找.

有没有办法在不在应用程序服务器中定义某些内容的情况下验证用户?或者另外一个简单的解决方案来验证和保护不同的页面?

java security authentication jsf jaspic

4
推荐指数
1
解决办法
1877
查看次数

标签 统计

java ×2

authentication ×1

guice ×1

jaspic ×1

jsf ×1

security ×1