【问题标题】:org.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException occurred calling getter oforg.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException 发生调用 getter
【发布时间】:2011-12-07 19:04:05
【问题描述】:

我遇到了如下所示的问题

IllegalArgumentException occurred calling getter of org.springframework.security.oauth.examples.sparklr.models.Authority.user; 
nested exception is org.hibernate.PropertyAccessException: 
IllegalArgumentException occurred calling getter of org.springframework.security.oauth.examples.sparklr.models.Authority.user

我的休眠依赖是:

  • 休眠核心 3.3.2.GA
  • hibernate-annotations 3.4.0.GA
  • hibernate-commons-annotations 3.3.0.ga
  • 休眠实体管理器 3.4.0.GA
public class User implements UserDetails,Serializable {

    /** Serial Version UID. */
    private static final long serialVersionUID = -558892839L;

    /** Use a WeakHashMap so entries will be garbage collected once all entities 
        referring to a saved hash are garbage collected themselves. */
    private static final Map<Serializable, String> SAVED_HASHES =
        Collections.synchronizedMap(new WeakHashMap<Serializable, String>());

    /** hashCode temporary storage. */
    private volatile String hashCode;


    /** Field mapping. */
    private Boolean accountnonexpired;
    /** Field mapping. */
    private Boolean accountnonlocked;
    /** Field mapping. */
    private List<Authority> authorities = new ArrayList<Authority>();

    /** Field mapping. */
    private Boolean credentialsnonexpired;
    /** Field mapping. */
    private Boolean enabled;
    /** Field mapping. */
    private String id;
    /** Field mapping. */
    private String password;


       public class Authority implements Serializable ,GrantedAuthority {


    /** Serial Version UID. */
    private static final long serialVersionUID = -558892840L;

    /** Use a WeakHashMap so entries will be garbage collected once all entities 
        referring to a saved hash are garbage collected themselves. */
    private static final Map<Serializable, Serializable> SAVED_HASHES =
        Collections.synchronizedMap(new WeakHashMap<Serializable, Serializable>());

    /** hashCode temporary storage. */
    private volatile Serializable hashCode;


    /** Field mapping. */
    private String authority;
    /** Field mapping. */
    private User user;

如何解决,非常感谢

【问题讨论】:

  • 您没有向我们展示org.springframework.security.oauth.examples.sparklr.models.Authority 类,这似乎是异常的来源。
  • 我在我的权限类下面发帖,你能看看吗,谢谢

标签: hibernate spring-security


【解决方案1】:

根据您显示的代码,您没有 Authorityuser 属性的吸气剂。

尝试添加

public User getUser(){
    return this.user;
}

【讨论】:

  • 我有,但由于公司限制,我无法复制所有代码,它会阻止 @ManyToOne( cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY ) @org.hibernate.annotations .Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE}) @JoinColumn(name = "user", nullable = false ) @Id public User getUser() { return this.user; }
  • 我不确定休眠版本,可以吗?
  • 当我使用 hsqldb 2.0.0、hibernate-jmx 3.5.4-Final、hibernate-annotations 3.3.0.ga、hibernate-commons-annotations 3.3.0.ga、javassist 3.4 更改这些依赖项时.GA 我遇到以下错误 java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMapping 有接口 org.hibernate.cfg.Mappings 作为超类-------如果我添加 hibernate-entitymanager 3.4.0。 GA 其他错误是相同的 IllegalArgumentException 发生调用 --- 与第一个我不明白的 getter 相同
猜你喜欢
  • 2011-12-28
  • 1970-01-01
  • 1970-01-01
  • 2013-10-25
  • 2011-05-29
  • 2019-07-13
  • 1970-01-01
  • 2017-03-17
  • 1970-01-01
相关资源
最近更新 更多