-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: PropertyAccessException thrown from CGLIB
PostPosted: Tue Jan 04, 2005 2:34 pm 
Newbie

Joined: Tue Jan 04, 2005 2:23 pm
Posts: 3
Hibernate version:2.1.7c

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>

<class name="com.iit.ert.RealmUser" table="realm_user">

<composite-id unsaved-value="any">
<key-property
name="userName"
column="user_name"
type="string"
length="32"
/>
<key-property
name="userPass"
column="user_pass"
type="string"
length="32"
/>
</composite-id>


<!-- associations -->

</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Using Spring to handle Hibernate sessions. (i.e. getHibernateTemplate())


Full stack trace of any exception that occurs:
exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of com.iit.ert.RealmUser.?; nested exception is net.sf.hibernate.PropertyAccessException: exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of com.iit.ert.RealmUser.?" type="org.springframework.orm.hibernate.HibernateSystemException">org.springframework.orm.hibernate.HibernateSystemException: exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of com.iit.ert.RealmUser.?; nested exception is net.sf.hibernate.PropertyAccessException: exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of com.iit.ert.RealmUser.?
net.sf.hibernate.PropertyAccessException: exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of com.iit.ert.RealmUser.?
at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:193)
at net.sf.hibernate.type.ComponentType.nullSafeGetValues(ComponentType.java:164)
at net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:151)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:749)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:788)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:265)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:911)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:931)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:415)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2130)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2000)
at net.sf.hibernate.impl.SessionImpl.get(SessionImpl.java:1936)
at org.springframework.orm.hibernate.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:207)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:176)
at org.springframework.orm.hibernate.HibernateTemplate.get(HibernateTemplate.java:205)
at com.iit.ert.dao.hibernate.RealmUserDAOHibernate.getRealmUser(RealmUserDAOHibernate.java:10)
at com.iit.ert.dao.hibernate.RealmUserDAOHibernate.removeRealmUser(RealmUserDAOHibernate.java:26)
at com.iit.ert.dao.RealmUserDAOTest.testAddAndRemoveUser(RealmUserDAOTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Caused by: java.lang.ClassCastException
at com.iit.ert.RealmUser$$BulkBeanByCGLIB$$c08e4f57.getPropertyValues(&lt;generated&gt;)
at net.sf.cglib.beans.BulkBean.getPropertyValues(BulkBean.java:48)
at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:190)
... 35 more


Name and version of the database you are using:MySQL 4.0.13

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hello,

I have been getting a PropertyAccessException where the root cause seems to be a ClassCastException. The database table has two fields which are both strings, and there is not a primary key. When attempting to remove a user using my RealmUserDAOHibernate an exception is thrown when attempting to getPropertyValues. As you can see in the mapping for RealmUser the column types are string. In the database they are VARCHAR so the Types match. I have not been able to debug very well because I am using the Spring Framework to run hibernate and do not know how to set Configuration properties. If anyone can suggest the reason for these exceptions or know how to debug hibernate through Spring that would greatly help me.

Thank you,

Anthony Bargnesi

_________________
Anthony Bargnesi
Programmer / Analyst
Institute of Information Technology


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 04, 2005 6:24 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Where are you configuring hibernate (i.e. the dialect to use, the database username and password...)?
It's more than likely in an xml file that spring uses when it loads (application.xml?). Set the property (creating one if required) hibernate.cglib.use_reflection_optimizer to false. That should give you more detailed output.

Please post the code for com.iit.ert.RealmUser.


Top
 Profile  
 
 Post subject: Tried suggested debug...
PostPosted: Wed Jan 05, 2005 10:10 am 
Newbie

Joined: Tue Jan 04, 2005 2:23 pm
Posts: 3
I have tried to put hibernate.cglib.use_reflection_optimizer to false, but it doesn't seem to work. Here is the section I edited from spring's applicationContext.xml.

---------------------------
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="mappingResources">
<list>
<value>com/iit/ert/RealmUser.hbm.xml</value>
<value>com/iit/ert/RealmUserRole.hbm.xml</value>
<value>com/iit/ert/UdpLog.hbm.xml</value>
<value>com/iit/ert/Vehicle.hbm.xml</value>
<value>com/iit/ert/VehicleType.hbm.xml</value>
</list>
</property>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
</props>
</property>
</bean>
---------------------------

The RealmUser.java file is below:

---------------------------
package com.iit.ert;

public class RealmUser extends BaseObject {

/**
* identifier field
*/
private String userName;

/**
* identifier field
*/
private String userPass;

/**
* full constructor
*/
public RealmUser(String userName, String userPass) {
this.userName = userName;
this.userPass = userPass;
}

/**
* default constructor
*/
public RealmUser() {
userName = "username";
userPass = "userpass";
}

public String getUserName() {
return this.userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getUserPass() {
return this.userPass;
}

public void setUserPass(String userPass) {
this.userPass = userPass;
}
}

---------------------------

I will try to figure out how to get the debug to work to get more information about the exception.

Thanks,
Anthony Bargnesi

_________________
Anthony Bargnesi
Programmer / Analyst
Institute of Information Technology


Top
 Profile  
 
 Post subject: Debug
PostPosted: Wed Jan 05, 2005 10:36 am 
Newbie

Joined: Tue Jan 04, 2005 2:23 pm
Posts: 3
I configured a hibernate.properties file which Spring was able to read off the classpath. Here are the new detailed exception noting that userName property is causing the exception. Also I have provided the sql queries against my MySQL database.

----------------------------------
[junit] ------------- Standard Output ---------------
[junit] Hibernate: insert into realm_user (user_name, user_pass) values (?, ?)
[junit] Hibernate: insert into realm_user (user_name, user_pass) values (?, ?)
[junit] abargnesi
[junit] Hibernate: select realmuser0_.user_name as user_name0_, realmuser0_.user_pass as user_pass0_ from realm_user
realmuser0_ where realmuser0_.user_name=? and realmuser0_.user_pass=?
[junit] ------------- ---------------- ---------------
[junit] Testcase: testAddAndRemoveUser(com.iit.ert.dao.RealmUserDAOTest): Caused an ERROR
[junit] IllegalArgumentException occurred calling getter of com.iit.ert.RealmUser.userName; nested exception is net.
sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.iit.ert.RealmUser.userName

[junit] org.springframework.orm.hibernate.HibernateSystemException: IllegalArgumentException occurred calling getter
of com.iit.ert.RealmUser.userName; nested exception is net.sf.hibernate.PropertyAccessException: IllegalArgumentExcepti
on occurred calling getter of com.iit.ert.RealmUser.userName
[junit] net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.iit.ert.Re
almUser.userName
[junit] at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:110)
[junit] at net.sf.hibernate.type.ComponentType.getPropertyValue(ComponentType.java:179)
[junit] at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:205)
[junit] at net.sf.hibernate.type.ComponentType.nullSafeGetValues(ComponentType.java:164)
[junit] at net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:151)
[junit] at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:749)
[junit] at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:788)
[junit] at net.sf.hibernate.loader.Loader.doQuery(Loader.java:265)
[junit] at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
[junit] at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:911)
[junit] at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:931)
[junit] at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
[junit] at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
[junit] at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:415)
[junit] at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2130)
[junit] at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2000)
[junit] at net.sf.hibernate.impl.SessionImpl.get(SessionImpl.java:1936)
[junit] at org.springframework.orm.hibernate.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:207)
[junit] at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:176)
[junit] at org.springframework.orm.hibernate.HibernateTemplate.get(HibernateTemplate.java:205)
[junit] at com.iit.ert.dao.hibernate.RealmUserDAOHibernate.getRealmUser(RealmUserDAOHibernate.java:10)
[junit] at com.iit.ert.dao.hibernate.RealmUserDAOHibernate.removeRealmUser(RealmUserDAOHibernate.java:26)
[junit] at com.iit.ert.dao.RealmUserDAOTest.testAddAndRemoveUser(RealmUserDAOTest.java:41)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:96)
[junit] ... 37 more


[junit] Test com.iit.ert.dao.RealmUserDAOTest FAILED

BUILD FAILED
----------------------------------

_________________
Anthony Bargnesi
Programmer / Analyst
Institute of Information Technology


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 06, 2005 8:50 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
The part that interests me is:
Code:
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class

Is this class (RealmUser) proxied in you mappings file?
Is this class part of an inheritance heirarchy that is mapped?

Try to work out what the class is an instance of?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.