hibernate annotations I get a MappingNotFoundException

K

kal

When I looked online it said that this was because I had the wrong
hibernate version, but I have the latest 3.2 release.

I can generate a database schema fine, So I assume that something else
is wrong


Here is the error I get and my Configuration file
Dec 30, 2006 10:25:17 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.0.cr5
Dec 30, 2006 10:25:17 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Dec 30, 2006 10:25:17 AM org.hibernate.cfg.Environment
buildBytecodeProvider
INFO: Bytecode provider name : cglib
Dec 30, 2006 10:25:17 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Dec 30, 2006 10:25:17 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Dec 30, 2006 10:25:17 AM org.hibernate.cfg.Configuration
getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Dec 30, 2006 10:25:18 AM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource:
com/stevens/server/domainmodel/Avalibility.java
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingNotFoundException: resource:
com/stevens/server/domainmodel/Avalibility.java not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:517)
at
org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1511)
at
org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1479)
at
org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1458)
at
org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1432)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1352)
at
com.stevens.server.commons.HibernateUtil.getSession(HibernateUtil.java:59)
at com.stevens.server.MemberManager.addMember(MemberManager.java:27)
at
com.stevens.server.test.MemberManagerTest.testAddMember(MemberManagerTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.textui.TestRunner.doRun(TestRunner.java:115)
at
com.intellij.rt.execution.junit.IdeaTestRunner.doRun(IdeaTestRunner.java:69)
at junit.textui.TestRunner.doRun(TestRunner.java:108)
at
com.intellij.rt.execution.junit.IdeaTestRunner.startRunnerWithArgs(IdeaTestRunner.java:24)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:118)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

java.lang.NullPointerException
at
com.stevens.server.commons.HibernateUtil.getSession(HibernateUtil.java:67)
at com.stevens.server.MemberManager.addMember(MemberManager.java:27)
at
com.stevens.server.test.MemberManagerTest.testAddMember(MemberManagerTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)


Process finished with exit code -1



And here is my configuration file persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">

<persistence-unit name="workshift">

<!-- A managed datasource provided by the application server, in
this
case the microcontainer, see caveatemptor-beans.xml
definition.
-->

<jta-data-source>java:/caveatemptorTestingDatasource</jta-data-source>


<jar-file>file:///E:/development/perforce/projects/server/workshifts/domainmodel/build/classes</jar-file>

<properties>
<!-- Only scan and detect annotated entities -->
<property name="hibernate.archive.autodetection"
value="class"/>

<!-- Only scan and detect hbm.xml files
<property name="hibernate.archive.autodetection"
value="hbm"/>
-->

<!-- SQL stdout logging
-->
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="true"/>
<property name="use_sql_comments" value="true"/>

<!-- We have a JTA data source...
<property name="hibernate.connection.driver_class"
value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.url"
value="jdbc:hsqldb:hsql://localhost"/>
<property name="hibernate.connection.username"
value="sa"/>

<property name="hibernate.c3p0.min_size"
value="5"/>
<property name="hibernate.c3p0.max_size"
value="20"/>
<property name="hibernate.c3p0.timeout"
value="300"/>
<property name="hibernate.c3p0.max_statements"
value="50"/>
<property name="hibernate.c3p0.idle_test_period"
value="3000"/>
-->

<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQL5InnoDBDialect"/>

<!-- Put the EntityManagerFactory into JNDI so we can use it
manually in tests -->
<property name="jboss.entity.manager.factory.jndi.name"

value="java:/EntityManagerFactories/caveatEmptorEMF"/>

<!-- Create the database schema when this test.persistence
unit is deployed, drop
it (clean the database) when it is undeployed
-->
<property name="hibernate.hbm2ddl.auto"
value="create-drop"/>

</properties>
</persistence-unit>

</persistence>
 
F

Filip Larsen

When I looked online it said that this was because I had the wrong
hibernate version, but I have the latest 3.2 release.

I can generate a database schema fine, So I assume that something else
is wrong

I believe Hibernate simply just can't find your domain class. Ensure
that it is on the class path when running your JUnit test cases and that
the class is named same in both the mapping configuration and in Java
(using "Avalibility" instead of "Availability" may also cause some
confusion to human readers and code maintainers, maybe that is was has
already happened).


Regards,
 
T

Tor Iver Wilhelmsen

kal said:
<jar-file>file:///E:/development/perforce/projects/server/workshifts/domainmodel/build/classes</jar-file>

Are you sure that's the right element to use? That's the path to a
directory, not to a jar file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top