-->
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.  [ 7 posts ] 
Author Message
 Post subject: SchemaExport - Could not compile the mapping document
PostPosted: Thu Dec 11, 2003 7:33 pm 
Newbie

Joined: Thu Dec 11, 2003 5:48 pm
Posts: 3
Using Hibernate 2.1 Final, Hibernate Extensions 2.0.2, MySQL 4.0.16, Connector 3.09 and generated Foo.java from Foo.hbm.xml with hbm2java.

SchemaExport produced the following error message:

C:\hibernate\bin>SchemaExport Foo.hbm.xml Foo.java
23:26:41,609 INFO Environment:432 - Hibernate 2.1 final
23:26:41,640 INFO Environment:466 - loaded properties from resource hibernate.p
roperties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.c
glib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibern
ate.cache.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect
=net.sf.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=tr
ue, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0,
yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.userna
me=root, hibernate.connection.url=jdbc:mysql://localhost/test, hibernate.connect
ion.password=, hibernate.connection.pool_size=1}
23:26:41,671 INFO Environment:480 - using java.io streams to persist binary typ
es
23:26:41,671 INFO Environment:481 - using CGLIB reflection optimizer
23:26:41,687 INFO Configuration:164 - Mapping file: Foo.hbm.xml
23:26:44,468 ERROR Configuration:248 - Could not compile the mapping document
net.sf.hibernate.MappingException: persistent class [Foo] not found
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:207)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1167)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:245)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:167)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:282
)
Caused by: java.lang.ClassNotFoundException: Foo
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:7
5)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:78)
... 5 more
23:26:44,546 ERROR Configuration:172 - Could not configure datastore from file:
Foo.hbm.xml
net.sf.hibernate.MappingException: persistent class [Foo] not found
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:207)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1167)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:245)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:167)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:282
)
Caused by: java.lang.ClassNotFoundException: Foo
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:7
5)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:78)
... 5 more
23:26:44,609 ERROR SchemaExport:303 - Error creating schema
net.sf.hibernate.MappingException: net.sf.hibernate.MappingException: persistent
class [Foo] not found
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:173)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:282
)
Caused by: net.sf.hibernate.MappingException: persistent class [Foo] not found
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:207)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1167)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:245)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:167)
... 1 more
Caused by: java.lang.ClassNotFoundException: Foo
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:7
5)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:78)
... 5 more
net.sf.hibernate.MappingException: net.sf.hibernate.MappingException: persistent
class [Foo] not found
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:173)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:282
)
Caused by: net.sf.hibernate.MappingException: persistent class [Foo] not found
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:207)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1167)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:245)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:167)
... 1 more
Caused by: java.lang.ClassNotFoundException: Foo
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:7
5)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:78)
... 5 more

Anything wrong with my configuration? Or a bug?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 7:49 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh - have you compiled Foo.java and put it in the classpath of schemaexport ? ....hibernate needs the class to e.g. perform the schemaexport...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 8:04 pm 
Newbie

Joined: Thu Dec 11, 2003 5:48 pm
Posts: 3
You are a star!

The reference "19.1.2. Running the tool" wasn't very specific on that.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 28, 2003 11:49 am 
Newbie

Joined: Wed Dec 24, 2003 11:19 pm
Posts: 1
Location: New Jersey, USA
Actually, in my case, I did compile the needed class. Here are the first few lines of output from my schemaexport ant task (mainly to show that the .class file is in the classpath):

// --- start of build script output snippet

[echo] Path is C:\java\bin\eclipse-2.1.2\workspace\MCSTS\lib\hibernate\cglib2.jar;C:\java\bin\eclipse-2.1.2\workspa
ce\MCSTS\lib\hibernate\commons-collections.jar;C:\java\bin\eclipse-2.1.2\workspace\MCSTS\lib\hibernate\commons-logging.j
ar;C:\java\bin\eclipse-2.1.2\workspace\MCSTS\lib\hibernate\dom4j.jar;C:\java\bin\eclipse-2.1.2\workspace\MCSTS\lib\hiber
nate\ehcache.jar;C:\java\bin\eclipse-2.1.2\workspace\MCSTS\lib\hibernate\hibernate2.jar;C:\java\bin\eclipse-2.1.2\worksp
ace\MCSTS\lib\hibernate\odmg.jar;C:\java\bin\eclipse-2.1.2\workspace\MCSTS\build\com\mycompany\mcsts\model\hibernate\
MailingAddress.class
[schemaexport] Dec 28, 2003 10:39:45 AM net.sf.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: Hibernate 2.1.1
[schemaexport] Dec 28, 2003 10:39:45 AM net.sf.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: loaded properties from resource hibernate.properties: {hibernate.connection.username=mcsts, hiberna
te.connection.password=mcsts, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.
SQLServerDialect, hibernate.connection.url=jdbc:microsoft:sqlserver://myhost:1433, hibernate.connection.driver_class=c
om.microsoft.jdbc.sqlserver.SQLServerDriver}
[schemaexport] Dec 28, 2003 10:39:45 AM net.sf.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: using CGLIB reflection optimizer
[schemaexport] Dec 28, 2003 10:39:45 AM net.sf.hibernate.cfg.Configuration addFile
[schemaexport] INFO: Mapping file: C:\java\bin\eclipse-2.1.2\workspace\MCSTS\sar\hibernate\com\mycompany\mcsts\model\
hibernate\MailingAddress.hbm.xml
[schemaexport] Dec 28, 2003 10:39:45 AM net.sf.hibernate.cfg.Configuration add
[color=red][b][schemaexport] SEVERE: Could not compile the mapping document
[schemaexport] net.sf.hibernate.MappingException: persistent class [com.mycompany.mcsts.model.hibernate.MailingAddres
s] not found[/b][/color]

// --- end of build script output snippet

And here is the relevant portion of my ant build script:

// --- start of ant build script snippet
<path id="hibernate.path">
<fileset dir="${lib.home}/hibernate">
<include name="*.jar"/>
</fileset>
<fileset dir="${build.home}">
<include name="**/hibernate/*.class"/>
</fileset>
</path>

<target name="schemaexport" description="Export the schema to the database">
<pathconvert targetos="windows" property="windowsPath" refid="hibernate.path"/>
<echo>Path is ${windowsPath}</echo>
<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="hibernate.path"/>
<schemaexport
properties="hibernate.properties"
quiet="no"
text="no"
drop="no"
delimiter=";"
output="schema-export.sql">
<fileset dir="${hibernate.sar}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>

// --- end of ant build script snippet

I'm using Hibernate 2.1.1 with JBoss 3.2.3, SQL Server 2000 SP3 with JDBC driver SP2 from Microsoft. Is there anything else I missed? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 4:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I promise you - the class com.mycompany.mcsts.model.hibernate.MailingAddress is NOT on your classpath - otherwise that error would not occur!

I can see your path contains C:\java\bin\eclipse-2.1.2\workspace\MCSTS\build\com\mycompany\mcsts\model\hibernate\
MailingAddress.class - this is NOT the correct way to have classes on the path. it should more be something like:
C:\java\bin\eclipse-2.1.2\workspace\MCSTS\build

And your ant path id="hibernate.path" refers to concrete *.class's instead of adding directories. This is basic java stuff - please go check out something like http://www.kevinboone.com/classpath.html

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: ClassNotFoundException using packages and xdoclet tags
PostPosted: Wed Jan 21, 2004 11:37 pm 
Beginner
Beginner

Joined: Wed Jan 21, 2004 10:52 pm
Posts: 27
Location: Santa Cruz do Sul - RS - Brazil
Hi all, sorry my bad english,
I look the thread, but my problem "persists".

I trying to create a simple project that contains 2 classes (in package) that represents a one-to-many relationship (one people have many cars).

My java files are in:
C:\TRABALHO\Auctions\org\hibernate\auctions

My java sources are declared as:
Code:
package org.hibernate.auction;
import java.util.*;
/**
* Created on Dec 18, 2003
* @author mrack
* @hibernate.class
*/
public class People extends Persistent { //Persistent have id attribute...
  private List cars = new Vector();
  //...
  /**
  * @hibernate.bag name="cars"
  * @hibernate.collection-key column="owner"
  * @hibernate.collection-one-to-many class="Car"
  */
  public List getCars() {
    return cars;
  }
}

and
Code:
package org.hibernate.auction;
import java.util.*;
/**
* Created on Dec 18, 2003
* @author mrack
* @hibernate.class
*/
public class Car extends Persistent { //Persistent have id attribute...
  private People owner;
//...
  /**
   * @return Returns the owner's car
   * @hibernate.many-to-one class="People"
  */
  public People getOwner() {
    return owner;
  }
}


My compiled java classes are in:
C:\TRABALHO\Auctions\org\hibernate\auctions

My ant script generate .hbm files correctly at
C:\TRABALHO\Auctions\org\hibernate\auctions

In other words:
C:\TRABALHO\Auctions\org\hibernate\auctions\People.java
C:\TRABALHO\Auctions\org\hibernate\auctions\Car.java
C:\TRABALHO\Auctions\org\hibernate\auctions\People.class
C:\TRABALHO\Auctions\org\hibernate\auctions\Car.class
C:\TRABALHO\Auctions\org\hibernate\auctions\People.hbm.xml
C:\TRABALHO\Auctions\org\hibernate\auctions\Car.hbm.xml

The problems occurs when I try to execute schemaExport, like below:

java -cp %CP% net.sf.hibernate.tool.hbm2ddl.SchemaExport --text --output=schema.ddl org\hibernate\auction\*.hbm.xml

at C:\TRABALHO\Auctions directory.

Note: var CP contains: ;lib\cglib2.jar;lib\commons-collections.jar;lib\commons-logging.jar;lib\dom4j.jar;lib\hibernate-tools.jar;lib\hibernate2.jar;lib\jdbc2_0-stdext.jar;lib\JSQLConnect.jar;lib\jta.jar;lib\odmg.jar;lib\xalan.jar;C:\TRABALHO\Auctions

The problem is that class "Car" was not found by schemaExport.

The workaround that I found was put fully-qualified name of "Car" and "People" in xdoclet-hibernate tags, like below:
Code:
package org.hibernate.auction;
import java.util.*;
/**
* Created on Dec 18, 2003
* @author mrack
* @hibernate.class
*/
public class People extends Persistent { //Persistent have id attribute...
  private List cars = new Vector();
  //...
  /**
  * @hibernate.bag name="cars"
  * @hibernate.collection-key column="owner"
  * @hibernate.collection-one-to-many class="org.hibernate.auction.Car"
  */
  public List getCars() {
    return cars;
  }
}

and
Code:
package org.hibernate.auction;
import java.util.*;
/**
* Created on Dec 18, 2003
* @author mrack
* @hibernate.class
*/
public class Car extends Persistent { //Persistent have id attribute...
  private People owner;
//...
  /**
   * @return Returns the owner's car
   * @hibernate.many-to-one class="org.hibernate.auction.People"
  */
  public People getOwner() {
    return owner;
  }
}


The question is: How I can execute schemaExport without use fully-qualified class-names in xdoclet-hibernate tags? Is a erroneous classpath configuration?

Thanks for all.

_________________
Do you still create DTO factories? Oh, no!
Try DTOptimzier now!
https://dtoptimizer.dev.java.net/


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 11:55 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
You have to fully qualify the class names in the XDoclet tags.

Otherwise, the schema export (and the normal hibernate startup) are going to look for classes in the default/no package.


Sherman


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.