Автор Тема: Програма за магазин  (Прочетена 13214 пъти)

0 Потребители и 1 Гост преглежда(т) тази тема.

kjufte

  • Sr. Member
  • ****
  • Благодарности
  • -Казани: 1
  • -Получени: 51
  • Публикации: 308
Re: Програма за магазин
« Отговор #30 -: 30 Януари 2015, 21:17:00 »
Аз jasper-a го подкарах и успешно генерирах един pdf. Утре ще ти постна кода, че вече съм тръгнал по кръчмите.

kjufte

  • Sr. Member
  • ****
  • Благодарности
  • -Казани: 1
  • -Получени: 51
  • Публикации: 308
Re: Програма за магазин
« Отговор #31 -: 31 Януари 2015, 13:13:58 »
Този код е предимно мацаници, които са нахвърляни за бърз тест . Трябва да си го структурираш смислено. В test() функцията се генерира pdf-a и накрая вика print(), която инициира print task.

Код: Java
  1. import net.sf.jasperreports.engine.*;
  2. import net.sf.jasperreports.engine.export.*;
  3. import net.sf.jasperreports.export.SimpleExporterInput;
  4. import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
  5. import net.sf.jasperreports.export.SimplePdfExporterConfiguration;
  6. import net.sf.jasperreports.export.SimplePrintServiceExporterConfiguration;
  7.  
  8. import java.util.*;
  9.  
  10. import javax.print.attribute.HashPrintRequestAttributeSet;
  11. import javax.print.attribute.HashPrintServiceAttributeSet;
  12. import javax.print.attribute.PrintRequestAttributeSet;
  13. import javax.print.attribute.PrintServiceAttributeSet;
  14. import javax.print.attribute.standard.MediaSizeName;
  15.  
  16. public class JasperTest {
  17.     static String outFileName = "test.pdf";
  18.     static String fileName = "report1.jrxml";
  19.  
  20.     public static void test() {
  21.         HashMap hm = new HashMap();
  22.         try {
  23.             JasperReport report = JasperCompileManager.compileReport(fileName);
  24.             JasperPrint jasperPrint = JasperFillManager.fillReport(report, hm, DBConnection.con());
  25.             JRPdfExporter exporter = new JRPdfExporter();
  26.             exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
  27.             exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outFileName));
  28.             SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
  29.             exporter.setConfiguration(configuration);
  30.             exporter.exportReport();
  31.            
  32.             print(jasperPrint);
  33.  
  34.         } catch (JRException e) {
  35.             e.printStackTrace();
  36.             System.exit(1);
  37.         } catch (Exception e) {
  38.             e.printStackTrace();
  39.             System.exit(1);
  40.         }
  41.     }
  42.  
  43.     public static void print(JasperPrint jasperPrint) throws JRException {
  44.         PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
  45.         printRequestAttributeSet.add(MediaSizeName.ISO_A4);
  46.  
  47.         PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
  48.  
  49.         JRPrintServiceExporter exporter = new JRPrintServiceExporter();
  50.  
  51.         exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
  52.         SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration();
  53.         configuration.setPrintRequestAttributeSet(printRequestAttributeSet);
  54.         configuration.setPrintServiceAttributeSet(printServiceAttributeSet);
  55.         configuration.setDisplayPageDialog(false);
  56.         configuration.setDisplayPrintDialog(true);
  57.         exporter.setConfiguration(configuration);
  58.         exporter.exportReport();
  59.     }
  60. }
« Последна редакция: 31 Януари 2015, 13:16:13 от kjufte »

Meniak

  • Full Member
  • ***
  • Благодарности
  • -Казани: 5
  • -Получени: 4
  • Публикации: 224
Re: Програма за магазин
« Отговор #32 -: 31 Януари 2015, 17:03:27 »
Това чудо не знам как да по подкарам да работи, как ли не го въртях къде ли не го суках все дава грешка на 23 ред. Рекох да не бъркам пътя до файла ама как ли не го задавах и не иска. Трябва ли имам pdf четец инсталиран на компа или?

kjufte

  • Sr. Member
  • ****
  • Благодарности
  • -Казани: 1
  • -Получени: 51
  • Публикации: 308
Re: Програма за магазин
« Отговор #33 -: 31 Януари 2015, 17:24:37 »
Сега на врачка ли да звъня да ми каже каква грешка ти дава?

Meniak

  • Full Member
  • ***
  • Благодарности
  • -Казани: 5
  • -Получени: 4
  • Публикации: 224
Re: Програма за магазин
« Отговор #34 -: 31 Януари 2015, 18:23:41 »
Ами маи проблема идва от това че не съм заредил правилните .jar файлове.

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1762)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1645)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8216)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3724)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3452)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1728)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2461)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:348)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:273)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:382)
at com.sun.glass.ui.View.handleMouseEvent(View.java:553)
at com.sun.glass.ui.View.notifyMouse(View.java:925)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1147985808.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
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:483)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1757)
... 47 more
Caused by: 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:99)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.initProperties(DefaultJasperReportsContext.java:94)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.<init>(DefaultJasperReportsContext.java:71)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.<clinit>(DefaultJasperReportsContext.java:59)
at net.sf.jasperreports.engine.JasperCompileManager.getDefaultInstance(JasperCompileManager.java:197)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:572)
at classes.Jasper.test(Jasper.java:31)
at controllers.PaymentScreenController.printPayment(PaymentScreenController.java:150)
... 57 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 66 more

Wanderer

  • Full Member
  • ***
  • Благодарности
  • -Казани: 4
  • -Получени: 26
  • Публикации: 196
Re: Програма за магазин
« Отговор #35 -: 31 Януари 2015, 18:32:30 »
Трябва да добавиш http://commons.apache.org/proper/commons-logging/download_logging.cgi
Ако ползвашe maven ся нямаше да занимаваш с такива глупости.
“You must make the Journey along the road, nobody is able to do it for you!”

kjufte

  • Sr. Member
  • ****
  • Благодарности
  • -Казани: 1
  • -Получени: 51
  • Публикации: 308
Re: Програма за магазин
« Отговор #36 -: 31 Януари 2015, 18:53:05 »
И той няма да  е единствения. Ето тука зависимостите.
Ако не ти се занимава да ги теглиш една по една може да си свалиш самия проект. В него като го разархивираш има една папака libs със всичките му нужни и ненужни библиотеки.

Meniak

  • Full Member
  • ***
  • Благодарности
  • -Казани: 5
  • -Получени: 4
  • Публикации: 224
Re: Програма за магазин
« Отговор #37 -: 31 Януари 2015, 19:10:39 »
Заредил съм : jasperreports-5.6.0.jar, commons-beanutils-1.8.2.jar, commons-collections-3.2.1.jar, commons-digester-2.1.jar, commons-javaflow-20060411.jar, commons-logging-1.1.jar, groovy-all-2.0.1.jar и резултата
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1762)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1645)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8216)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3724)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3452)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1728)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2461)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:348)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:273)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:382)
at com.sun.glass.ui.View.handleMouseEvent(View.java:553)
at com.sun.glass.ui.View.notifyMouse(View.java:925)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/626202354.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
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:483)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1757)
... 47 more
Caused by: java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException
at classes.Jasper.test(Jasper.java:33)
at controllers.PaymentScreenController.printPayment(PaymentScreenController.java:150)
... 57 more
Caused by: java.lang.ClassNotFoundException: com.lowagie.text.DocumentException
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 59 more

Wanderer

  • Full Member
  • ***
  • Благодарности
  • -Казани: 4
  • -Получени: 26
  • Публикации: 196
Re: Програма за магазин
« Отговор #38 -: 31 Януари 2015, 19:23:28 »
“You must make the Journey along the road, nobody is able to do it for you!”

kjufte

  • Sr. Member
  • ****
  • Благодарности
  • -Казани: 1
  • -Получени: 51
  • Публикации: 308
Re: Програма за магазин
« Отговор #39 -: 31 Януари 2015, 20:14:54 »
Като създаваш репорт с iReport цъкни върху иконата с чукчето да си генерираш компилиран репорт (.jasper) направо. После замени този ред в кода който зареждаш репорта и съответно името на репорта.

Код: Java
  1. String fileName = "report1.jasper"; // .jasper, а не .jrxml
  2.  
  3. ...
  4.  
  5. //  JasperReport report = JasperCompileManager.compileReport(fileName);
  6. JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(fileName);          
  7.  

Процеса на компилиране в кода забавя доста генерирането (> 7 секунди при мене).

Meniak

  • Full Member
  • ***
  • Благодарности
  • -Казани: 5
  • -Получени: 4
  • Публикации: 224
Re: Програма за магазин
« Отговор #40 -: 31 Януари 2015, 20:43:57 »
Не сака да сака и май ще го зарязвам.
Ей това ми е кода, да не би пък аз да сам не донаписал нещо

import database.DBConnection;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.export.*;
import net.sf.jasperreports.export.SimpleExporterInput;
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
import net.sf.jasperreports.export.SimplePdfExporterConfiguration;
import net.sf.jasperreports.export.SimplePrintServiceExporterConfiguration;
import java.util.*;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.HashPrintServiceAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.PrintServiceAttributeSet;
import javax.print.attribute.standard.MediaSizeName;
import net.sf.jasperreports.engine.util.JRLoader;
 
public class Jasper {
    static String outFileName = "C:\\Users\\Simeon Simeonov\\Documents\\NetBeansProjects\\MyStore\\src\\classes\\test.pdf";
    static String fileName = "C:\\Users\\Simeon Simeonov\\Documents\\NetBeansProjects\\MyStore\\src\\classes\\Printer.jasper";
 
    public static void test() {
        HashMap hm = new HashMap();
        try {
            JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(fileName);
            JasperPrint jasperPrint = JasperFillManager.fillReport(report, hm, DBConnection.con());
            JRPdfExporter exporter = new JRPdfExporter();
            exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
            exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outFileName));
            SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
            exporter.setConfiguration(configuration);
            exporter.exportReport();
           
            print(jasperPrint);
 
        } catch (JRException e) {
            e.printStackTrace();
            System.exit(1);
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
 
    public static void print(JasperPrint jasperPrint) throws JRException {
        PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
        printRequestAttributeSet.add(MediaSizeName.ISO_A4);
 
        PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
 
        JRPrintServiceExporter exporter = new JRPrintServiceExporter();
 
        exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
        SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration();
        configuration.setPrintRequestAttributeSet(printRequestAttributeSet);
        configuration.setPrintServiceAttributeSet(printServiceAttributeSet);
        configuration.setDisplayPageDialog(false);
        configuration.setDisplayPrintDialog(true);
        exporter.setConfiguration(configuration);
        exporter.exportReport();
    }
}

а това е грешката

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1762)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1645)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8216)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3724)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3452)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1728)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2461)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:348)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:273)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:382)
at com.sun.glass.ui.View.handleMouseEvent(View.java:553)
at com.sun.glass.ui.View.notifyMouse(View.java:925)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/626202354.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
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:483)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1757)
... 47 more
Caused by: java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException
at classes.Jasper.test(Jasper.java:32)
at controllers.PaymentScreenController.printPayment(PaymentScreenController.java:150)
... 57 more
Caused by: java.lang.ClassNotFoundException: com.lowagie.text.DocumentException
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 59 more

kjufte

  • Sr. Member
  • ****
  • Благодарности
  • -Казани: 1
  • -Получени: 51
  • Публикации: 308
Re: Програма за магазин
« Отговор #41 -: 31 Януари 2015, 20:49:10 »
Ами точно за тази ти грешка Wanderer ти е писал кво ти липсва директно с линк.
Отделно аз ти писах как да го подкараш без ги смъкваш един по един всичките библиотеки.

Трябва да се научиш да четеш и интерпретираш warning-ите и error-ите дето ти хвърля компилатора.

Wanderer

  • Full Member
  • ***
  • Благодарности
  • -Казани: 4
  • -Получени: 26
  • Публикации: 196
Re: Програма за магазин
« Отговор #42 -: 31 Януари 2015, 20:49:39 »
LoL. Добави ли iText от линка който ти дадох в предишния си пост ? Ако не става с него пробвай по-стара версия: http://mvnrepository.com/artifact/com.lowagie/itext

ПП: Колкото по-бързо почнеш да ползваш някаква билд система толкова по-малко ще се занимаваш с такива простотии.
“You must make the Journey along the road, nobody is able to do it for you!”

Meniak

  • Full Member
  • ***
  • Благодарности
  • -Казани: 5
  • -Получени: 4
  • Публикации: 224
Re: Програма за магазин
« Отговор #43 -: 31 Януари 2015, 21:13:25 »
Живи и здрави да сте тръгна пущината и то по добре от очакваното, сега остана мноооого дребен проблем ако нямам записи в базата данни и натисна бутона "Принтираи" ми трещи грешка че имам нулев резултат и затваря програмата та някаде маи трябва да има една проверка дали имам ко да принтирам.

java.lang.IllegalArgumentException: Null range specified
at javax.print.attribute.standard.PageRanges.<init>(PageRanges.java:211)
at net.sf.jasperreports.engine.export.JRPrintServiceExporter.exportReport(JRPrintServiceExporter.java:407)
at classes.Jasper.print(Jasper.java:68)
at classes.Jasper.test(Jasper.java:42)
at controllers.PaymentScreenController.printPayment(PaymentScreenController.java:150)
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:483)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1757)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1645)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8216)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3724)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3452)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1728)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2461)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:348)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:273)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:382)
at com.sun.glass.ui.View.handleMouseEvent(View.java:553)
at com.sun.glass.ui.View.notifyMouse(View.java:925)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1851691492.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Java Result: 1

kjufte

  • Sr. Member
  • ****
  • Благодарности
  • -Казани: 1
  • -Получени: 51
  • Публикации: 308
Re: Програма за магазин
« Отговор #44 -: 31 Януари 2015, 21:18:16 »
Ами той бутона трябва да е активен само ако имаш кво да принтираш. Ако нямаш артикули в текуща сметка трябва да ти е деактивиран бутона.