-->
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.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: problem creating a session
PostPosted: Thu Jun 16, 2005 11:15 am 
Newbie

Joined: Thu Jun 16, 2005 10:51 am
Posts: 2
Versions:
Eclipse 3.1 RC2
JBossIDE 1.5.0 M1
HibernateConsole: 3.0.0 alpha 4

Hi everybody,

I created successfully a new configuration. That means the wizard also accepted the path to the HBM file, which is /jboss1/src/WEB-INF/classes/Article.hbm.xml.

Trying to create a session on this very configuration, a box with the following message appears:

Quote:
Problem while executing Create Session (org.hibernate.MappingException: Resource: Article.hbm.xml not found).


Somebody knows the reason for that? The path has been accepted when creating the configuration, but it seems that create session looks up the file without considerung the path.

Thanks,
Juerg


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 1:51 pm 
Newbie

Joined: Thu Jun 09, 2005 10:34 am
Posts: 10
Are you getting this error when you attempt to run your program, or when you select "Create SessionFactory" from the hibernate console?

Basically what this means is that your mapping file isn't on the class path. If this is occuring when you press run or debug, you'll need to edit your launch configuration and add /jboss1/src/WEB-INF/classes/ to the class path.

If this is occuring in the hibernate console on the other hand, I'm going to guess that you added your mapping files AND your hibernate configuration file to your console config. Remove the mapping files from the config, and make sure the classpath is set properly. As the wizard says, you need to give it the classpath of your database driver and the folder containing your mapping files, in this case /jboss1/src/WEB-INF/classes/.

Scott


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 5:06 am 
Newbie

Joined: Thu Jun 16, 2005 10:51 am
Posts: 2
Thanks a lot for the precise answer. Really helped.

-- Juerg


Top
 Profile  
 
 Post subject: Create SessionFactory - .hbm.xml not found.
PostPosted: Tue Jun 28, 2005 3:59 am 
Newbie

Joined: Sat Jan 15, 2005 9:17 am
Posts: 10
ScottWadden wrote:
Are you getting this error when you attempt to run your program, or when you select "Create SessionFactory" from the hibernate console?

Basically what this means is that your mapping file isn't on the class path. If this is occuring when you press run or debug, you'll need to edit your launch configuration and add /jboss1/src/WEB-INF/classes/ to the class path.

If this is occuring in the hibernate console on the other hand, I'm going to guess that you added your mapping files AND your hibernate configuration file to your console config. Remove the mapping files from the config, and make sure the classpath is set properly. As the wizard says, you need to give it the classpath of your database driver and the folder containing your mapping files, in this case /jboss1/src/WEB-INF/classes/.

Scott


Now..
You seem to be meaning that the "Mapping files" section of the Console Configuration Wizard should be left empty.

It's when I have the <mapping> elements in the hibernate configuration file that I get a similar error as reported by the O.P though.
When I comment out those parts, an error is reported about not being able to parse the hibernate configuration file.
With the <mapping> elements still off and the 'Mapping files' added to the wizard, same thing: error parsing the hibernate configuration file.

With 'Mapping files' added to console wizard and mapping elements in hibernate configuration file, back to square one: resource not found.
The console classpath contains the path to the POJO, and I believe that's where the mapping files are supposed to be as well...

Any pointers from someone here? How to solve the .hbm.xml file not found problem? Thanks.

Rico.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 5:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you are using <mapping resource="something"> you need to ensure that "something" is at the root of the classpath you have defined in the classpath of the console configuration

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 6:14 am 
Newbie

Joined: Sat Jan 15, 2005 9:17 am
Posts: 10
max wrote:
if you are using <mapping resource="something"> you need to ensure that "something" is at the root of the classpath you have defined in the classpath of the console configuration


Thanks max...

I had the folder containing "something" in the classpath together with a completely different folder containing the DB driver.
Moving the DB driver to the same folder as the mapping files, and removing its old folder from the classpath didn't help: still the mapping file is not found.

What do you mean by "at the root of the classpath" ?
There is such a thing as the root from which everything in the console classpath must stem?

Thanks for your input.

Rico.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 6:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it works like any other classpath....

if the console needs to resolve "org/your/path/to/res.hbm.xml" then that must be reachable from the root of the classpath - like with any normal classpath, no magic here.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 7:13 am 
Newbie

Joined: Sat Jan 15, 2005 9:17 am
Posts: 10
max wrote:
it works like any other classpath....

if the console needs to resolve "org/your/path/to/res.hbm.xml" then that must be reachable from the root of the classpath - like with any normal classpath, no magic here.


Well, the 'root of the classpath' then seems to be pretty much all of Eclipse's workspace because I have access to just about any folder under there to add to the Classpath, when I click "Add..."

I wanted to clarify whether 'at the root of the classpath' meant simply the same as 'in the classpath'.

The mapping file says
<mapping resource="folder1/folder2/ThisMap.hbm.xml" />

The classpath contains "/<project_name>/folder1/folder2/". positive.
There is no way to add the XML file itself; so I believe having the folder there is enough.
Or is the wizard being confused by the fact that there's no "/project_name/" part in the mapping file ?
After all, if I am allowed to add "/project1/folder1/" and "/project2/folder1" to the classpath, how would the wizard resolve the following:
<mapping resource="folder1/senior.hbm.xml"> ?

And why is the wizard unable to parse the XML file when I comment out the <mapping> element that it is so allergic to?
I've double-checked that the XML is valid, well-formed... some adjectives like that...

Rico.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 7:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, by root of the classpath I mean that the resource path must be in the classpath.

It sounds to me that you use your project root as an element in your classpath - the tool currently doesn't support (since i seriously think it is a very bad malpractice).

I guess i could add support for adding the project root to the classpath - make a jira for it if you really want it.

Until then as a workaround (a better way) you could move your files to a root that is not the project root. like <project name>/etc or <project name>/src or similar.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 12:03 pm 
Newbie

Joined: Sat Jan 15, 2005 9:17 am
Posts: 10
max wrote:
yes, by root of the classpath I mean that the resource path must be in the classpath.

It sounds to me that you use your project root as an element in your classpath - the tool currently doesn't support (since i seriously think it is a very bad malpractice).

I guess i could add support for adding the project root to the classpath - make a jira for it if you really want it.

Until then as a workaround (a better way) you could move your files to a root that is not the project root. like <project name>/etc or <project name>/src or similar.


All right.. Thanks. I'm seeing some kind of change here.
I've moved my files to a new Eclipse 'Source folder' /<project_name>/src

Now it's a MappingException reporting that it couldn't configure datastore from file filename1.hbm.xml. Not sure why this is so. That's a file it generated as an artifact..

Some help here, please? Thanks.

Rico.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 12:13 pm 
Newbie

Joined: Sat Jan 15, 2005 9:17 am
Posts: 10
Ras_Nas wrote:

Now it's a MappingException reporting that it couldn't configure datastore from file filename1.hbm.xml. Not sure why this is so. That's a file it generated as an artifact..

Some help here, please? Thanks.

Rico.


Great. That's the kind of thing that never happens until just after I click 'Submit'..
I removed all the mappings that had been added to the Console Config wizard "Mapping files" section and that seemed to do it. Wonder how this could be how it's supposed to be..
Anyway... why did I want to get this to work again? :P
ohh.. yeah... running queries, right..

Rico.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 1:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well - adding the mapping files via the cfg.xml AND the mapping files list of course result in duplicate mappings...which is an error....

Again, it behaves just like hibernate would do if you did it from code ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: entity class not found
PostPosted: Tue Jul 12, 2005 6:20 am 
Newbie

Joined: Fri Jun 17, 2005 4:26 am
Posts: 4
Location: Torino, Italy
Hello.

I followed same path as described in this thread: in the first time I didn't get loaded the hbm.xml file (wrong classpath). Now I menaged to get it working (the artifact generator takes correctly my hbm file and creates the java source in the right place).

But still the Hibernate console doesn't work. I get this error:

org.hibernate.MappingException: entity class not found: it.sysgroup.sysweb.login.User

I have this scenario (Eclipse 3.1 WTP 0.7 M5 with Hibernate tools 3.0.0alpha4):
- Hibernate configuration file: login-hibernate.cfg.xml in <project>/JavaSource/it/sysgroup/sysweb/login
- Mapping file: User.hbm.xml in <project>/JavaSource/it/sysgroup/sysweb/login
- class file User.java in <project>/JavaSource/it/sysgroup/sysweb/login

In the cfg.xml file:
<mapping resource="it/sysgroup/sysweb/login/User.hbm.xml" />

In the mapping file:
<hibernate-mapping package="it.sysgroup.sysweb.login">

In the console configuration I have no duplicate hbm files (the list is empty) and the classpath has two entries: the JDBC driver (PostgreSQL) and <project>/JavaSource.

I really tried everything I can think of, the result is the same: "entity class not found".

Any hint would be much appreciated, thank you.

Fabio Da Soghe


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 10:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
javasource seems to hint it includes java sources not java classes.

the console need a classpath, not your sourcepath

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Thanks and what about custom velocity templates?
PostPosted: Thu Jul 14, 2005 6:18 am 
Newbie

Joined: Fri Jun 17, 2005 4:26 am
Posts: 4
Location: Torino, Italy
Sorry for my delay.

Yes, you're right: now it works perfectly. Thank you very very much! :)

By the way, it seems to us the graphical plug-in was a bit limited in its flexibility: for example we were not able to get the DDL SQL files from our hbm definition files (it seems you can only refresh the live database).

For this reason we're finding more useful the Ant tasks (about which I found very helpful another thread of yours here, thank you again for your great support). Now we can write once an Hibernate configuration and get auto-generated source Java files and SQL scripts. What a great tool!

About this, we're thinking of customizing the velocity templates used for the automatic code generation: we want to have the generated classes decoupled from our customization code. Ideally the automatic generation should create a base class which we derive to get the actual hibernated class. This is useful for example to write equals() and hashcode() methods in the derived class and not have our code rewrited every time we execute the Ant script.

Is there already something like this? I know there is a plugin for Eclipse (Hibernate Synchronizer) which uses similar approach but we don't want to use all that class hierarchy with DAO classes and so on.

Best regards,

Fabio Da Soghe


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next

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.