0

Even if I know that this is one of the most common question, i could'nt solve it by myself so I decidet to ask it.

Hibernate can not find my .hbm.xml files or entity classes. This is my file structure:enter image description here

and this is one of the hbm files:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jul 24, 2015 9:36:20 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
    <class name="org.kelime.dbModel.Kelime" table="kelime" catalog="distributedproject">
        <id name="kelime" type="string">
            <column name="Kelime" length="50" />
            <generator class="assigned" />
        </id>
    </class>
</hibernate-mapping>

and this is the error: org.hibernate.MappingNotFoundException: resource: org.kelime.dbModel.Kelime.hbm.xml not found at org.hibernate.cfg.Configuration.addResource(Configuration.java:724) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2102) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2074) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2054) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2007) at org.hibernate.cfg.Configuration.configure(Configuration.java:1922) at org.kelime.HibernateUtils.HibernateUtils.(HibernateUtils.java:15) at org.kelime.rest.AccountController.registerNewUser(AccountController.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source)

2 Answers 2

1

You probably need to tell maven to include those files. Try something like this in your pom.xml:

<build>
    <resources>
        <resource>
            <directory>src/main/java/</directory>
            <includes>
                <include>**/*.xml</include>
            </includes>
        </resource>
    </resources>
</build>
Sign up to request clarification or add additional context in comments.

3 Comments

is this ok ? <resource> <directory>src/main/java/</directory> <includes> <include>/org/kelime/dbModel/Kelime.hbm.xml</include> <include>/org/kelime/dbModel/Kullanici.hbm.xml</include> <include>/org/kelime/dbModel/Oyun.hbm.xml</include> </includes> </resource> I am asking a bit too much but am not familiar with java ee..
i am afraid it was not. Probably it is because of something else. One of my friends is helping me now and according to him the xml files are not included in the war file
can you check if the files are where they are expected in the target folder? or if they are copied somwhere else?
0

I and my friend have solved this problem.. I dont know why but for some reason it only works with this style of coding :

Configuration configuration = new Configuration(); configuration.addResource("./org/kelime/dbModel/Kelime.hbm.xml"); configuration.addResource("./org/kelime/dbModel/Kullanici.hbm.xml");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.