Jakarta ee Glassfish JDBCRealm和request.login()
我在使用域和request.login()记录用户时遇到一些问题,我发现了一些类似的问题,但没有一个能解决我的问题 Login.xhtmlJakarta ee Glassfish JDBCRealm和request.login(),jakarta-ee,glassfish,jdbcrealm,Jakarta Ee,Glassfish,Jdbcrealm,我在使用域和request.login()记录用户时遇到一些问题,我发现了一些类似的问题,但没有一个能解决我的问题 Login.xhtml <h:form> <h:outputLabel for="usernameInput"> #{bundle['login.email']}: </h:outputLabel> <h:inputTex
<h:form>
<h:outputLabel for="usernameInput">
#{bundle['login.email']}:
</h:outputLabel>
<h:inputText id="usernameInput" value="#{loginBean.email}"
required="true" />
<br />
<h:outputLabel for="passwordInput">
#{bundle['login.password']}:
</h:outputLabel>
<h:inputSecret id="passwordInput" value="#{loginBean.password}"
required="true" />
<br />
<h:commandButton value="${bundle['login.submit']}"
action="#{loginBean.login}" />
</h:form>
最后是glassfish引发的异常:
WARNING: No Principals mapped to Role [ADMIN].
INFO: Loading application [blueberrysoup] at [/blueberrysoup]
INFO: blueberrysoup was successfully deployed in 3,944 milliseconds.
WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception
WARNING: JSF1064: Unable to find or serve resource, /user/error.xhtml.
我想这里有个线索:
警告:没有映射到角色[ADMIN]的主体。
在web.xml文件中,您有:
<auth-constraint>
<role-name>ADMIN</role-name>
</auth-constraint>
修复了上述“打字错误”,是的,角色鬃毛在db中是正确的,但仍然没有成功。删除了“警告:没有映射到角色[ADMIN]的主体”。错误tho。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
<security-role-mapping>
<role-name>USERS</role-name>
<group-name>USERS</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ADMINS</role-name>
<group-name>ADMINS</group-name>
<principal-name>berry</principal-name>
</security-role-mapping>
</glassfish-web-app>
Realm Name : JDBCRealm
Class Name : com.sun.enterprise.security.ee.auth.realm.jdbc.JDBCRealm
JAAS Context:jdbcRealm
JNDI: mysql/blueberrysoup
User Table: user
User Name Column: email
Password Column: password
Group Table: groups
Group Name Column: role_name
Password Encryption Algorithm: MD5
Digest Algorithm: MD5
Charset: UTF-8
WARNING: No Principals mapped to Role [ADMIN].
INFO: Loading application [blueberrysoup] at [/blueberrysoup]
INFO: blueberrysoup was successfully deployed in 3,944 milliseconds.
WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception
WARNING: JSF1064: Unable to find or serve resource, /user/error.xhtml.
<auth-constraint>
<role-name>ADMIN</role-name>
</auth-constraint>
<security-role-mapping>
<role-name>ADMINS</role-name>
<group-name>ADMINS</group-name>