-->
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.  [ 5 posts ] 
Author Message
 Post subject: org.hibernate.MappingNotFoundException
PostPosted: Fri Feb 23, 2007 8:13 pm 
Newbie

Joined: Fri Feb 23, 2007 7:59 pm
Posts: 4
Good day,

I'm having a problem with the beta9 of the tools. I keep getting these error messages: org.hibernate.MappingNotFoundException: resource: Status.hbm.xml not found

When I remove the mapping section and put the mapping in the console configuration, I get this error: org.hibernate.MappingException: entity class not found: Test

The .java .xml and .class files are all in the same folder

I know that its connecting to the database because it can pull up the tables and all of the column names. Also, I can profile the database and I see the connections being made in the db.

I have read through the forums and I think I might have a problem with my class path, but I'm not sure exactly what to configure.

If someone could point me to what I should look at in the documentation I would greatly appreciate it. I've tried to google this, but I have not had much luck.

Thank you for your time and help,
Matt

hibernate.cfg.xml:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.url">jdbc:sqlserver://localhost</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.default_catalog">DatabaseRelease</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<mapping resource="Status.hbm.xml" />
<mapping resource="Syssegments.hbm.xml" />
<mapping resource="ServerList.hbm.xml" />
<mapping resource="Dbprefix.hbm.xml" />
<mapping resource="Dblist.hbm.xml" />
<mapping resource="Test.hbm.xml" />
<mapping resource="ErrorLog.hbm.xml" />
<mapping resource="Sysconstraints.hbm.xml" />
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 11:42 pm 
Newbie

Joined: Fri Feb 23, 2007 7:59 pm
Posts: 4
Hmmm... so I have not been able to make any progress on this. I hope that by posting more information, someone will see something that I am doing wrong.

I've created a new project with 1 table to try to just get this working. My problem is that in the Hibernate Console Configuration, when I try to expand the Session Factory section. I get an error.

Either it cannot find the hbm.xml file or it cannot find the class. When I put an entry into the mappings section of the configuration console, it cannot find the class. When I try to put a <mapping resource="Main.hbm.xml"/> call in the hibernate.cfg.xml file, it cannot find the hbm.xml file. I'm not sure what I am doing wrong.

This is the Main.hbm.xml file:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Feb 27, 2007 9:18:47 PM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="events.Main" table="Main" schema="dbo">
<id name="c1" type="int">
<column name="c1" />
<generator class="assigned" />
</id>
<property name="c2" type="java.lang.Integer">
<column name="c2" />
</property>
</class>
</hibernate-mapping>

This is the hibernate.cfg.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.password">test</property>
<property name="hibernate.connection.url">jdbc:sqlserver://Latitude32:1433</property>
<property name="hibernate.connection.username">test</property>
<property name="hibernate.default_catalog">hibernate</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
</session-factory>
</hibernate-configuration>

This is the Main.java file:

package events;
// default package
// Generated Feb 27, 2007 9:18:47 PM by Hibernate Tools 3.2.0.b9

/**
* Main generated by hbm2java
*/
public class Main {

private int c1;

private Integer c2;

public Main() {
}

public Main(int c1) {
this.c1 = c1;
}

public Main(int c1, Integer c2) {
this.c1 = c1;
this.c2 = c2;
}

public int getC1() {
return this.c1;
}

public void setC1(int c1) {
this.c1 = c1;
}

public Integer getC2() {
return this.c2;
}

public void setC2(Integer c2) {
this.c2 = c2;
}

}



Full Error Log:

org.hibernate.MappingException: entity class not found: events.Main
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:168)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:118)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:425)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:317)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:89)
at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:312)
at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:55)
at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:63)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:168)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: java.lang.ClassNotFoundException: events.Main
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:402)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:347)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:83)
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 org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:96)
... 40 more


File Structure:

HBTest3
+src
+events
Main.java
Main.hbm.xml
hibernate.cfg.xml

+bin
+events
Main.class
Main.hbm.xml
hibernate.cfg.xml

(I think) I have imported the jar files correctly. I am using Eclipse and done the alt+r -> n. Gone to the classpath and imported the external jar files. All of the files under the /lib directory where I decompressed hibernate + hibernate3.jar file. I also have included my jdbc driver.

I am able to connect to the database (that is how the Main.hbm.xml file got created.)

I'm missing something and I don't see it. I've tried to go through the documentation, but I still not getting it. I've tried to add package attributes as well as putting the class attribute of Main.hbm.xml.

My environment:

XP Pro
Eclipse 3.2
Hibernate 3.2.2
Tools 3.2 beta 9
JDBC Driver = MS 1.1
Database = SQL 2000

If anyone has anything that I can try, I'll be more then willing to do it. If someone has a page of the documentation that I should reread, I'll do it.
This is driving me crazy!

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 28, 2007 12:49 am 
Newbie

Joined: Fri Feb 23, 2007 7:59 pm
Posts: 4
Ok,

So maybe something else.

I created a class to try to get something going in hibernate without using the tools.

Test class:

package events;
import org.hibernate.*;
import org.hibernate.cfg.*;

public class RunTest {

/**
* @param args
*/
public static void main(String[] args) {

// TODO Auto-generated method stub
System.out.println("test6");

try
{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
sessionFactory.openSession();
Session session = sessionFactory.getCurrentSession();
session.beginTransaction();
MainHome main = new MainHome();
Main mymain = new Main();
mymain = main.findById(1);
System.out.println(mymain.getC2());
session.getTransaction().commit();
}
catch (Exception ex)
{
System.out.println(ex.toString());
}


}

}


When I run that, I get this:
java.lang.IllegalStateException: Could not locate SessionFactory in JNDI
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 28, 2007 1:14 am 
Newbie

Joined: Fri Feb 23, 2007 7:59 pm
Posts: 4
So, I finally fixed this sort of. In case anyone cares here is what seemed to fix it.

In the console configuration classpath, I put an entry to the bin/events.

I also checked "Include default classpath from project". I'm surprised that I am not getting duplicate jar file errors here because the jdbc driver is in the project class path as well as the console classpath.

I'm now getting these errors:

Widget disposed too early!
Unhandled event loop exception!

I hope someone finds this information helpful.

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 19, 2007 10:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it sounds very wrong to add bin/events; it should just be bin/.

are you sure you are using fully qualified resource and class names where needed ?

_________________
Max
Don't forget to rate


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