My project structure is as follows:
thereallm/ {ROOT}
{ROOT}/bin (hibernate.cfg.xml, log4j.properties)
{ROOT}/bin/com
{ROOT}/bin/com/reallm
{ROOT}/bin/com/reallm/ (class files, mapping documents)
{ROOT}/src (hibernate.cfg.xml, log4j.properties)
{ROOT}/src/com
{ROOT}/src/com/reallm
{ROOT}/src/com/reallm/ (source files, mapping documents)
The bin directory is Eclipse's output directory and everything in that tree matches everything in the src tree (except that .java. files are .class, of course).
It doesn't seem like this should make a difference, but I have tried running my test app from the actual .class file instead of the .java file and I get the same error. I am wondering if maybe Hibernate is traversing BOTH trees. Maybe?
I'm sorry for all the debugging output, I tried to format it to make it a little esier to read.
11:19:51,250 INFO Environment:464 - Hibernate 3.0.5
11:19:51,265 INFO Environment:477 - hibernate.properties not found
11:19:51,265 INFO Environment:510 - using CGLIB reflection optimizer
11:19:51,265 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
11:19:51,437 INFO Configuration:1110 - configuring from resource: /hibernate.cfg.xml
11:19:51,437 INFO Configuration:1081 - Configuration resource: /hibernate.cfg.xml
11:19:52,031 DEBUG DTDEntityResolver:42 - trying to locate
http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
11:19:52,031 DEBUG DTDEntityResolver:53 - found
http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath
11:19:52,125 DEBUG Configuration:1067 - connection.driver_class=com.mysql.jdbc.Driver
11:19:52,125 DEBUG Configuration:1067 - connection.password=password
11:19:52,125 DEBUG Configuration:1067 - connection.url=jdbc:mysql://localhost:3306/reallm
11:19:52,125 DEBUG Configuration:1067 - connection.username=bob
11:19:52,125 DEBUG Configuration:1067 - dialect=org.hibernate.dialect.MySQLDialect
11:19:52,125 DEBUG Configuration:1067 - connection.pool_size=1
11:19:52,125 DEBUG Configuration:1067 - show_sql=true
11:19:52,140 DEBUG Configuration:1262 - null<-org.dom4j.tree.DefaultAttribute@1ea0252 [Attribute: name resource value "com/reallm/NavMenu.hbm.xml"]
11:19:52,140 INFO Configuration:444 - Mapping resource: com/reallm/NavMenu.hbm.xml
11:19:52,140 DEBUG DTDEntityResolver:42 - trying to locate
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
11:19:52,140 DEBUG DTDEntityResolver:53 - found
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
11:19:52,421 INFO HbmBinder:260 - Mapping class: com.reallm.NavMenu -> navmenu
11:19:52,437 DEBUG HbmBinder:1099 - Mapped property: navMenuId -> NAVMENU_ID
11:19:52,468 DEBUG HbmBinder:1099 - Mapped property: title -> title
11:19:52,468 DEBUG HbmBinder:1099 - Mapped property: menus
11:19:52,468 DEBUG Configuration:1262 - null<-org.dom4j.tree.DefaultAttribute@b8c8e6 [Attribute: name resource value "com/reallm/Menu.hbm.xml"]
11:19:52,468 INFO Configuration:444 - Mapping resource: com/reallm/Menu.hbm.xml
11:19:52,484 DEBUG DTDEntityResolver:42 - trying to locate
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
11:19:52,484 DEBUG DTDEntityResolver:53 - found
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
11:19:52,562 INFO HbmBinder:260 - Mapping class: com.reallm.Menu -> menu
11:19:52,562 DEBUG HbmBinder:1099 - Mapped property: menuId -> MENU_ID
11:19:52,562 DEBUG HbmBinder:1099 - Mapped property: title -> title
11:19:52,562 DEBUG HbmBinder:1099 - Mapped property: subMenus
11:19:52,562 DEBUG Configuration:1262 - null<-org.dom4j.tree.DefaultAttribute@c980c9 [Attribute: name resource value "com/reallm/SubMenu.hbm.xml"]
11:19:52,562 INFO Configuration:444 - Mapping resource: com/reallm/SubMenu.hbm.xml
11:19:52,578 DEBUG DTDEntityResolver:42 - trying to locate
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
11:19:52,578 DEBUG DTDEntityResolver:53 - found
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
11:19:52,656 INFO HbmBinder:260 - Mapping class: com.reallm.SubMenu -> submenu
11:19:52,656 DEBUG HbmBinder:1099 - Mapped property: subMenuId -> SUBMENU_ID
11:19:52,656 DEBUG HbmBinder:1099 - Mapped property: title -> title
11:19:52,656 DEBUG HbmBinder:1099 - Mapped property: subMenuItems
11:19:52,656 DEBUG Configuration:1262 - null<-org.dom4j.tree.DefaultAttribute@2a6f16 [Attribute: name resource value "com/reallm/SubMenuItem.hbm.xml"]
11:19:52,656 INFO Configuration:444 - Mapping resource: com/reallm/SubMenuItem.hbm.xml
11:19:52,671 DEBUG DTDEntityResolver:42 - trying to locate
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
11:19:52,671 DEBUG DTDEntityResolver:53 - found
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
11:19:52,734 INFO HbmBinder:260 - Mapping class: com.reallm.SubMenuItem -> submenuitem
11:19:52,734 DEBUG HbmBinder:1099 - Mapped property: subMenuItemId -> SUBMENUITEM_ID
11:19:52,734 DEBUG HbmBinder:1099 - Mapped property: title -> title
11:19:52,734 DEBUG HbmBinder:1099 - Mapped property: role -> role
11:19:52,734 DEBUG HbmBinder:1099 - Mapped property: action -> action
11:19:52,734 INFO Configuration:1222 - Configured SessionFactory: null
11:19:52,734 DEBUG Configuration:1223 - properties: {java.class.path=C:\Documents and Settings\Bryan\workspace\thereallm\bin; more...}
11:19:52,765 INFO Configuration:464 - Mapping resource: com/reallm/SubMenuItem.hbm.xml
11:19:52,781 DEBUG DTDEntityResolver:42 - trying to locate
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
11:19:52,781 DEBUG DTDEntityResolver:53 - found
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
11:19:52,890 ERROR Configuration:365 - Could not compile the mapping document
org.hibernate.MappingException: duplicate import: com.reallm.SubMenuItem
at org.hibernate.cfg.Mappings.addImport(Mappings.java:105)
at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:541)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:488)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:234)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
at org.hibernate.cfg.Configuration.add(Configuration.java:362)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
at org.hibernate.cfg.Configuration.addClass(Configuration.java:468)
at com.reallm.NavMenuTest.main(NavMenuTest.java:15)
org.hibernate.MappingException: Error reading resource: com/reallm/SubMenuItem.hbm.xml
at org.hibernate.cfg.Configuration.addClass(Configuration.java:471)
at com.reallm.NavMenuTest.main(NavMenuTest.java:15)
Caused by: org.hibernate.MappingException: duplicate import: com.reallm.SubMenuItem
at org.hibernate.cfg.Mappings.addImport(Mappings.java:105)
at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:541)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:488)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:234)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
at org.hibernate.cfg.Configuration.add(Configuration.java:362)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
at org.hibernate.cfg.Configuration.addClass(Configuration.java:468)
... 1 more
Thanks again for your help max.
Bryan