Hi,
I'm new to the jasper reports. Currently working on my final year university project. My project utilizes java, mysql and hibernate framework. Using the netbeans I generated the necessary hibernate configurations, mapping files.
I got a table (ExternalShipping) with a composite key. Generally the the database connection and operations wok perfectly. But the issue occurs when I try to create the jasper reports.
ExternalShipping.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 Jul 25, 2013 1:30:06 AM by Hibernate Tools 3.2.1.GA --> <hibernate-mapping> <class name="pojo.ExternalShipping" table="external_shipping" catalog="bit_final_year_project"> <composite-id name="id" class="pojo.ExternalShippingId"> <key-property name="agentId" type="int"><column name="agent_id" /></key-property> <key-property name="buyerId" type="int"><column name="buyer_id" /></key-property> <key-property name="shippingId" type="int"><column name="shipping_id" /></key-property> </composite-id> <many-to-one name="externalByBuyerId" class="pojo.External" update="false" insert="false" fetch="select"> <column name="buyer_id" not-null="true" /> </many-to-one> <many-to-one name="externalByAgentId" class="pojo.External" update="false" insert="false" fetch="select"> <column name="agent_id" not-null="true" /> </many-to-one> <many-to-one name="externalByConsigneeId" class="pojo.External" fetch="select"> <column name="consignee_id" /> </many-to-one> <many-to-one name="shipping" class="pojo.Shipping" update="false" insert="false" fetch="select"> <column name="shipping_id" not-null="true" /> </many-to-one> </class> </hibernate-mapping>
ExternalShipping.java
package pojo;// Generated Jul 25, 2013 1:30:05 AM by Hibernate Tools 3.2.1.GA import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverrides; import javax.persistence.Column; import javax.persistence.EmbeddedId; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; /** * ExternalShipping generated by hbm2java */ @Entity@Table(name="external_shipping" ,catalog="bit_final_year_project") public class ExternalShipping implements java.io.Serializable { private ExternalShippingId id; private External externalByBuyerId; private External externalByAgentId; private External externalByConsigneeId; private Shipping shipping; public ExternalShipping() { } public ExternalShipping(ExternalShippingId id, External externalByBuyerId, External externalByAgentId, Shipping shipping) { this.id = id; this.externalByBuyerId = externalByBuyerId; this.externalByAgentId = externalByAgentId; this.shipping = shipping; } public ExternalShipping(ExternalShippingId id, External externalByBuyerId, External externalByAgentId, External externalByConsigneeId, Shipping shipping) { this.id = id; this.externalByBuyerId = externalByBuyerId; this.externalByAgentId = externalByAgentId; this.externalByConsigneeId = externalByConsigneeId; this.shipping = shipping; } @EmbeddedId @AttributeOverrides( { @AttributeOverride(name="agentId", column=@Column(name="agent_id", nullable=false) ), @AttributeOverride(name="buyerId", column=@Column(name="buyer_id", nullable=false) ), @AttributeOverride(name="shippingId", column=@Column(name="shipping_id", nullable=false) ) } ) public ExternalShippingId getId() { return this.id; } public void setId(ExternalShippingId id) { this.id = id; } @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="buyer_id", nullable=false, insertable=false, updatable=false) public External getExternalByBuyerId() { return this.externalByBuyerId; } public void setExternalByBuyerId(External externalByBuyerId) { this.externalByBuyerId = externalByBuyerId; } @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="agent_id", nullable=false, insertable=false, updatable=false) public External getExternalByAgentId() { return this.externalByAgentId; } public void setExternalByAgentId(External externalByAgentId) { this.externalByAgentId = externalByAgentId; } @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="consignee_id") public External getExternalByConsigneeId() { return this.externalByConsigneeId; } public void setExternalByConsigneeId(External externalByConsigneeId) { this.externalByConsigneeId = externalByConsigneeId; } @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="shipping_id", nullable=false, insertable=false, updatable=false) public Shipping getShipping() { return this.shipping; } public void setShipping(Shipping shipping) { this.shipping = shipping; } }
ExternalShippingId.java
package pojo;// Generated Jul 25, 2013 1:30:05 AM by Hibernate Tools 3.2.1.GA import javax.persistence.Column;import javax.persistence.Embeddable; /** * ExternalShippingId generated by hbm2java */ @Embeddablepublic class ExternalShippingId implements java.io.Serializable { private int agentId; private int buyerId; private int shippingId; public ExternalShippingId() { } public ExternalShippingId(int agentId, int buyerId, int shippingId) { this.agentId = agentId; this.buyerId = buyerId; this.shippingId = shippingId; } @Column(name="agent_id", nullable=false) public int getAgentId() { return this.agentId; } public void setAgentId(int agentId) { this.agentId = agentId; } @Column(name="buyer_id", nullable=false) public int getBuyerId() { return this.buyerId; } public void setBuyerId(int buyerId) { this.buyerId = buyerId; } @Column(name="shipping_id", nullable=false) public int getShippingId() { return this.shippingId; } public void setShippingId(int shippingId) { this.shippingId = shippingId; } public boolean equals(Object other) { if ( (this == other ) ) return true; if ( (other == null ) ) return false; if ( !(other instanceof ExternalShippingId) ) return false; ExternalShippingId castOther = ( ExternalShippingId ) other; return (this.getAgentId()==castOther.getAgentId()) && (this.getBuyerId()==castOther.getBuyerId()) && (this.getShippingId()==castOther.getShippingId()); } public int hashCode() { int result = 17; result = 37 * result + this.getAgentId(); result = 37 * result + this.getBuyerId(); result = 37 * result + this.getShippingId(); return result; } }
The issue is whenever I try to make a hibernate connection in the jasper roprt, it gives me an error as "component class not found: ExternalShippingId". I have added the classe paths correctly but it doesn't work. Please anyone can help me to figureout this issue soon thus I can able to finsh my project soon.
Edit:
The error message
2 Answers:
hi, check that your pojos are actually in the iReport classpath. It looks like Hibernate is not able to find the class BankDocumentsId.
For a stacktrace check View->IDE Log.
Giulio
Hi,
I've done what you said. First I added the POJO folder it didn't work. Then I added the whole classes it didn't work, Then I added both but the result was same.
org.hibernate.MappingException: component class not found: database.hibernate_pojo.BankDocumentsId
at org.hibernate.mapping.Component.getComponentClass(Component.java:127)
at org.hibernate.tuple.component.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:156)
at org.hibernate.tuple.component.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:66)
at org.hibernate.tuple.component.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:61)
at org.hibernate.tuple.component.ComponentEntityModeToTuplizerMapping.<init>(ComponentEntityModeToTuplizerMapping.java:76)
at org.hibernate.tuple.component.ComponentMetamodel.<init>(ComponentMetamodel.java:73)
at org.hibernate.mapping.Component.buildType(Component.java:175)
at org.hibernate.mapping.Component.getType(Component.java:168)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:276)
at org.hibernate.mapping.RootClass.validate(RootClass.java:216)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1135)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1320)
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(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
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(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
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(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at org.openide.awt.ToolbarButton.processMouseEvent(ToolbarButton.java:61)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at org.netbeans.core.TimableEventQueue.d
ispatchEvent(TimableEventQueue.java:104)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: database.hibernate_pojo.BankDocumentsId
at java.net.URLClassLoader$1.run(Unknown Source)
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 org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:252)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
at org.hibernate.mapping.Component.getComponentClass(Component.java:124)
... 126 more
Hi,
I don't get the stack trace as I couldn't able to establish a connection to the DB. I've uploaded the error I get when I try to establish a connection.