Jump to content
We've recently updated our Privacy Statement, available here ×

Jasper with Hibernate - entity class not found


nidhishkrishnan

Recommended Posts

i'm trying to create a jasper with hibernate connection as demonstrated in the tutorial

http://www.tutorialcenters.com/index.php/how-to-design-report-using-jasperreport-hibernate-connect
ion/

i did exactly as specified in the tutorial but when i'm getting
entity class not found: mappings.EmployeeMaster

can anyone please tell me some solution for this....
 

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.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hse</property>
        <property name="hibernate.connection.username">root</property>
        <mapping resource="mappings/EmployeeMaster.hbm.xml"/>
      </session-factory>
    </hibernate-configuration>

hibernate.reveng.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
    <hibernate-reverse-engineering>
      <schema-selection match-catalog="hse"/>
      <table-filter match-name="employee_master"/>
      
    </hibernate-reverse-engineering>

EmployeeMaster.hbm.xml

    <?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 Sep 15, 2013 11:07:05 PM by Hibernate Tools 3.2.1.GA -->
    <hibernate-mapping >
        <class name="mappings.EmployeeMaster" table="employee_master" catalog="hse">
            <id name="id" type="java.lang.Integer">
                <column name="id" />
                <generator class="identity" />
            </id>
            <property name="userCode" type="string">
                <column name="user_code" length="60" not-null="true" unique="true" />
            </property>
            <property name="firstName" type="string">
                <column name="first_name" length="60" />
            </property>
            <property name="lastName" type="string">
                <column name="last_name" length="60" />
            </property>
            <property name="deptId" type="java.lang.Integer">
                <column name="dept_id" />
            </property>
            <property name="designationId" type="java.lang.Integer">
                <column name="designation_id" />
            </property>
            <property name="empEmail" type="string">
                <column name="emp_email" length="60" />
            </property>
            <property name="status" type="string">
                <column name="status" length="20" />
            </property>
            <property name="createdDate" type="timestamp">
                <column name="created_date" length="19" />
            </property>
            <property name="modifiedDate" type="timestamp">
                <column name="modified_date" length="19" />
            </property>
        </class>
    </hibernate-mapping>

IDE Log

    org.hibernate.MappingException: entity class not found: mappings.EmployeeMaster
            at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:122)
            at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:191)
            at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:67)
            at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:147)
            at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:457)
            at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:131)
            at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
            at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:261)
            at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
            at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
            at com.jaspersoft.ireport.designer.connection.JRHibernateConnection.getSessionFactory(JRHibernateConnection.java:130)
            at com.jaspersoft.ireport.designer.connection.JRHibernateConnection$1.run(JRHibernateConnection.java:157)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
            at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
            at java.awt.EventQueue.access$000(EventQueue.java:101)
            at java.awt.EventQueue$3.run(EventQueue.java:666)
            at java.awt.EventQueue$3.run(EventQueue.java:664)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
            at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:121)
            at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
            at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
            at java.awt.Dialog.show(Dialog.java:1072)
            at java.awt.Component.show(Component.java:1651)
            at java.awt.Component.setVisible(Component.java:1603)
            at java.awt.Window.setVisible(Window.java:1013)
            at java.awt.Dialog.setVisible(Dialog.java:1003)
            at com.jaspersoft.ireport.designer.connection.gui.ConnectionsDialog.jButtonNewParameterActionPerformed(ConnectionsDialog.java:578)
            at com.jaspersoft.ireport.designer.connection.gui.ConnectionsDialog.access$400(ConnectionsDialog.java:47)
            at com.jaspersoft.ireport.designer.connection.gui.ConnectionsDialog$7.actionPerformed(ConnectionsDialog.java:221)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
            at java.awt.Component.processMouseEvent(Component.java:6505)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
            at java.awt.Component.processEvent(Component.java:6270)
            at java.awt.Container.processEvent(Container.java:2229)
            at java.awt.Component.dispatchEventImpl(Component.java:4861)
            at java.awt.Container.dispatchEventImpl(Container.java:2287)
            at java.awt.Component.dispatchEvent(Component.java:4687)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
            at java.awt.Container.dispatchEventImpl(Container.java:2273)
            at java.awt.Window.dispatchEventImpl(Window.java:2713)
            at java.awt.Component.dispatchEvent(Component.java:4687)
            at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
            at java.awt.EventQueue.access$000(EventQueue.java:101)
            at java.awt.EventQueue$3.run(EventQueue.java:666)
            at java.awt.EventQueue$3.run(EventQueue.java:664)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
            at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
            at java.awt.EventQueue$4.run(EventQueue.java:680)
            at java.awt.EventQueue$4.run(EventQueue.java:678)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
            at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:121)
            at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
            at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
            at java.awt.Dialog.show(Dialog.java:1072)
            at java.awt.Component.show(Component.java:1651)
            at java.awt.Component.setVisible(Component.java:1603)
            at java.awt.Window.setVisible(Window.java:1013)
            at java.awt.Dialog.setVisible(Dialog.java:1003)
            at com.jaspersoft.ireport.designer.connection.gui.ConnectionsDialog.setVisible(ConnectionsDialog.java:651)
            at com.jaspersoft.ireport.designer.menu.DatasourcesAction.performAction(DatasourcesAction.java:46)
            at org.openide.util.actions.CallableSystemAction$1.run(CallableSystemAction.java:118)
            at org.netbeans.modules.openide.util.ActionsBridge.doPerformAction(ActionsBridge.java:77)
            at org.openide.util.actions.CallableSystemAction.actionPerformed(CallableSystemAction.java:114)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
            at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
            at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
            at java.awt.Component.processMouseEvent(Component.java:6505)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
            at org.openide.awt.ToolbarButton.processMouseEvent(ToolbarButton.java:61)
            at java.awt.Component.processEvent(Component.java:6270)
            at java.awt.Container.processEvent(Container.java:2229)
            at java.awt.Component.dispatchEventImpl(Component.java:4861)
            at java.awt.Container.dispatchEventImpl(Container.java:2287)
            at java.awt.Component.dispatchEvent(Component.java:4687)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
            at java.awt.Container.dispatchEventImpl(Container.java:2273)
            at java.awt.Window.dispatchEventImpl(Window.java:2713)
            at java.awt.Component.dispatchEvent(Component.java:4687)
            at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
            at java.awt.EventQueue.access$000(EventQueue.java:101)
            at java.awt.EventQueue$3.run(EventQueue.java:666)
            at java.awt.EventQueue$3.run(EventQueue.java:664)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
            at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
            at java.awt.EventQueue$4.run(EventQueue.java:680)
            at java.awt.EventQueue$4.run(EventQueue.java:678)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
            at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
    Caused by: java.lang.ClassNotFoundException: mappings.EmployeeMaster
            at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
            at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:252)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:186)
            at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
            at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:119)
            ... 123 more


my samplehiber project structure in netbeans IDE

proj(1).png.6a23240d7203e449f568c415fe2458a6.png

Setting Classpath

 

connection.png.e09358c771fea71b5ecda3890f341af8.png

Connection setup with MySQL Database using hibernate Configuration

step1.png.98700d0cb2a8574d5d3276d848a89a8e.png

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...