|
From: <jue...@we...> - 2003-08-22 11:48:36
|
The error message says "No property
[mappingResources] in class [class =
com.interface21.orm.hibernate.LocalSessionFactoryBean]", so your version =
of Spring does not support a "mappingResources" property on =
LocalSessionFactoryBean. Could it be that you've not updated to 0.9.1?
In 0.9.1, I've introduced that bean-style configuration of =
LocalSessionFactoryBean, as an alternative to Hibernate's standard =
hibernate.cfg.xml file. I consider the bean-style syntax nicer, but you =
can also define a hibernate.cfg.xml with a plain LocalSessionFactoryBean =
definition if you want:
<bean id=3D"exampleSessionFactory"
class=3D"com.interface21.orm.hibernate.LocalSessionFactoryBean"/>
This would simply load a hibernate.cfg.xml file from WEB-INF/classes, as =
specified by the Hibernate docs. You don't have the option of using a =
Spring-configured DataSource then, though.
I recommend to update to 0.9.1 and stick with the bean-style =
configuration :-)
Juergen
-----Original Message-----
From: Lars Fischer [mailto:lar...@gm...]
Sent: Thursday, August 21, 2003 12:41 PM
To: spr...@li...
Subject: [Springframework-developer] Hibernate and mapping resources
Still playing around with Spring and Hibernate ...
Data source works fine now, I just tested renaming the JNDI value to a =
wrong
name and I get
a very good error message.
Next step is to define something like
<bean id=3D"exampleSessionFactory"
class=3D"com.interface21.orm.hibernate.LocalSessionFactoryBean">
<property name=3D"mappingResources">
<list>
<value>Employee.hbm.xml</value>
</list>
</property>
<property name=3D"hibernateProperties">
<props>
<prop
key=3D"hibernate.dialect">net.sf.hibernate.dialect.PostgreSQLDialect</pro=
p>
<prop key=3D"hibernate.query.substitutions">true=3D1 =
false=3D0</prop>
<prop key=3D"hibernate.show_sql">true</prop>
</props>
</property>
<property name=3D"dataSource">
<ref bean=3D"exampleDataSource"/>
</property>
</bean>
'Employee.hbm.xml' is located in /WEB-INF/classes in the war file and =
points
to the Employee
class with the appropriate package name (like in the webapp-hibernate
skeleton).
I've tested this outside of Spring and can insert a new Employee into =
the
database.
When inside the war with Spring I get the following error message:
21.08.2003 12.29 Uhr CEST> <Warning> <HTTP> <BEA-101162> <User defined
listener com.interface21.web.context.ContextLoaderListener failed:
com.interface21.context.ApplicationContextException: Cannot load =
configuration: problem
instantiating or initializing beans; nested exception is:
com.interface21.beans.FatalBeanException: No property
[mappingResources] in class [class =
com.interface21.orm.hibernate.LocalSessionFactoryBean].>
I don't think this is very useful because it doesn't tell you exactly =
what
is wrong (like using
a wrong data source name).
Could this be a classpath issue ? In my example app without spring the
*.hbm.xml is located
in the same directory as the class.
Thanks for your help
Lars
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click =
here:http://www.vmware.com/wl/offer/358/0
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|