jdbcrealm.invaliduserreason in jdbcrealm with glassfish 4.1.2 和 Java EE 7

问题描述

我在尝试登录我的 jdbcrealm 身份验证表单时遇到以下错误,有人知道它出了什么问题或如何配置错误日志以读取异常的所有跟踪吗?

Severe:   jdbcrealm.invaliduserreason
Warning:   WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login Failed: Security Exception

下面我展示数据

桌子

CREATE TABLE "sq"."pos_usuarios" (    
    "usuario" VARCHAR2(255) NOT NULL ENABLE,"clave" VARCHAR2(100) NOT NULL ENABLE,CONSTRAINT "POS_USUARIOS_PK" PRIMARY KEY ("usuario")
);

CREATE UNIQUE INDEX "sq"."POS_USUARIOS_PK" ON "sq"."pos_usuarios" ("usuario");


CREATE TABLE "sq"."pos_usuarios_grupos" (    
    "group_id" VARCHAR2(20) NOT NULL ENABLE,"usuario_id" VARCHAR2(255) NOT NULL ENABLE,CONSTRAINT "POS_USUARIOS_GRUPOS_PK" PRIMARY KEY ("group_id")
);

CREATE UNIQUE INDEX "sq"."POS_USUARIOS_GRUPOS_PK" ON "sq"."pos_usuarios_grupos" ("group_id");

我在以下选项中创建了我的领域

Glassfish 配置 > server-config > 安全 > 领域

Realm Name: jdbcRealm
JAAS Context: jdbcRealm
JNDI: jdbc/securityDatasource
User Table: pos_usuarios
User Name Column: usuario
Password Column: clave
Group Table: pos_usuarios_grupos
Group Name Column: grupo_id
Password Encryption Algorithm: SHA-256
Digest Algorithm: SHA-256
Charset: UTF-8

我的 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>
    <security-constraint>
        <display-name>Admin Pages</display-name>
        <web-resource-collection>
            <web-resource-name>Protected Admin Area</web-resource-name>
            <description></description>
            <url-pattern>/faces/admin/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
            <http-method>HEAD</http-method>
            <http-method>PUT</http-method>
            <http-method>OPTIONS</http-method>
            <http-method>TRACE</http-method>
            <http-method>DELETE</http-method>
        </web-resource-collection>
        <auth-constraint>
            <description/>
            <role-name>admin</role-name>
        </auth-constraint>
        <user-data-constraint>
            <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
    <security-constraint>
        <display-name>All Access</display-name>
        <web-resource-collection>
            <web-resource-name>None Protected User Area</web-resource-name>
            <description/>
            <url-pattern>/faces/users/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
            <http-method>HEAD</http-method>
            <http-method>PUT</http-method>
            <http-method>OPTIONS</http-method>
            <http-method>TRACE</http-method>
            <http-method>DELETE</http-method>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>jdbcRealm</realm-name>
        <form-login-config>
            <form-login-page>/faces/login.xhtml</form-login-page>
            <form-error-page>/faces/loginerror.xhtml</form-error-page>
        </form-login-config>
    </login-config>
</web-app>

我的 glassfish-web.xml

<?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>admin</role-name>
      <group-name>admin</group-name>
  </security-role-mapping>
  <security-role-mapping>
      <role-name>user</role-name>
      <group-name>user</group-name>
  </security-role-mapping>
  
  <parameter-encoding default-charset="UTF-8"/>

</glassfish-web-app>

还有我的 login.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Login</title>
    </h:head>
    <h:body>
        <p:panel header="Login From">
            <form method="POST" action="j_security_check">
                <p>
                    Usuario <input type="text" name="j_username" /><br />
                    Clave <input type="password" name="j_password" />
                </p>

                <p>
                    <input type="submit" value="Login" />
                    <input type="reset" value="Reset" />
                </p>
            </form>
        </p:panel>
    </h:body>
</html>

注意事项:

  • 我使用的是 Glassfish 4.1.2 和 Java EE 7
  • 我从 NetBeans 12.2 运行服务器
  • 应用打包在耳朵里

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...