• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

obscure message running schemaexport: Could not read mapping document from file:

 
Richard Gilling
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am quite new to using hibernate, and just trying to best configure my environment. I've used the search function, and have seen the previous post regarding the same message. It indicated the problem is with the dtd location. I am quite sure this isn't what's wrong in my case though.

The problem I have is that the error message that prints when I run the ant task is so uninformative, and I don't know where to find more details of the exception. Firstly, I found that if I run my app on the server with the hbm2ddl.auto property set to true, that even though this message appears in the debug logs when it exports the schema, on system out (websphere) it prints a more detailed message indicating what the problem is.

But when I run it as an ant task, all I get is this obscure message that it couldn't read the mapping file (see logs below). So my question is, I know 'something' is wrong with my mapping file, but how can I figure out what without relying on eyeballing the hbm file? How can I get more detail than what's provided below?



Log4J Configuration for ant follows:



Thanks,


[Edited to fix formatting - Paul Sturrock]
[ April 18, 2006: Message edited by: Paul Sturrock ]
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch!
Originally posted by Richard Gilling:
� on system out (websphere) it prints a more detailed message indicating what the problem is. � So my question is, I know 'something' is wrong with my mapping file, but how can I figure out what without relying on eyeballing the hbm file?

  • usually you have to look at something before you can determine what is wrong with it � or in fact to determine that there is nothing wrong with it. So posting the contents of Person.hbm.xml here may be a good place to start.
  • You haven't actually asserted in your post that there is a Person.hbm.xml file at C:\java\workspace\wcmFramework\JavaSource\com\racv\remote\forms\common. Is it there? If not, where is it? The location of the mapping files is configured in the hibernate.cfg.xml file (note the relative path).

  • Posting the "more detailed message" may make it easier for somebody here to help you � however two different systems may be experiencing different problems.

  •  
    Richard Gilling
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    There is definitely a Person.hbm.xml file under the directory. The problem isn't that this particular file is wrong, I know it is, but that's a different story. The problem is that I don't know how to figure out what's wrong with it via the schema export tool.

    If I run it on the server app with hbm2ddl-auto set to true, I catch the Hibernate exception from the first time I initialise the session. Then I log it to debug, and get the nice error message that you see below. This indicates to me where the problem is and I can go ahead and fix it or post it on a forum or whatever.

    But if I run the schema export, all I get is the message indicated in the previous post. So what I'm asking isn't for somebody to look at Person.hbm.xml and tell me how to fix it (I'll probably start a new thread for that soon ). I guess it's best to take a step back and define what I'm trying to do:

    1. Configure RAD 6.0 to work with hibernate efficiently.
    2. i.e Trying to determine a quick way to validate that my mapping files are correct and fix errors. To do this I decided I should write an ant script that triggers the schema generation, then use it's output to fix/repair errors.

    Is there a better way to accomplish this? Otherwise has anyone used the ant task for this validation type purpose, and how can I get a more detailed error report from it? Maybe it's something wrong with my log4j config or something?

    Example Output From Server:
    DEBUG org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings
    2006-04-18 23:47:45,688 [WebContainer : 1] DEBUG org.hibernate.cfg.Configuration - processing association property references
    2006-04-18 23:47:45,688 [WebContainer : 1] DEBUG org.hibernate.cfg.Configuration - processing foreign key constraints
    2006-04-18 23:47:45,688 [WebContainer : 1] DEBUG org.hibernate.cfg.Configuration - resolving reference to class: java.lang.Long
    2006-04-18 23:47:45,688 [WebContainer : 1] ERROR com.racv.remote.configuration.HibernateUtil - org.hibernate.MappingException: An association from the table UNF_PERSON refers to an unmapped class: java.lang.Long
    org.hibernate.MappingException: An association from the table UNF_PERSON refers to an unmapped class: java.lang.Long
    at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1134)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1052)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1168)
     
    Peer Reynders
    Bartender
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Have you taken a look at:
    Get schemaexport to run with ant - it may contain some tidbits of interest.

    Also you may want to try to set these settings in your log4j.properties file if they aren't already set that way:
    Hibernate 2


    Hibernate 3

    [ April 19, 2006: Message edited by: Peer Reynders ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic