The previous problem was fixed placing the mapping files in the java files' directory, named <project root dir>/src/SubsystemDesign/Didactics/Classes
Therefore, the main mapping configuration file (
hibernate.cfg.xml) looks like:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://localhost:8080/IPC-Implementation/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/ipcdb</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">password</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Mapping files -->
<mapping resource="src/Subsystem/Didactics/SubsystemDesign/humanuser.hbm.xml" />
<mapping resource="src/Subsystem/Didactics/SubsystemDesign/student.hbm.xml" />
<mapping resource="src/Subsystem/Didactics/SubsystemDesign/professor.hbm.xml" />
<mapping resource="src/Subsystem/Didactics/SubsystemDesign/systemmanager.hbm.xml" />
<mapping resource="src/Subsystem/Didactics/SubsystemDesign/course.hbm.xml" />
<mapping resource="src/Subsystem/Didactics/SubsystemDesign/courseoffering.hbm.xml" />
<mapping resource="src/Subsystem/Didactics/SubsystemDesign/enrolment.hbm.xml" />
</session-factory>
</hibernate-configuration>
The mapping files are:
humanuser.cfg.xmlCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="SubsystemDesign.Didactics.Classes">
<class name="HumanUser" table="humanuser">
<id name="emailAddress" type="string" column="emailaddress">
<generator class="assigned"/>
</id>
<property name="name">
<column name="name"/>
</property>
<property name="surname">
<column name="surname"/>
</property>
<property name="ID_Number">
<column name="idnumber"/>
</property>
<property name="enabled">
<column name="enabled"/>
</property>
</class>
</hibernate-mapping>
student.cfg.xmlCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="SubsystemDesign.Didactics.Classes">
<joined-subclass name="Student" extends="HumanUser" table="student">
<key column="emailaddress"/>
<set name="enrolments">
<key column="student" not-null="true"/>
<one-to-many class="Enrolment"/>
</set>
</joined-subclass>
</hibernate-mapping>
The code accessing Hibernate is the same posted previously, but now the
exception stack trace is:
Code:
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.ExceptionInInitializerError
java.lang.J9VMInternals.initialize(J9VMInternals.java:195)
java.lang.J9VMInternals.initialize(J9VMInternals.java:144)
SubsystemDesign.Didactics.Classes.StudentRegistrationController.createStudent(StudentRegistrationController.java:80)
SubsystemDesign.Didactics.Classes.AccountManagerDispatcher.createStudent(AccountManagerDispatcher.java:169)
SubsystemDesign.Didactics.Classes.StudentRegistrationServlet.doPost(StudentRegistrationServlet.java:96)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
org.hibernate.MappingException: Following superclasses referenced in extends not found: null[SubsystemDesign.Didactics.Classes]
org.hibernate.cfg.Configuration.processExtendsQueue(Configuration.java:1209)
org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1128)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
SubsystemDesign.Didactics.Classes.HumanUser.<clinit>(HumanUser.java:23)
java.lang.J9VMInternals.initializeImpl(Native Method)
java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
java.lang.J9VMInternals.initialize(J9VMInternals.java:144)
SubsystemDesign.Didactics.Classes.StudentRegistrationController.createStudent(StudentRegistrationController.java:80)
SubsystemDesign.Didactics.Classes.AccountManagerDispatcher.createStudent(AccountManagerDispatcher.java:169)
SubsystemDesign.Didactics.Classes.StudentRegistrationServlet.doPost(StudentRegistrationServlet.java:96)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Just to point out, this web application runs on Tomcat 5.5.26. The application server is started from Eclipse workbench and the classpath contains <project root dir>, <project root dir>/WebContent (I mean the directories in the workspace, not those ones on the server, may it be a problem) and the default libraries added by Eclipse.