0

I know that this topic is already existed but, unfortunately, they don't solve my problem. My code is below

try {
            String prID = txt_prno.getText();
            HashMap hash=new HashMap(1);
            hash.put("ProductID",prID);
            InputStream file = getClass().getResourceAsStream("/myreports/reportpr1.jrxml");
            System.out.println("path_1:"+file);
            System.out.println("path_2:"+file.toString());
            JasperDesign jd = JRXmlLoader.load(file);
            JasperReport jr = JasperCompileManager.compileReport(jd);
            JasperPrint jp = JasperFillManager.fillReport(jr, hash, conn);
            JasperViewer.viewReport(jp,false);// jv = new JasperViewer(jp,false);
        } catch (JRException ex) {
            System.out.println(ex);
        }

Here is my file structure enter image description here

This is some error code from CMD. It is a very long stack trace

java.lang.NoClassDefFoundError: org/apache/commons/beanutils/MethodUtils
    at org.apache.commons.digester.CallMethodRule.end(CallMethodRule.java:632)
    at org.apache.commons.digester.Rule.end(Rule.java:257)
    at org.apache.commons.digester.Digester.endElement(Digester.java:1345)
    at net.sf.jasperreports.engine.xml.JRXmlDigester.endElement(JRXmlDigester.java:199)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
    at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)

This is the path of report file enter image description here

Now, their is no more errors after I download and add the following file to my project library commons-beanutils-1.9.3-bin.tar.gz. But, this message appears instead of the error

net.sf.jasperreports.engine.JRException: Error compiling report java source files : C:\Users\IT\report32name_1548766294622_936064.java
Martin Schröder
  • 4,176
  • 7
  • 47
  • 81
Canyou Seeme
  • 37
  • 1
  • 4
  • and what is the problem you are having? "cannot load jrxml report" .. can't it find the report? can't it work with Jasper? – Stultuske Jan 29 '19 at 08:57
  • Thanks for your quick reply, refer to the log yes seem like "Unknow source", i do not user the report .jastper but i use the one .jrxml and it works when i running my project in Netbean but, it throw an error when i run .jar file, actually there is error code and i am trying to attached to this PS. I am new here – Canyou Seeme Jan 29 '19 at 09:04
  • "JasperDesign", yet you don't use Jasper. Does that reportpr1.jrxml file exist where you claim it to? print the total path of that file, and check if it does – Stultuske Jan 29 '19 at 09:05
  • here is some error at org.apache.commons.digester.CallMethodRule.end(CallMethodRule.java:632) at org.apache.commons.digester.Rule.end(Rule.java:257) at org.apache.commons.digester.Digester.endElement(Digester.java:1345) at net.sf.jasperreports.engine.xml.JRXmlDigester.endElement(JRXmlDigester.java:199) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source) – Canyou Seeme Jan 29 '19 at 09:05
  • show the structure of your jar, where the jrxml-file is located – Turo Jan 29 '19 at 09:05
  • if you want to provide more information, edit your question and add it there – Stultuske Jan 29 '19 at 09:06
  • the file is exist for sure, how can i print total path of that file ? – Canyou Seeme Jan 29 '19 at 09:10
  • Dont put such information into comments. Always edit your question and provide a [mcve] there. And hint: it doesnt matter at all if you are using netbeans. Your editor used for writing code does not at all matter when asking why some code isnt working. – GhostCat Jan 29 '19 at 09:11
  • I am really appreciated for your suggestion and sorry for inconvenience, i am trying to add more information as much as possible pls – Canyou Seeme Jan 29 '19 at 09:17
  • Probably related: https://stackoverflow.com/questions/18451052/how-to-include-jars-in-lib-into-project-jar-file-in-netbeans – Tom Jan 29 '19 at 09:35

1 Answers1

0

Your error message indicates you are missing commons-beanutils-x.x.x.jar

if you're using Maven , add a dependency to this jar. Otherwise you can downoad the missing jar, then right-click your Project in Netbeans > Libraries > Add JAR/Folder > select the jar > Open

nullPointer
  • 4,419
  • 1
  • 15
  • 27