2011-11-03 90 views
2

我正在努力在glassfish V3中创建我的第一个安全领域。无法为JDBC领域加载组

我的问题是,它看起来像是出于某种原因,应用程序没有看到数据库中的一个coulmns,并且我的控制台一直告诉我存在语法错误。我认为让我烦恼的表是连接列(下面你会看到我的数据库实现)。

在这里,我将复制保持堆栈跟踪,所以你会看到什么是要去:

FINE:[网络安全]设置策略上下文ID:旧=无效ctxID = CHAPTER_x_12_Container_Managed_Authentication_and_Authorization/CHAPTER_x_12_Container_Managed_Authentication_and_Authorization FINE :[网络安全] hasUserDataPermission烫发: (javax.security.jacc.WebUserDataPermission GET)FINE:[网络安全] hasUserDataPermission isGranted:真正的FINE:SecurityContext的: setCurrentSecurityContext方法称为

FINE:[网络安全]策略上下文ID是: CHAPTER_x_12_Container_Managed_Authentication_and_Authorization/CHAPTER_x_12_Container_Managed_Authentication_and_Authorization FINE:[网络安全] hasUserDataPermission烫发: (javax.security.jacc.WebUserDataPermission/j_security_check POST) FINE:[网络安全] hasUserDataPermission isGranted:真FINE: 记录在用户[[email protected]]到境界:使用 JAAS模块DBRealm:jdbcRealm FINE:登录模块初始化:类 com.sun.enterprise.security.auth.login.JDBCLoginModule

SEVERE:SEC1111:无法为JDBC实际加载组m用户 [[email protected]]。 FINE:无法加载组 java.sql.SQLSyntaxErrorException:列'USER_GROUP'或者不在 FROM列表中的任何表中或出现在联接规范中,并且 在联接规范的范围之外或出现在HAVING 子句中并不在GROUP BY列表中。如果这是CREATE或ALTER TABLE语句,则'USER_GROUP'不是目标 表中的列。在在 org.apache.derby.client org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(未知 源)在 org.apache.derby.client.am.SqlException.getSQLException(未知 源)。 am.Connection.prepareStatement在 com.sun.gjc.spi.base.ConnectionHolder.prepareStatement(ConnectionHolder.java:535)(未知源) 在 com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40 .java:251) at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40.java:48) at com.sun.gjc.spi.ManagedConnection.prepareCachedStatement(Manag edConnection.java:880) 在 com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareStatement(ConnectionWrapper40.java:169) 在 com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm.findGroups( JDBCRealm.java:478) 在 com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm.authenticate(JDBCRealm.java:312) 在 com.sun.enterprise.security.auth.login.JDBCLoginModule。验证(JDBCLoginModule.java:72) at com.sun.enterprise.security.auth.login。PasswordLoginModule.authenticateUser(PasswordLoginModule.java:90) 处 sun.reflect com.sun.appserv.security.AppservPasswordLoginModule.login(AppservPasswordLoginModule.java:141) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)。 NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在java.lang.reflect.Method.invoke(Method.java:597)在 javax.security (LoginContext.java:769) at javax.security.auth.login.LoginContext.access $ 000 javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)返回页首返回页首返回页首返回页首返回页首返回页首返回页首 在 javax.security.auth.login.LoginContext.login(LoginContext.java:579) 在 com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:341) 在 COM .sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:199) 在 com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:152) 在 COM .sun.web.security.RealmAdapter.authent icate(RealmAdapter.java:479) 在 com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:418) 在 org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:264) 在 org.apache.catalina.authenticator.AuthenticatorBase.processSecurityCheck(AuthenticatorBase.java:1015) 在 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614) 在 org.apache.catalina .core.StandardPipeline.invoke(StandardPipeline.java:615) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESess ionLockingStandardPipeline.java:85) 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185) 在 org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226) 在 com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165) 在 的com.sun .grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693) at com.sun.grizzly.http.ProcessorTask.process( ProcessorTask.jav一:954) 在 com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170) 在 com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135) 在 的com.sun .grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102) 在 com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88) 在 com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java :76) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53) at com.sun.grizzly。SelectionKeyContextTask.call(SelectionKeyContextTask.java:57) at com.sun.grizzly.ContextTask.run(ContextTask.java:69)at com.sun.grizzly.util.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:330) at com.sun.grizzly.util.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:309) at java.lang.Thread.run(Thread.java:662)引起: org.apache.derby.client .am.SqlException:'USER_GROUP'列或者是 不在FROM表中的任何表中,或者在连接 规范中出现,并且超出了连接规范的范围,或者 出现在HAVING子句中,但不在GROUP BY中名单。如果这是 CREATE或ALTER TABLE语句,则'USER_GROUP'不是目标表中的列 。 at org.apache.derby.client.am.Statement.completeSqlca(Unknown Source)at org.apache.derby.client.net.NetStatementReply.parsePrepareError(Unknown Source)at org.apache.derby.client.net .NetStatementReply.parsePRPSQLSTTreply(未知 源)在 org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(未知 源)在 org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(未知 源)在 org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(未知 源)在 org.apache.derby.client.am.Statement.readPrepareDescribeOutput(未知 源)在 org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(未知 源)在 org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(未知 源)在 org.apache.derby.client .am.PreparedStatement.prepare(来源不明) 在org.apache.derby.client.am.Connection.prepareStatementX(未知 源)... 50多个

FINE:JAAS登录完成。 FINE:提交JAAS身份验证。 FINE: 密码登录成功为:[email protected] FINE: 权限检查设置SecurityContext FINE:设置安全性 上下文为用户:[email protected] FINE:[网络安全]策略 上下文ID是: CHAPTER_x_12_Container_Managed_Authentication_and_Authorization/CHAPTER_x_12_Container_Managed_Authentication_and_Authorization FINE:[网络安全] hasUserDataPermission烫发: (javax.security.jacc.WebUserDataPermission GET)FINE:[网络安全] hasUserDataPermission isGranted:真正的FINE:权限检查做 集SecurityContext的FINE:SecurityContext的: setCurrentSecurityContext 方法称为

只需再次检查一次,在这里我将粘贴我的域配置以及数据库和用于创建它的实体。

境界 enter image description here

数据库和实体 enter image description here

package entities; 

import java.io.Serializable; 

import javax.persistence.Column; 
import javax.persistence.Entity; 
import javax.persistence.Id; 
import javax.persistence.JoinColumn; 
import javax.persistence.JoinTable; 
import javax.persistence.ManyToOne; 
import javax.persistence.Table; 

@Entity 
@Table(name="USERS", schema="ADMIN") 
public class User implements Serializable { 

    private static final long serialVersionUID = -1244856316278032177L; 
    @Id 
    @Column(nullable = false) 
    private String userid; 

    @Column(nullable = false) 
    private String password; 

    @ManyToOne 
    @JoinTable(name="USER_GROUP",schema="ADMIN", joinColumns = @JoinColumn(name="userid", referencedColumnName="userid"), [email protected](name="groupid", referencedColumnName= "groupid")) 
    private Group group; 

    public String getUserid() { 
     return userid; 
    } 

    public void setUserid(String userid) { 
     this.userid = userid; 
    } 

    public String getPassword() { 
     return password; 
    } 

    public void setPassword(String password) { 
     this.password = password; 
    } 

    public Group getGroup() { 
     return group; 
    } 

    public void setGroup(Group group) { 
     this.group = group; 
    } 
} 

package entities; 

import java.io.Serializable; 
import java.util.Set; 

import javax.persistence.Column; 
import javax.persistence.Entity; 
import javax.persistence.Id; 
import javax.persistence.OneToMany; 
import javax.persistence.Table; 

@Entity 
@Table(name="GROUPS", schema="ADMIN") 
public class Group implements Serializable { 

    private static final long serialVersionUID = -7274308564659753174L; 
    @Id 
    @Column(nullable = false) 
    private String groupid; 

    @OneToMany(mappedBy="group") 
    private Set<User> users; 

    public String getGroupid() { 
     return groupid; 
    } 
    public void setGroupid(String groupid) { 
     this.groupid = groupid; 
    } 
    public Set<User> getUsers() { 
     return users; 
    } 
    public void setUsers(Set<User> users) { 
     this.users = users; 
    } 
} 

这就是控制台显示使用选项时,从实体生成表:

[EL Config]:持久类[类 entities.Group]的访问类型设置为[FIELD]。 [EL配置]:一对多映射元素[字段用户]的目标实体 (引用)类为 默认为:类entities.User。 [EL配置]:持久类[class entities.User]的访问类型 设置为[FIELD]。 [EL 配置]:多对一 映射元素[字段组]的目标实体(引用)类默认为:类 entities.Group。 [EL Config]:实体类 [class entities.Group]的别名默认为:Group。 [EL配置]:元素[字段组ID]的 列名默认为: GROUPID。 [EL配置]:实体类[类 entities.User]的别名默认为:用户。 [EL Config]:元素[field userid]的名称 默认为:USERID。 [EL 配置]:元素[字段密码]的列名称为 默认为:PASSWORD。 [EL警告]:PersistenceUnitInfo容器管理的身份验证和授权具有transactionType RESOURCE_LOCAL,因此jtaDataSource将被忽略[EL Info]: EclipseLink,版本:Eclipse持久性服务 - 2.0.1.v20100213-r6600 [EL Fine ]:检测到的供应商平台:org.eclipse.persistence.platform.database.JavaDBPlatform [EL配置]: 连接(25292190) - 连接(DatabaseLogin( platform => JavaDBPlatform user name =>“user”datasource URL => jdbc:derby:// localhost:1527/studydb; create = true“))[EL Config]: Connection :用户数据库: Apache Derby版本:10.5.3.0 - (802917)驱动程序:Apache Derby Network Client JDBC Driver版本:10.5.3.0 - (802917)[EL Config]: 连接(9740137) - 连接(DatabaseLogin( platform => JavaDBPlatform user name =>“user”datasource URL:> “jdbc:derby:// localhost:1527/studydb; create = true”))[EL Config]: Connection(23965177) - Connected: jdbc:derby:// localhost:1527/studydb;创建= true用户:用户数据库: Apache Derby版本:10.5.3.0 - (802917)驱动程序:Apache Derby 网络客户端JDBC驱动程序版本:10.5.3.0 - (802917)[EL信息]: file:/ C:/ learningJSF/CHAPTER x 12 Container Managed Authentication and Authorization/build/classes/_CHAPTER x 12 Container Managed Authentica Authorization_url = jdbc:derby:// localhost:1527/studydb; create = true_user = user 登录成功[EL Fine]:连接(18306082) - 修改表 ADMIN.USER_GROUP DROP CONSTRAINT USER_GROUP_groupid [EL Fine]: 连接(18306082) - ALTER TABLE ADMIN。USER_GROUP DROP CONSTRAINT USER_GROUP_userid [EL Fine]:连接(18306082) - DROP TABLE ADMIN.USER_GROUP [EL Fine]:连接(18306082) - CREATE TABLE ADMIN.USER_GROUP(userid VARCHAR(255)NOT NULL,groupid VARCHAR (EL): 连接(18306082) - DROP TABLE ADMIN.USERS [EL Fine]: 连接(18306082) - CREATE TABLE ADMIN.USERS(())(255) NOT NULL,PRIMARY KEY(userid,groupid) USERID VARCHAR(255) 连接(EL): 连接(18306082) - 连接(18306082) - 连接(18306082) --CREATE TABLE ADMIN.GROUPS(GROUPID VARCHAR(255) NOT NULL,PRIMARY KEY(GROUPID))[EL Fine]: Conne ction(18306082) - ALTER TABLE ADMIN.USER_GROUP ADD CONSTRAINT USER_GROUP_groupid FOREIGN KEY(groupid)REFERENCES ADMIN.GROUPS (groupid)[EL Fine]:连接(18306082) - 修改表 ADMIN.USER_GROUP ADD CONSTRAINT USER_GROUP_userid FOREIGN KEY (用户标识) 参考ADMIN.USERS(用户标识符)[EL配置]: 连接(18306082) - 断开连接[EL信息]: 文件:/ C:/ learningJSF/CHAPTER x 12 Container Managed Authentication and Authorization/build/class/_CHAPTER x 12 Container Managed Authentication and Authorization_url = jdbc:derby:// localhost:1527/studydb; create = true_user = user 注销成功[EL Config]:连接(25292190) - 断开连接[EL Config] :康涅狄格州挠度(23965177) - 断开

这是我配置的休息,也许它也有帮助:

enter image description hereenter image description here 生病真的很感谢你的帮助。

+0

哪个版本的Glassfish是这个?从堆栈跟踪中,我可以看到这不是v3.1.1。要查找版本 - 使用'asadmin start-domain domain1'启动Glassfish(如果domain1是您的域),然后运行'asadmin version'。 –

+0

@Vineet Reynolds版本是3.0.1 – sfrj

+1

这看起来很好乍一看。你有没有机会捕获使用的实际SQL查询?这个例外基本上是建议'SELECT USER_GROUP FROM ...'被使用,而它应该是'SELECT ... FROM USER_GROUP'。 – BalusC

回答

3

尝试在领域设置中键入ADMIN.USERS和ADMIN.USER_GROUP。它会告诉GlasshFish模式,表格的存储位置。

+0

我遇到从4.0迁移到4.1.1的问题http://stackoverflow.com/questions/40686737/migration-from-glassfish-4-0-to-glassfish-4-1-1-jdbc-realm-issue – Bikram