title: Error when using Hibernate tools Session factory
body: <p>I get <strong>org.hibernate.MappingException: entity class not found: Company</strong></p>
  
  <p>In my Spring MVC project I already have classes mapped with annotations and I use Hibernate. I installed and configured Hibernate Tools to use HSql editor and mapping diagram. The mapping diagram opens, but the Hsql editor won't run. In Hibernate Code Generation Configurations I have only exported XML mappings and XML configuration. How can I fix this so Hsql editor will work?</p>
  
  <p>Mappings I added through <strong>Edit launch configuration properties</strong> in Hibernate Tools.</p>
  
  <p>Update: When I right click on on my class file (Open source file) hibernate=>Configuration=>Company(or any other class files) hibernate throws error: <em>Can't find source file.</em> but if I click on Mapping file it opens.</p>
  
  <p>Here's the hibernate cfg file and it's located in src folder:
  Updated:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
  &lt;session-factory name="sessionFactory"&gt;
      &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
      &lt;property name="hibernate.connection.password"&gt;xxxx&lt;/property&gt;
      &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://&amp;lt;host&amp;gt;&amp;lt;:port&amp;gt;/&amp;lt;database&amp;gt;&lt;/property&gt;
      &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
      &lt;mapping resource="com/web/handyman/entity/Company.hbm.xml"&gt;&lt;/mapping&gt;
       &lt;mapping resource="com/web/handyman/entity/Address.hbm.xml"&gt;&lt;/mapping&gt;
       &lt;mapping resource="com/web/handyman/entity/Customers.hbm.xml"&gt;&lt;/mapping&gt;
       &lt;mapping resource="com/web/handyman/entity/Handyman.hbm.xml"&gt;&lt;/mapping&gt;
       &lt;mapping resource="com/web/handyman/entity/Locations.hbm.xml"&gt;&lt;/mapping&gt;
       &lt;mapping resource="com/web/handyman/entity/User.hbm.xml"&gt;&lt;/mapping&gt;
       &lt;mapping resource="com/web/handyman/entity/UserRoles.hbm.xml"&gt;&lt;/mapping&gt;
       &lt;mapping resource="com/web/handyman/entity/WorkOrder.hbm.xml"&gt;&lt;/mapping&gt;
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p>and here's my <em>Company.hbm.xml</em> and it's located in <em>com.web.handyman.entity package</em>:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"&gt;
  &lt;!-- Generated Jun 8, 2017 12:00:36 PM by Hibernate Tools 5.1.0.Alpha1 --&gt;
  &lt;hibernate-mapping&gt;
  &lt;class name="Company" table="company" catalog="" optimistic-lock="version"&gt;
      &lt;id name="id" type="java.lang.Integer"&gt;
          &lt;column name="id" /&gt;
          &lt;generator class="identity" /&gt;
      &lt;/id&gt;
      &lt;many-to-one name="address" class="Address" fetch="select"&gt;
          &lt;column name="address_id" /&gt;
      &lt;/many-to-one&gt;
      &lt;property name="companyName" type="string"&gt;
          &lt;column name="company_name" length="45" /&gt;
      &lt;/property&gt;
      &lt;property name="phoneNumber" type="string"&gt;
          &lt;column name="phone_number" length="25" /&gt;
      &lt;/property&gt;
      &lt;property name="fax" type="string"&gt;
          &lt;column name="fax" length="25" /&gt;
      &lt;/property&gt;
      &lt;property name="email" type="string"&gt;
          &lt;column name="email" length="25" /&gt;
      &lt;/property&gt;
      &lt;property name="website" type="string"&gt;
          &lt;column name="website" length="45" /&gt;
      &lt;/property&gt;
      &lt;property name="info" type="string"&gt;
          &lt;column name="info" length="250" /&gt;
      &lt;/property&gt;
      &lt;set name="customerses" table="customers" inverse="true" lazy="true" fetch="select"&gt;
          &lt;key&gt;
              &lt;column name="company_id" /&gt;
          &lt;/key&gt;
          &lt;one-to-many class="Customers" /&gt;
      &lt;/set&gt;
  &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Here's the hibernate error:</p>
  
  <pre><code>    org.hibernate.MappingException: entity class not found: Company
  at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:132)
  at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:323)
  at org.hibernate.tuple.PropertyFactory.buildIdentifierAttribute(PropertyFactory.java:63)
  at org.hibernate.tuple.entity.EntityMetamodel.&lt;init&gt;(EntityMetamodel.java:138)
  at org.hibernate.persister.entity.AbstractEntityPersister.&lt;init&gt;(AbstractEntityPersister.java:509)
  at org.hibernate.persister.entity.SingleTableEntityPersister.&lt;init&gt;(SingleTableEntityPersister.java:124)
  at sun.reflect.GeneratedConstructorAccessor275.newInstance(Unknown Source)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
  at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
  at org.hibernate.internal.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:344)
  at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:465)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
  at sun.reflect.GeneratedMethodAccessor734.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.jboss.tools.hibernate.runtime.common.Util.invokeMethod(Util.java:43)
  at org.jboss.tools.hibernate.runtime.common.AbstractConfigurationFacade.buildTargetSessionFactory(AbstractConfigurationFacade.java:321)
  at org.jboss.tools.hibernate.runtime.common.AbstractConfigurationFacade.buildSessionFactory(AbstractConfigurationFacade.java:169)
  at org.hibernate.console.ConsoleConfiguration$5.execute(ConsoleConfiguration.java:285)
  at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
  at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:108)
  at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:280)
  at org.hibernate.eclipse.console.actions.ExecuteQueryAction.execute(ExecuteQueryAction.java:82)
  at org.hibernate.eclipse.console.actions.ExecuteQueryAction.run(ExecuteQueryAction.java:55)
  at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
  at org.hibernate.eclipse.console.actions.ExecuteQueryAction.runWithEvent(ExecuteQueryAction.java:59)
  at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
  at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
  at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:462)
  at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
  at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4481)
  at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1329)
  at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3819)
  at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3430)
  at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
  at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
  at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
  at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
  at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
  at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
  at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
  at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
  at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
  at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
  at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
  at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
  at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
  at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
  at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
  at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
  at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
  Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [Company]
  at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:229)
  at org.hibernate.boot.internal.ClassLoaderAccessImpl.classForName(ClassLoaderAccessImpl.java:62)
  at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:127)
  ... 58 more
   Caused by: java.lang.ClassNotFoundException: Could not load requested class : Company
  at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:217)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:348)
  at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:226)
  ... 60 more
  </code></pre>