-->
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: Configuration error when class name ends with Group
PostPosted: Tue Nov 11, 2003 11:09 am 
Newbie

Joined: Tue Nov 11, 2003 10:50 am
Posts: 3
I am having a problem with a simple persistent class named 'AssetGroup', but the problem disappears if I rename the class. The class just has a primary key (Long) and a 'name' property (String). The .hbm.xml is as follows:

<hibernate-mapping schema="test">
<class name="com.phocis.sdx.server.domain.AssetGroup" table="asset_group">
<id name="id" type="long">
<generator class="native"/>
</id>
<property name="name" type="java.lang.String" column="name" not-null="true" length="200"/>
</class>
</hibernate-mapping>

I am deploying this in a web app and initialising in the servlet's init() method using:

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

When I deploy this I get the following exception:

net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property name in class com.phocis.sdx.server.domain.AssetGroup
at net.sf.hibernate.util.ReflectHelper.getSetter(ReflectHelper.java:151)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:572)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:665)
at net.sf.hibernate.persister.PersisterFactory.create(PersisterFactory.java:29)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:207)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627)
...etc...

However, the bizarre thing is that if I rename the class to 'AssetTroup' (and change the class name in the .hbm.xml) it successfully deploys. Is this a known bug? Is there any particular reason why I shouldn't be able to have a class name which ends with 'Group'?

I'm using Hibernate 2.0.3.

Thanks,
Al.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 11, 2003 11:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is not a bug in Hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 11, 2003 11:47 am 
Newbie

Joined: Tue Nov 11, 2003 10:50 am
Posts: 3
Hello Gavin,

I'm sorry, I agree it's not a bug - I tried changing the name of a class in an independent test app to AssetGroup and it worked.

However, I'm still left with the problem in my web app, so can you think of anything that could cause this behaviour? As I said, if I rename the class to something else then it works. I thought it might be due to a stale AssetGroup class somewhere on the class path but I've tried a clean JBoss domain and ensured my build is completely clean, so I'm confident it's not that.

Any ideas would be much appreciated.

Thanks,
Al.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 11, 2003 2:48 pm 
Newbie

Joined: Tue Nov 11, 2003 10:50 am
Posts: 3
I fixed the problem.

Basically it turned out to be a class loading problem. My persistent classes are in a JAR which is included in a WAR under WEB-INF/lib. However in JBoss, the Jetty configuration has Servlet 2.3 class loading compliance disabled by default (Java2ClassLoadingCompliance = true), which meant WEB-INF/lib was not loaded first. I changed this to false (i.e. Servlet 2.3 class loading) and it now works fine.

I still don't understand why changing the class name caused it to succeed though. I was restarting JBoss each time I changed the class name. Oh well.

Al.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 11, 2003 2:59 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 1:24 pm
Posts: 213
Location: Richardson, TX
Quote:
I still don't understand why changing the class name caused it to succeed though.


Do you have an identically named class elsewhere in the classpath?


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.