cubesoft
cubesoft

Reputation: 3550

Eclipse dynamic web project - MappingNotFoundException

I have a Eclipse Dynamic Web Project which host a simple servlet and runs on Tomcat. I use Hibernate within - I have classes that map to database tables and hbm.xml files for them within my project. Everything works fine - I can use Hibernate from Servlet and modify database tables through classes. But now I want to move my "model" (Java classes for SQL tables and mapping files) to a separate Eclipse project so that I can use this "model" from other projects. After I specify a reference from my Web project to the "model" project, Eclipse can see the references and allows me using classes, but when I deploy and run the project on Tomcat, there are always errors like:

org.hibernate.MappingNotFoundException: resource: xxx/yyy/zzz/model/MyClassTable.hbm.xml not found

I suspect this is because I have to put classes for the model into WEB-INF directory, but I have no other idea how to do it than doing it manually. What is the correct way to configure Web Project in that case?

Upvotes: 3

Views: 2416

Answers (2)

SANDHYARAJ
SANDHYARAJ

Reputation: 21

That said, you are supposed to put class source files and any other resources like .hbm.xml files in the project's src folder. Eclispe will then "automagically" put them in the /WEB-INF/classes. Alternatively, if you want to detach the configuration files from the project, then just put it somewhere outside the project in a fixed path and add this path to the runtime classpath of the server

Upvotes: 0

BalusC
BalusC

Reputation: 1108742

It needs to be in /WEB-INF/classes, not in /WEB-INF.

That said, you are supposed to put class source files and any other resources like .hbm.xml files in the project's src folder. Eclispe will then "automagically" put them in the /WEB-INF/classes. Alternatively, if you want to detach the configuration files from the project, then just put it somewhere outside the project in a fixed path and add this path to the runtime classpath of the server. In Tomcat you can manage those paths in shared.loader property of /conf/catalina.properties.

Upvotes: 2

Related Questions