-->
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.  [ 10 posts ] 
Author Message
 Post subject: MappingException - xml not found
PostPosted: Mon Nov 14, 2005 5:32 am 
Newbie

Joined: Mon Nov 14, 2005 5:17 am
Posts: 13
Hey,

I'm very new to Hibernate, just finished installing HibernateTools for Eclipse and I have a problem which seems to be very basic ;)

I followed the FLASH presentation of how to configure the Tools, I've created a new Configuration/Console Configuration and generated the XMLs/Classes of an existing DB,

My directory structure is:
dev-proj/test/hibernate/src - hibernate.hbm.xml
dev-proj/test/hibernate/src/org/revenge - all generated POJO entities/XMLs

When opening one of the generated classes it seems that Hibernate generated the classes with 'package org.revenge' which seems not to exist...
I assume the problem starts here unless I need to move 'org/revenge' to the root of the project?

In the configuration file, the resources are mapped like that:
<mapping resource="org/revenge/Profile.hbm.xml" />


When trying to click on 'Create SessionFactory' through the Hibernate Configurations I recieve the following error:


Code:
Error while fetching children

Reason:
org.hibernate.MappingException: Resource: org/revenge/Profile.hbm.xml not found


This is the full exception error message:

Code:
org.hibernate.MappingException: Resource: org/revenge/Profile.hbm.xml not found
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:470)
   at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1414)
   at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1382)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1363)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1339)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1293)
   at org.hibernate.console.ConsoleConfiguration.loadConfigurationXML(Unknown Source)
   at org.hibernate.console.ConsoleConfiguration.access$0(Unknown Source)
   at org.hibernate.console.ConsoleConfiguration$1.execute(Unknown Source)
   at org.hibernate.console.execution.DefaultExecutionContext.execute(Unknown Source)
   at org.hibernate.console.ConsoleConfiguration.buildWith(Unknown Source)
   at org.hibernate.console.ConsoleConfiguration.build(Unknown Source)
   at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(Unknown Source)
   at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(Unknown Source)
   at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:192)
   at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)



Help would be very appriciated :)

Thanks,
Trouby.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 9:43 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hi,

there are two ways to specify a classpath here.
I am not sure which one is the best.


1. like in:

Code:
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask">
  <classpath refid="myclasspath" />
</taskdef>


2. like in:

Code:
<target name="myTarget" >
   <hibernatetool destdir="${IfbHibernate.dir}/exp">
      <classpath>
         <path location="myclasspath"/>
      </classpath>
      <jdbcconfiguration
            configurationfile="myPath/hibernate.cfg.xml"/>
      <hbm2hbmxml/>
   </hibernatetool>   
</target>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 12:26 pm 
Newbie

Joined: Mon Nov 14, 2005 5:17 am
Posts: 13
Hey,

Thanks for the answer,


I assume these directives go to hibernate.hdm.xml?

Also, what about the classes themselfs that are generated with a package name that does not exist?

I mean, even in the example(I followed the exact pathes of the example), it seems that there is a 'src' directory under the root directory of the project,

the output folder of the generated classes/xmls goes to 'src' while the specified package name is not 'src.org.revenge' but 'org.revenge',

After file generation process completes, when I open one of the entity classes, it seems that the generated package is 'org.revenge' which does not exist...

What exactly do I do wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 9:22 am 
Newbie

Joined: Mon Nov 14, 2005 5:17 am
Posts: 13
HELP? anyone? :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 9:44 am 
Newbie

Joined: Mon Oct 03, 2005 8:27 am
Posts: 13
Try this...
double click on the configuration you have created.
In the classpath section, add the root of your generated classes. I've put here the classes directory in which are all the classes the reveng has created.

Let me know!!!

-

Please don't forget to credit ,-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 10:02 am 
Newbie

Joined: Mon Nov 14, 2005 5:17 am
Posts: 13
Nope, doesn't help, :(


In the Configuration file, If no path/package name was specified, such as:
Code:
<mapping resource="Profile.hbm.xml" />


Aint that means that the file will be looked at the same directory where Hibernate's conf file lives?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 10:22 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Can you post your ant script ?
And perhaps a description of your directories ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 10:23 am 
Newbie

Joined: Mon Oct 03, 2005 8:27 am
Posts: 13
It's very strange.
I've created my configuration simply specifying my src dir as Output directory, and the package com.bla.bla.bla as the package which doesn't exist yet!

-

Please don't forget to credit ,-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 3:04 pm 
Newbie

Joined: Mon Nov 14, 2005 5:17 am
Posts: 13
Well, this is my ant script,
It works just fine if I run by 'ant', but Eclipse keeps complaining that the mapping xmls are not found.



Code:
<project name="hibernate-test" default="compile" basedir=".">

    <property name="sourcedir" value="${basedir}/src"/>
    <property name="targetdir" value="${basedir}/bin"/>
    <property name="librarydir" value="${basedir}/lib"/>

    <path id="libraries">
        <fileset dir="${librarydir}">
            <include name="*.jar"/>
        </fileset>
    </path>

    <target name="clean">
        <delete dir="${targetdir}"/>
        <mkdir dir="${targetdir}"/>
    </target>

    <target name="compile" depends="clean, copy-resources">
      <javac srcdir="${sourcedir}"
             destdir="${targetdir}"
             classpathref="libraries"/>
    </target>

    <target name="copy-resources">
        <copy todir="${targetdir}">
            <fileset dir="${sourcedir}">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>



<target name="run" depends="compile">
    <java fork="true" classname="EventManager" classpathref="libraries">
        <classpath path="${targetdir}"/>
        <arg value="${action}"/>
    </java>
</target>

</project>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 4:05 pm 
Newbie

Joined: Mon Nov 14, 2005 5:17 am
Posts: 13
Heh, damn, I was missing the path to the POJO files under the 'classPath' of Hibernate's console configuration.

Cheers.


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

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.