-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate Mapping Jar can't be found.
PostPosted: Thu Nov 26, 2009 12:07 pm 
Newbie

Joined: Thu Nov 26, 2009 11:47 am
Posts: 1
Okay. After trying almost... everything, I give up and ask for help here.

The situation

Me and my team are developing this simple E-Learning application for school. We are developing quite some modules, and each of these modules have a couple of classes. So, currently, we're mapping all these files like this (in the hibernate.cfg.xml)

Code:
        <mapping package="system.model.forum" resource="system/model/forum/Forum.hbm.xml"/>
        <mapping class="system.model.user.User" resource="system/model/user/User.hbm.xml"/>
        <mapping package="system.model.exam" resource="system/model/exam/Exam.hbm.xml"/>


There is one problem. For each new 'module' we add, we need to modify the hibernate.cfg.xml file. But, for this, we need to have this file in the source control. The problem here is as follows:

A few members in the team use a MSSQL database, and a few members use a MySQL database. This is all good, but they would need to have their own hibernate.cfg.xml, otherwise the session-factory would not work. So, the idea was to pack all of these hibernate mapping files into one .jar file, and reference the hibernate.cfg.xml to that.

All said and done, I modified the ANT script with this simple packaging script:
Code:
    <target name="buildHibernateJars">
        <property name="store.jar.name" value="hib-mappings" />
        <property name="store.dir" value="src/java/system/model/mappings/jar" />
        <property name="store.jar" value="${store.dir}/${store.jar.name}.jar" />
        <echo message="Packaging all hibernate files into a single package" />
        <delete dir="${store.dir}" />
        <mkdir dir="${store.dir}" />
        <zip destfile="${store.jar}">
            <fileset dir="src/java/system/model/" includes="*/*.hbm.xml" />
        </zip>
    </target>


This creates a hib-mappings.jar in the 'src/java/system/model/mappings/jar' folder. This all works.
I also added a reference to the file, so it added the following entries in the ant script:

For the manifest target
Code:
<copyfiles files="${file.reference.hib-mappings.jar}" iftldtodir="${build.web.dir}/WEB-INF" manifestproperty="manifest.file.reference.hib-mappings.jar" todir="${dist.ear.dir}"/>


For the war target
Code:
<copyfiles files="${file.reference.hib-mappings.jar}" todir="${build.web.dir}/WEB-INF/lib"/>


All good, when I clean and build, the file is added to the WEB-INF\lib in the .war file (in dist) and in the build/web folder.

The problem here is. No matter what I try, the hibernate.cfg.xml just doesn't seem to be able to find the hib-mappings.jar.

I've tried the following methods (Methods users from IRC found for me)
Code:
<mapping jar="../lib/hib-mappings.jar"/>
<mapping jar="../../lib/hib-mappings.jar"/>
<mapping jar="hib-mappings.jar"/>


The only way it seems to work is like this:

Code:
<mapping jar="D:\\PDLWithoutSVN\\PDL\\build\\web\\WEB-INF\\lib\\hib-mappings.jar"/>


So, that indicates there is nothing wrong with the generated .jar file. But, I can't use this method, since everyone would check out their sources from a different folder.

Can anyone here enlighten me what's going wrong? I am pretty clueless after visiting every possible page on google about the issue :(

EDIT: In case someone asks, here's the full hibernate.cfg.xml for MSSQL:

Code:
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
        <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
        <property name="hibernate.connection.url">jdbc:sqlserver://localhost:56770;databaseName=HibernateDB</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.connection.password">password</property>
        <property name="hibernate.hbm2ddl.auto">update</property>
        <property name="hibernate.current_session_context_class">thread</property>
        <!--<mapping class="system.model.GlobalSettings" file="" jar="" package="" resource="system/model/GlobalSettings.hbm.xml"/>
        <mapping package="system.model.forum" resource="system/model/forum/Forum.hbm.xml"/>
        <mapping class="system.model.user.User" resource="system/model/user/User.hbm.xml"/>
        <mapping package="system.model.exam" resource="system/model/exam/Exam.hbm.xml"/>
        <mapping package="system.model.calendar" resource="system/model/calendar/Calendar.hbm.xml"/>-->
       
        <mapping jar="D:\\PDLWithoutSVN\\PDL\\build\\web\\WEB-INF\\lib\\hib-mappings.jar"/>
    </session-factory>


Greetings,

Mats


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.