无法为JDBC领域加载组 [英] Cannot load group for JDBC realm

查看:114
本文介绍了无法为JDBC领域加载组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



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



在这里,我将复制保持堆栈跟踪,以便您看到发生了什么:
$ b


FINE:[Web-Security]设置策略上下文ID:old = null 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的:$ b $称为b setCurrentSecurityContext方法



FINE:[网络安全]策略上下文ID为:
CHAPTER_x_12_Container_Managed_Authentication_and_Authorization / CHAPTER_x_12_Container_Managed_Authentication_and_Authorization
FINE:[网络安全] hasUserDataPermission perm:
(javax.security.jacc.WebUserDataPermission / j_securit y_check POST)
FINE:[Web-Security] hasUserDataPermission isGranted:true FINE:
将用户[administrator@gmail.com]登录到领域:DBRealm使用
JAAS模块:jdbcRealm FINE:登录模块初始化:class
com.sun.enterprise.security.auth.login.JDBCLoginModule



SEVERE:SEC1111:无法为JDBC领域用户加载组
[administrator@gmail.com]。 FINE:无法加载组
java.sql.SQLSyntaxErrorException:列'USER_GROUP'不在
中FROM列表中的任何表或出现在联接规范中且
超出加入规范或出现在HAVING
子句中,并且不在GROUP BY列表中。如果这是CREATE或ALTER
TABLE语句,那么'USER_GROUP'不是目标
表中的一列。 at
org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown
Source)at
org.apache.derby.client.am.SqlException.getSQLException(Unknown
源)
org.apache.derby.client.am.Connection.prepareStatement(未知源)

com.sun.gjc.spi.base.ConnectionHolder.prepareStatement(ConnectionHolder.java :535)
at
com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40.java:251)
at
com.sun.gjc.spi.jdbc40 .ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40.java:48)
。在
com.sun.gjc.spi.ManagedConnection.prepareCachedStatement(ManagedConnection.java:880)
。在
的com.sun .gjc.spi.jdbc40.ConnectionWrapper40.prepareStatement(ConnectionWrapper40.java:169)
。在
com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm.findGroups(JDBCRealm.java:478)
at
com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm.authenti cate(JDBCRealm.java:312)
at
com.sun.enterprise.security.auth.login.JDBCLoginModule.authenticate(JDBCLoginModule.java:72)
at
com。 sun.enterprise.security.auth.login.PasswordLoginModule.authenticateUser(PasswordLoginModule.java:90)
。在
com.sun.appserv.security.AppservPasswordLoginModule.login(AppservPasswordLoginModule.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25)
在java.lang.reflect.Method.invoke(Method.java:597)at
javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
at
javax.security.auth.login.LoginContext.access $ 000(LoginContext.java:186)
at
javax.security.auth.login.LoginContext $ 4.run(LoginContext .java:683)java.security.AccessCont中的
roll.doPrivileged(本地方法)
javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
at
javax.security.auth.login.LoginContext.login (LoginContext.java:579)
at
com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:341)
at
com.sun .enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:199)
。在
com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:152)
at
com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:479)
at
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)
at
org.apache.catali na.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)处的com.sun
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:615)

。 enterprise.web.WebPipeline.invoke(WebPipeline.java:97)维持在
org.apache
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
。 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)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at
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。 Java的:954)
。在
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
。在
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:135) DefaultProtocolChain.java:88)
。在
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
。在
com.sun.grizzly.ProtocolChainContextTask。 doCall(ProtocolChainContextTask.java:53)
。在
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
在com.sun.grizzly.ContextTask.run(ContextTask。
com.sun.grizzly.util.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:330)
at
com.sun.grizzly.util.AbstractThreadPool $ Worker。在java.lang.Thread.run运行(AbstractThreadPool.java:309)
(Threa d.java:662)导致:
org.apache.derby.client.am.SqlException:列'USER_GROUP'是
不在FROM列表中的任何表中,或者出现在连接$ b中$ b规范,并且超出了联接规范的范围,或
出现在HAVING子句中,并且不在GROUP BY列表中。如果这是
一个CREATE或ALTER TABLE语句,那么'USER_GROUP'不是目标表中的一列

org.apache.derby.client.am.Statement.completeSqlca(未知来源)在
org.apache.derby.client.net.NetStatementReply.parsePrepareError(未知
来源)at
org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(未知
来源)在
org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(未知
来源) at
org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown
Source)at
org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown
源)维持在
org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput
org.apache.derby.client.am.Statement.readPrepareDescribeOutput(未知
来源)(未知
源)在
org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(未知
源)在
org.apache.derby.client.am.PreparedStatement.prepare(未知来源)
at org.apache.derby.client.am.Connection.prepareStatementX(Unknown
Source)... 50 more



FINE:JAAS登录完成。 FINE:提交JAAS身份验证。 FINE:
密码登录成功:administrator@gmail.com FINE:
权限检查设置SecurityContext FINE:设置安全性
上下文为user:administrator@gmail.com FINE:[Web-安全]策略
上下文ID是:
FINE:[Web-Security] hasUserDataPermission perm:
(javax.security.jacc.WebUserDataPermission GET)FINE:[网络安全] [Web-Security] - 安全性]
hasUserDataPermission isGranted:true FINE:对
进行的权限检查set SecurityContext FINE:SecurityContext:setCurrentSecurityContext
方法称为

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



领域



>数据库和实体

 包实体; 

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)
私有字符串userid;

@Column(nullable = false)
私人字符串密码;

@ManyToOne
@JoinTable(NAME = USER_GROUP 模式= ADMIN,joinColumns = @JoinColumn(名称= 用户id,referencedColumnName = 用户id),inverseJoinColumns = @ JoinColumn(name =groupid,referencedColumnName =groupid))
私人群组;

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;







 包实体; 

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>用户;

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




$ b $ p
$ b

这是控制台在使用选项generate来自实体的表格:

lockquote
EL Config:设置持久化类[class
entities.Group]的访问类型到[FIELD]。 [EL配置]:一对多映射元素[字段用户]的目标实体
(引用)类默认为:class entities.User。 [EL配置]:持久类[class entities.User]的访问类型
被设置为[FIELD]。 [EL
Config]:多对一
映射元素[字段组]的目标实体(引用)类默认为:class
entities.Group。 [EL Config]:实体类
[class entities.Group]的别名默认为:Group。 [EL配置]:元素[field groupid]的
列名默认为:
GROUPID。 [EL Config]:实体类[class
entities.User]的别名默认为:User。 [EL配置]:元素[字段用户标识]的列
名称默认为:USERID。 [EL
Config]:元素[字段密码]的列名称是
,默认为:PASSWORD。 [EL警告]:PersistenceUnitInfo第12章
容器管理的身份验证和授权具有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 =>userdatasource URL =>
jdbc:derby:// localhost:1527 / studydb; create = true))[EL Config]:
连接(18306082) - 连接:
jdbc:derby:// localhost:1527 / studydb; create = true用户:user数据库:
Apache Derby版本:10.5.3.0 - (802917)驱动程序:Apache Derby
网络客户端JDBC驱动程序版本:10.5.3.0 - (802917)[EL配置]:
连接(9740137) - 连接(DatabaseLogin(
platform => JavaDBPlatform user name =>user datasource URL =>
$ jbc:derby:// localhost:1527 / studydb; create = true))[EL Config]:
连接(23965177) - 连接:
jdbc:derby:// localhost: 1527 / studydb; create = true用户:user数据库:
Apache Derby版本:10.5.3.0 - (802917)驱动程序:Apache Derby
网络客户端JDBC驱动程序版本:10.5.3.0 - (802917)[EL信息]:
文件:/ C:/ learningJSF / CHAPTER x 12容器管理认证和
授权/构建/类/ _CHAPTER x 12容器管理
认证和
Authorization_url = jdbc :derby:// localhost:1527 / studydb; create = true_user = user
登录成功[EL Fine]:连接(18306082) - ALTER TABLE
ADMIN.USER_GROUP DROP CONSTRAINT USER_GROUP_groupid [EL Fine]:
连接(18306082) - ALTER TABLE ADMIN.USER_GROUP DROP约束
USER_GROUP_userid [EL精细]:连接(18306082) - DROP TABLE
ADMIN.USER_GROUP [EL精细]:连接(18306082 ) - CREATE TABLE
ADMIN.USER_GROUP(userid VARCHAR(255)NOT NULL, groupid VARCHAR(255)
NOT NULL,PRIMARY KEY(userid,groupid))[EL Fine]:
Connection(18306082) - DROP TABLE ADMIN.USERS [EL Fine]:
连接(18306082) - CREATE TABLE ADMIN.USERS(USERID VARCHAR(255)
NOT NULL,PASSWORD VARCHAR(255)NOT NULL,PRIMARY KEY(USERID))[EL
Fine]:Connection(18306082) --DROP TABLE ADMIN.GROUPS [EL Fine]:
连接(18306082) - CREATE TABLE ADMIN.GROUPS(GROUPID VARCHAR(255)
NOT NULL,PRIMARY KEY(GROUPID))[EL Fine] :
连接(18306082) - ALTER TABLE ADMIN.USER_GROUP ADD约束
USER_GROUP_groupid外键(组识别符号)参考ADMIN.GROUPS
(组识别符号)[EL精细]:连接(18306082) - ALTER TABLE
ADMIN.USER_GROUP ADD CONSTRAINT USER_GROUP_userid FOREIGN KEY(userid)
REFERENCES ADMIN.USERS(userid)[EL Config]:
Connection(18306082) - disconnect [EL Info]:
文件:/ C:/ learningJSF / CHAPTER x 12 Container Managed Authentication and
Authorization / build / classes / _CHAPTE R x 12容器管理
认证和
Authorization_url = jdbc:derby:// localhost:1527 / studydb; create = true_user = user
注销成功[EL Config]:连接(25292190) - -disconnect [EL
Config]:Connection(23965177) - disconnect

这是我的其余配置,也许它也有帮助:



真的很感谢您的帮助。


Im being a few days struggling to create my first Security realm in glassfish V3.

My problem is that it looks like for some reason, the application does not see the one of the coulmns in the database, and my console keeps telling me that there is a syntax error. I think the table that is making me trouble is the join column(Below you will see my DB implementation).

Here i will copy the hold stack trace so you will see what is going on:

FINE: [Web-Security] Setting Policy Context ID: old = null ctxID = CHAPTER_x_12_Container_Managed_Authentication_and_Authorization/CHAPTER_x_12_Container_Managed_Authentication_and_Authorization FINE: [Web-Security] hasUserDataPermission perm: (javax.security.jacc.WebUserDataPermission GET) FINE: [Web-Security] hasUserDataPermission isGranted: true FINE: SecurityContext: setCurrentSecurityContext method called

FINE: [Web-Security] Policy Context ID was: CHAPTER_x_12_Container_Managed_Authentication_and_Authorization/CHAPTER_x_12_Container_Managed_Authentication_and_Authorization FINE: [Web-Security] hasUserDataPermission perm: (javax.security.jacc.WebUserDataPermission /j_security_check POST) FINE: [Web-Security] hasUserDataPermission isGranted: true FINE: Logging in user [administrator@gmail.com] into realm: DBRealm using JAAS module: jdbcRealm FINE: Login module initialized: class com.sun.enterprise.security.auth.login.JDBCLoginModule

SEVERE: SEC1111: Cannot load group for JDBC realm user [administrator@gmail.com]. FINE: Cannot load group java.sql.SQLSyntaxErrorException: Column 'USER_GROUP' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'USER_GROUP' is not a column in the target table. at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source) at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source) at com.sun.gjc.spi.base.ConnectionHolder.prepareStatement(ConnectionHolder.java:535) at 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(ManagedConnection.java:880) at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareStatement(ConnectionWrapper40.java:169) at com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm.findGroups(JDBCRealm.java:478) at com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm.authenticate(JDBCRealm.java:312) at com.sun.enterprise.security.auth.login.JDBCLoginModule.authenticate(JDBCLoginModule.java:72) at com.sun.enterprise.security.auth.login.PasswordLoginModule.authenticateUser(PasswordLoginModule.java:90) at com.sun.appserv.security.AppservPasswordLoginModule.login(AppservPasswordLoginModule.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769) at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186) at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680) at javax.security.auth.login.LoginContext.login(LoginContext.java:579) at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:341) at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:199) at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:152) at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:479) at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:418) at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:264) at org.apache.catalina.authenticator.AuthenticatorBase.processSecurityCheck(AuthenticatorBase.java:1015) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614) at 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(PESessionLockingStandardPipeline.java:85) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165) at 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.java:954) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88) at 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) Caused by: org.apache.derby.client.am.SqlException: Column 'USER_GROUP' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'USER_GROUP' is not a column in the target table. 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(Unknown Source) at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source) at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source) at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source) at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source) at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source) at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source) at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source) at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source) ... 50 more

FINE: JAAS login complete. FINE: JAAS authentication committed. FINE: Password login succeeded for : administrator@gmail.com FINE: permission check done to set SecurityContext FINE: Set security context as user: administrator@gmail.com FINE: [Web-Security] Policy Context ID was: CHAPTER_x_12_Container_Managed_Authentication_and_Authorization/CHAPTER_x_12_Container_Managed_Authentication_and_Authorization FINE: [Web-Security] hasUserDataPermission perm: (javax.security.jacc.WebUserDataPermission GET) FINE: [Web-Security] hasUserDataPermission isGranted: true FINE: permission check done to set SecurityContext FINE: SecurityContext: setCurrentSecurityContext method called

Just to check once more, here i will paste my realm configuration and also the database and the entities used to create it.

Realm

Database and entities

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"), inverseJoinColumns=@JoinColumn(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;
    }   
}

This is what the console displays when using the option generate Tables from entities:

[EL Config]: The access type for the persistent class [class entities.Group] is set to [FIELD]. [EL Config]: The target entity (reference) class for the one to many mapping element [field users] is being defaulted to: class entities.User. [EL Config]: The access type for the persistent class [class entities.User] is set to [FIELD]. [EL Config]: The target entity (reference) class for the many to one mapping element [field group] is being defaulted to: class entities.Group. [EL Config]: The alias name for the entity class [class entities.Group] is being defaulted to: Group. [EL Config]: The column name for element [field groupid] is being defaulted to: GROUPID. [EL Config]: The alias name for the entity class [class entities.User] is being defaulted to: User. [EL Config]: The column name for element [field userid] is being defaulted to: USERID. [EL Config]: The column name for element [field password] is being defaulted to: PASSWORD. [EL Warning]: PersistenceUnitInfo CHAPTER x 12 Container Managed Authentication and Authorization has transactionType RESOURCE_LOCAL and therefore jtaDataSource will be ignored [EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.0.1.v20100213-r6600 [EL Fine]: Detected Vendor platform: org.eclipse.persistence.platform.database.JavaDBPlatform [EL Config]: Connection(25292190)--connecting(DatabaseLogin( platform=>JavaDBPlatform user name=> "user" datasource URL=> "jdbc:derby://localhost:1527/studydb;create=true" )) [EL Config]: Connection(18306082)--Connected: jdbc:derby://localhost:1527/studydb;create=true User: user Database: Apache Derby Version: 10.5.3.0 - (802917) Driver: Apache Derby Network Client JDBC Driver Version: 10.5.3.0 - (802917) [EL Config]: Connection(9740137)--connecting(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;create=true User: user Database: Apache Derby Version: 10.5.3.0 - (802917) Driver: Apache Derby Network Client JDBC Driver Version: 10.5.3.0 - (802917) [EL Info]: file:/C:/learningJSF/CHAPTER x 12 Container Managed Authentication and Authorization/build/classes/_CHAPTER x 12 Container Managed Authentication and Authorization_url=jdbc:derby://localhost:1527/studydb;create=true_user=user login successful [EL Fine]: Connection(18306082)--ALTER TABLE ADMIN.USER_GROUP DROP CONSTRAINT USER_GROUP_groupid [EL Fine]: Connection(18306082)--ALTER TABLE ADMIN.USER_GROUP DROP CONSTRAINT USER_GROUP_userid [EL Fine]: Connection(18306082)--DROP TABLE ADMIN.USER_GROUP [EL Fine]: Connection(18306082)--CREATE TABLE ADMIN.USER_GROUP (userid VARCHAR(255) NOT NULL, groupid VARCHAR(255) NOT NULL, PRIMARY KEY (userid, groupid)) [EL Fine]: Connection(18306082)--DROP TABLE ADMIN.USERS [EL Fine]: Connection(18306082)--CREATE TABLE ADMIN.USERS (USERID VARCHAR(255) NOT NULL, PASSWORD VARCHAR(255) NOT NULL, PRIMARY KEY (USERID)) [EL Fine]: Connection(18306082)--DROP TABLE ADMIN.GROUPS [EL Fine]: Connection(18306082)--CREATE TABLE ADMIN.GROUPS (GROUPID VARCHAR(255) NOT NULL, PRIMARY KEY (GROUPID)) [EL Fine]: Connection(18306082)--ALTER TABLE ADMIN.USER_GROUP ADD CONSTRAINT USER_GROUP_groupid FOREIGN KEY (groupid) REFERENCES ADMIN.GROUPS (groupid) [EL Fine]: Connection(18306082)--ALTER TABLE ADMIN.USER_GROUP ADD CONSTRAINT USER_GROUP_userid FOREIGN KEY (userid) REFERENCES ADMIN.USERS (userid) [EL Config]: Connection(18306082)--disconnect [EL Info]: file:/C:/learningJSF/CHAPTER x 12 Container Managed Authentication and Authorization/build/classes/_CHAPTER x 12 Container Managed Authentication and Authorization_url=jdbc:derby://localhost:1527/studydb;create=true_user=user logout successful [EL Config]: Connection(25292190)--disconnect [EL Config]: Connection(23965177)--disconnect

And this is the rest of my configuration, maybe it helps too:

Ill really appreciate your help.

解决方案

Try to type ADMIN.USERS and ADMIN.USER_GROUP in realm settings. It will tell GlasshFish the schema, where your tables are stored.

这篇关于无法为JDBC领域加载组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆