I have created a sample report and trying to Load it from jFrame button click. First Report. Not working.

0

Code:

try {         String IP = "192.168.1.123";
         String DataBase = "traders_bikri";
         String ID = "root";
         String Password = "PASSWORD";         

Connection con1 = DriverManager.getConnection("jdbc:mysql://" + IP + "/" + DataBase + "", ID, Password);


String report = "Y:\\iReportsDemo\\src\\ireportsdemo\\report1.jrxml"; try {
//Connection making
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
//Logger.getLogger(reportJDialog.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(null, ex);
}
JasperReport jr = JasperCompileManager.compileReport(report);


JasperPrint jp = JasperFillManager.fillReport(jr, null, con1);


JasperViewer.viewReport(jp, false);


con1.close();


} catch (JRException e) {
e.printStackTrace();


JOptionPane.showMessageDialog(null, e);
} catch (SQLException ex) {



Logger.getLogger(ReportLoaderForm.class.getName()).log(Level.SEVERE, null, ex);
}

And here is from the output window.
run:
Sat Jul 22 20:25:36 IST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at net.sf.jasperreports.engine.util.JRLoader.<clinit>(JRLoader.java:81)
    at net.sf.jasperreports.engine.JRPropertiesUtil.loadProperties(JRPropertiesUtil.java:102)
    at net.sf.jasperreports.engine.DefaultJasperReportsContext.initProperties(DefaultJasperReportsContext.java:99)
    at net.sf.jasperreports.engine.DefaultJasperReportsContext.<init>(DefaultJasperReportsContext.java:76)
    at net.sf.jasperreports.engine.DefaultJasperReportsContext.<clinit>(DefaultJasperReportsContext.java:59)
    at net.sf.jasperreports.engine.JasperCompileManager.getDefaultInstance(JasperCompileManager.java:200)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:575)
    at ireportsdemo.ReportLoaderForm.jButton1ActionPerformed(ReportLoaderForm.java:96)
    at ireportsdemo.ReportLoaderForm.access$000(ReportLoaderForm.java:25)
    at ireportsdemo.ReportLoaderForm$1.actionPerformed(ReportLoaderForm.java:50)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    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:6533)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6298)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    at java.awt.Container.dispatchEventImpl(Container.java:2280)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 46 more
Please guide to findout where is the problem. Also, when I am previewing the report in iReports design and preview, its loading well in IDE as well as in Internet Explorer.I had to use try-catch block twice because I IDe forced me to do that.
subhamchintu's picture
Joined: Mar 6 2014 - 10:51pm
Last seen: 2 years 4 months ago

2 Answers:

0

>Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory

You're missing apache log jar file in your build path. Unfortunately, you didn't include the complete source code but it seems like you're using the log somewhere.

Your error has nothing to do with JasperReports library.

Really should learn Java before attempting to write a program using JasperReports library.

hozawa's picture
54510
Joined: Apr 24 2010 - 4:31pm
Last seen: 6 months 4 days ago
0

Idiot response! tsk tsk

m.goncalves.2005's picture
Joined: Sep 28 2017 - 3:51am
Last seen: 4 months 5 days ago
Feedback