Announcement Announcement Module
Collapse
No announcement yet.
Cannot compile JasperReports Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot compile JasperReports

    Hi,

    I am trying to use JasperReports 0.6.8 with Spring 1.2. I just can't get the JasperReport file compiled. The root cause of the exception is:

    Code:
    C:\eclipse\test2.java:4: package net.sf.jasperreports.engine does not exist
    import net.sf.jasperreports.engine.*;
    ^
    C:\eclipse\test2.java:5: package net.sf.jasperreports.engine.fill does not exist
    import net.sf.jasperreports.engine.fill.*;
    ^
    C:\eclipse\test2.java:14: package net.sf.jasperreports.engine does not exist
    import net.sf.jasperreports.engine.*;
    ^
    C:\eclipse\test2.java:15: package net.sf.jasperreports.engine.data does not exist
    import net.sf.jasperreports.engine.data.*;
    ^
    C:\eclipse\test2.java:21: cannot resolve symbol
    symbol  : class JRCalculator 
    location: class test2
    public class test2 extends JRCalculator
                               ^
    C:\eclipse\test2.java:28: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
        private JRFillParameter parameter_REPORT_RESOURCE_BUNDLE = null;
                ^
    C:\eclipse\test2.java:29: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
        private JRFillParameter parameter_REPORT_CONNECTION = null;
                ^
    C:\eclipse\test2.java:30: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
        private JRFillParameter parameter_REPORT_PARAMETERS_MAP = null;
                ^
    C:\eclipse\test2.java:31: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
        private JRFillParameter parameter_REPORT_LOCALE = null;
                ^
    C:\eclipse\test2.java:32: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
        private JRFillParameter parameter_REPORT_DATA_SOURCE = null;
                ^
    C:\eclipse\test2.java:33: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
        private JRFillParameter parameter_REPORT_SCRIPTLET = null;
                ^
    C:\eclipse\test2.java:34: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
        private JRFillParameter parameter_REPORT_MAX_COUNT = null;
                ^
    C:\eclipse\test2.java:37: cannot resolve symbol
    symbol  : class JRFillVariable 
    location: class test2
        private JRFillVariable variable_PAGE_NUMBER = null;
                ^
    C:\eclipse\test2.java:38: cannot resolve symbol
    symbol  : class JRFillVariable 
    location: class test2
        private JRFillVariable variable_COLUMN_NUMBER = null;
                ^
    C:\eclipse\test2.java:39: cannot resolve symbol
    symbol  : class JRFillVariable 
    location: class test2
        private JRFillVariable variable_REPORT_COUNT = null;
                ^
    C:\eclipse\test2.java:40: cannot resolve symbol
    symbol  : class JRFillVariable 
    location: class test2
        private JRFillVariable variable_PAGE_COUNT = null;
                ^
    C:\eclipse\test2.java:41: cannot resolve symbol
    symbol  : class JRFillVariable 
    location: class test2
        private JRFillVariable variable_COLUMN_COUNT = null;
                ^
    C:\eclipse\test2.java:64: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
            parameter_REPORT_RESOURCE_BUNDLE = (JRFillParameter)pm.get("REPORT_RESOURCE_BUNDLE");
                                                ^
    C:\eclipse\test2.java:65: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
            parameter_REPORT_CONNECTION = (JRFillParameter)pm.get("REPORT_CONNECTION");
                                           ^
    C:\eclipse\test2.java:66: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
            parameter_REPORT_PARAMETERS_MAP = (JRFillParameter)pm.get("REPORT_PARAMETERS_MAP");
                                               ^
    C:\eclipse\test2.java:67: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
            parameter_REPORT_LOCALE = (JRFillParameter)pm.get("REPORT_LOCALE");
                                       ^
    C:\eclipse\test2.java:68: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
            parameter_REPORT_DATA_SOURCE = (JRFillParameter)pm.get("REPORT_DATA_SOURCE");
                                            ^
    C:\eclipse\test2.java:69: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
            parameter_REPORT_SCRIPTLET = (JRFillParameter)pm.get("REPORT_SCRIPTLET");
                                          ^
    C:\eclipse\test2.java:70: cannot resolve symbol
    symbol  : class JRFillParameter 
    location: class test2
            parameter_REPORT_MAX_COUNT = (JRFillParameter)pm.get("REPORT_MAX_COUNT");
                                          ^
    C:\eclipse\test2.java:87: cannot resolve symbol
    symbol  : class JRFillVariable 
    location: class test2
            variable_PAGE_NUMBER = (JRFillVariable)vm.get("PAGE_NUMBER");
                                    ^
    C:\eclipse\test2.java:88: cannot resolve symbol
    symbol  : class JRFillVariable 
    location: class test2
            variable_COLUMN_NUMBER = (JRFillVariable)vm.get("COLUMN_NUMBER");
                                      ^
    C:\eclipse\test2.java:89: cannot resolve symbol
    symbol  : class JRFillVariable 
    location: class test2
            variable_REPORT_COUNT = (JRFillVariable)vm.get("REPORT_COUNT");
                                     ^
    C:\eclipse\test2.java:90: cannot resolve symbol
    symbol  : class JRFillVariable 
    location: class test2
            variable_PAGE_COUNT = (JRFillVariable)vm.get("PAGE_COUNT");
                                   ^
    C:\eclipse\test2.java:91: cannot resolve symbol
    symbol  : class JRFillVariable 
    location: class test2
            variable_COLUMN_COUNT = (JRFillVariable)vm.get("COLUMN_COUNT");
                                     ^
    29 errors
    It looks like it couldn't find the JasperReport jar file during the compile. However, I am sure I packaged the jar file with my web app. Does anyone know which classpath gets used when the JasperReport file gets compiled? Any help is greatly appreciated.

    Thanks!

    Kenny

  • #2
    Are you trying to use runtime compilation or buildtime?

    Rob

    Comment


    • #3
      Hi Rob,

      I was trying to compile the report at runtime. Finally, I found out the problem.

      First, the compile error is due to the JRDefaultCompiler used by Spring. We have to provide a different compiler (JRBshCompiler) to JasperReportsPdfView. Something looks like this:

      Code:
      <bean id="jRBshCompiler" class="net.sf.jasperreports.engine.design.JRBshCompiler"/>
               
      <bean id="testPDF" class="org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView">
          <property name="reportCompiler">
              <ref local="jRBshCompiler"/>
          </property>
          <property name="url">
              <value>/WEB-INF/reports/test.jrxml</value>
          </property>
      </bean>
      This can be found at http://forum.springframework.org/showthread.php?t=14857. Thanks to Gilberto.

      However, this is only a part of the problem. When I configure my JasperReportsPdfView by using a ResourceBundleViewResolver, Spring will completely ignore my additional bean configuration in the app-servlet.xml file even the bean id/class match to the view name/class. I don't know if this is by design but it means that I can't use ResourceBundleViewResolver to configure my PDF views because there is no way to provide a different JRCompiler (Spring will always use JRDefaultCompiler). This is not a big deal because we can always manually initiate the view or inject the view to the controller. But it will be nice that we can keep all views in one place (views.properties).

      By the way, I get some InputStream exception when I try to compile the report using iReport and ask Spring to load the compiled report object. So it forces me to let Spring compile the reports for me.

      Kenny
      Last edited by robyn; May 15th, 2006, 05:58 PM.

      Comment


      • #4
        You can still configure your reports using the properties-style approach, even if you have to inject a different compiler. Spring does attempt to merge properties from the properties file with those defined in the application context - this is by design.

        I'm interested to know why the reports compiled by iReport cannot be loaded by Spring. I'll try my best to fix any problems you encounter, but unfortunately, the compilation behavior in JR is a bit of moving target and we are constrained by what compilers they provide.

        Rob

        Comment


        • #5
          Originally posted by robh
          I'm interested to know why the reports compiled by iReport cannot be loaded by Spring. I'll try my best to fix any problems you encounter, but unfortunately, the compilation behavior in JR is a bit of moving target and we are constrained by what compilers they provide.
          Rob
          Same problem happen to me before, either:
          1. ireport and spring using different JDK (build using jdk 1.5 run by spring using jdk 1.4.2 ) or
          2. ireport and spring using different version of Jasperreport libs (0.6.x vs 1.0.0 in spring 1.2.3). The fix is simple, just replace jasperreport lib in iReport with spring lib (jasperreport 1,0.0 and all common libraries related)

          I have sugestion though, could spring compile jrxml like velocity do to the .vm templates. I mean in a certain amount of time, when file changes, it automatically detect and recompile the file without starting aps?

          Spring is great :wink:

          [^_^]
          IPBS

          Comment


          • #6
            Please post a feature request for that on JIRA.

            Rob

            Comment


            • #7
              You can still configure your reports using the properties-style approach, even if you have to inject a different compiler. Spring does attempt to merge properties from the properties file with those defined in the application context - this is by design.
              Hello Mr. Rob, you said we can still use properties-style approach.. is it like this:

              Code:
              covering_letter.class=org.springframework.web.servlet.view.jasperreports.JasperReportsMultiFormatView
              covering_letter.reportCompiler=net.sf.jasperreports.engine.design.JRJdtCompiler
              covering_letter.url=/WEB-INF/elions/uw/reports/covering_letter.jrxml
              because i cannot do this, error... can you help clarify about using properties style ? thank you

              Comment

              Working...
              X