[Solved] Hibernate mapping - bean exception

Hello everyone,

i got an bean exception on the hibernate part and already search on the forum and count find any familiar cases. I have done this steps with my service LesionType and now i wanted to use with an DB :

  • build LesionType.hbm.xml
  • build the interface LesionTypeDAO
  • build the class HibernateLesionTypeDAO
  • build TestingApplicationContext for API and OMOD
  • build test-hibernate.cfg.xml for API and OMOD
  • add to the config.xml -> LesionType.hbm.xml
  • edit the moduleApplicationContext

Not sure if i missed one step… edit: all services work fine, the only thing not working is the access to DAO

Have you seen https://github.com/openmrs/openmrs-module-dispensing/commit/8a168d5ddb83ffba0a75b2f0854584a7b8b70796

1 Like

@meizzz would you share the stack trace? Use pastebin please. Another tip, it is usually more convenient to send the text instead of screenshot…

please make sure u always clearly attach the exception_log. use pasterbin to paste the whole log… thats wen we can have a clue on the possible causes

and can u specify which version f the openmrs platform your building against. from wat i see it may be a hibernate 3/hibernate 4 incompatibility…but paste the whole stack trace

sorry totally forgot to use pastebin, im using OpenMRS dist 2.7and trying to use hibernate 3 due to on hibernate 4 to save some time on starting the server. @tendomart im using that already @mozzy @owais.hussain my moduleApplicationContext , the server start up with liquibase here and on the page here
ps: i cant paste the fully server log it exceeds on nr of lines on the windows command line and paste bin max size any solution for that?

2.7 cannot be an openmrs paltform version , …thats a referenece app version.

r u using the SDK to create your module? u shud upgrade your openmrs platform version your building against, to be able to use hibernate 4 to use “sessionFactory” in your hibernate classes, otherwise sometimes its a bit challenging to use “DbsessionFactory” ,especially wen your not so familliar with configuring a new module.

look at this https://wiki.openmrs.org/display/docs/Supporting+Platform+2.0+and+below

The stack trace suggests that Lesion.hbm.xml cannot be found. Your hibernate mapping files should be in src/main/resources/

You can also try the following change in the target property in moduleApplicationContext:

<property name="target">
	<bean class="${project.parent.groupId}.${project.parent.artifactId}.api.impl.BodyRegionServiceImpl">
		<property name="dao">
			<bean class="${project.parent.groupId}.${project.parent.artifactId}.api.db.hibernate.HibernateBodyRegionDAO">
				<property name="sessionFactory">
					<ref bean="sessionFactory" />
				</property>
			</bean>
		</property>
	</bean>
</property>

The error is about missing “Lesion.hbm.xml”. You seem to only have “LesionType.hbm.xml”

i cleaned the cache folder and its working… thanks for your answers