Menu

Configure NexOpen Project 2 Jasper & Sample

Help
iperalta
2007-12-06
2013-04-29
  • iperalta

    iperalta - 2007-12-06

    Hi,

    When i entered to the site i expected to find more messages, how we talk thursday ... but no jejeje Everybody are in holidays?

    Well, <a href="http://www.versoqs.com">Verso</a> project needs configure project to jasper report and include new reports with iReport.

    We are waiting yours contributions to reach our objectives.

    Steps to generate jasper element:

    <ul>
    <li>Generate .jrxml file with the content of report</li>
    <li>Compile .jxrml file to generate .jasper file</li>
    <li>Full fields in report to retrieve .jrprint file</li>
    <li>Export .jrprint to expected format (.pdf ...)</li>
    </ul>

    <b>1. Generate .jrxml file </b>

    iReport is the best visual tool to generate this file. iReport allow to configure database source (JDBC, Hibernate, File...) and include selects of report.

    <b>2. Jasper file Compilation</b>

    JasperReport report = JasperCompileManager.compileReport("X:\\...\\JRXML\\Sample.jrxml");

    The next step is configure connection to report. Execute command:

    <b>3. Full fields in report </b>

    JasperPrint print = JasperFillManager.fillReport(report, parameters, conn);

    <ul>
    <li>report: .jasper file generate in previous step</li>
    <li>conn: Database Connection</li>
    </ul>

    <b>4. PDF generation</b>

    JasperExportManager.exportReportToPdfFile(print, "X:\\...\\PDF's\\InformePaisesMySQL.pdf");

    <b> NexOpen configuration </b>

    When you've .jasper compiled include it in your NexOpen project how resource. For example in:

    /WEB-INF/reports

    You shall configure library dependencies (Maven 2.0)

    In your pom.xml you shall activate dependency and configure servlet resolver of .jasper elements

    You shall configure MVC mapping in a view.properties in WEB-INFO/classes folder

    nomReport.(class)=org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView
    nomReport.url=/WEB-INF/reports/report.jasper

    <b>Problems</b>

    When deploy applications give nullpointer exeption "ComponentRegistryProcessManager.contxtInitializer ()"

    <b>Questinons</b>

    How to configure hibernate config of NexOpen to .jmxrl in iReport tool in a relative path (inside project root)

    Thanks!!

     
    • Francesc Xavier

      Francesc Xavier - 2007-12-07

      Hey, if ia have understood of your problem you achieve an ugly NulPointerException when you integrate with Jasper, does it correct???
      could you be so kind to add the stack trace??
      other problem, i do not understand ... how hibernate plays a role into Jasper generation?? are you using a Hibernate provider??have you checked the Hibernate Forums??please, povide more info!!!

      Many Thanks

       
    • iperalta

      iperalta - 2007-12-08

      Well,

      I make this steps:

      1. Generate .jasper reports and install in /WEB-INF/reports/xxx.jasper

      2. Create a controller that associate view and model, and set in a Map the values

      Class CertifFormTrabController

          public ModelAndView handleRequest(HttpServletRequest request,
                  HttpServletResponse response) throws Exception {
              return new ModelAndView("certifFormTrab", getModel());
          }

      3. Activate dependency of jasper library in web pom.xml

      4. Configure mapping in view.properties

      certifFormTrab.CertifFormTrabController=org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView
      certifFormTrab.url=/WEB-INF/reports/certFormTrab2.jasper

      5. Activate in nexopen-servlet.xml the jasper Servlet

          <bean id="reportsViewResolver"
              class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
              <property name="basename">
                  <value>views</value>
              </property>
          </bean>

      But when redeploy the server JBoss generate the next exception

      14:22:00,312 INFO  [GenericWebApplicationContext] Refreshing org.springframework.web.context.support.GenericWebApplicationContext@12f9712: display name [org.springframework.web.context.support.GenericWebApplicationContext@12f9712]; startup date [Sat Dec 08 14:22:00 CET 2007]; parent: org.springframework.web.context.support.XmlWebApplicationContext@15eddd8
      14:22:00,312 INFO  [GenericWebApplicationContext] Bean factory for application context [org.springframework.web.context.support.GenericWebApplicationContext@12f9712]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1a72b8a
      14:22:00,312 INFO  [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1a72b8a: defining beans [certAptitud,certifFormTrabEmpresa,certifFormTrab]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@1d2e04b
      14:22:00,312 INFO  [DefaultListableBeanFactory] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1a72b8a: defining beans [certAptitud,certifFormTrabEmpresa,certifFormTrab]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@1d2e04b
      14:22:00,328 ERROR [[nexopen]] Servlet.service() for servlet nexopen threw exception
      java.lang.IllegalStateException: No bean class specified on bean definition
          at org.springframework.beans.factory.support.AbstractBeanDefinition.getBeanClass(AbstractBeanDefinition.java:287)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:716)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:387)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
          at org.springframework.web.servlet.view.ResourceBundleViewResolver.initFactory(ResourceBundleViewResolver.java:228)
          at org.springframework.web.servlet.view.ResourceBundleViewResolver.loadView(ResourceBundleViewResolver.java:170)
          at org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:159)
          at org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:78)
          at org.springframework.web.servlet.DispatcherServlet.resolveViewName(DispatcherServlet.java:1178)
          at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1122)
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:878)
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:461)
          at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:416)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.nexopenframework.context.local.ThreadLocalMapFilter.doFilter(ThreadLocalMapFilter.java:79)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
          at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
          at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
          at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
          at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
          at java.lang.Thread.run(Thread.java:595)

      This exception only throws when activate jasper servlet in nexopen-servlet.xml

      Can't you help me??

      Thanks!

       
    • Francesc Xavier

      Francesc Xavier - 2007-12-08

      Ok, problem it is related with a Bean does not present into Spring beanFactiorry, but ...

      1.- it is a redeploy problem or when it is deployed at first time ???

      2.- in your post you have mentioned a NullPointerException related to a ComponentRegistryProcessManager.contxtInitializer () does it continue happening?

      many thanks

       
    • Francesc Xavier

      Francesc Xavier - 2007-12-08

      One question, in spring reference guide .... in view.properties specify views as follows

      viewName.class=org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView
      viewName.url=/WEB-INF/reports/myJasperReport.jasper

      do you follow this convention, isn't it???

       
    • Francesc Xavier

      Francesc Xavier - 2007-12-08

      Error reproduced, it is a bug due to unexpected refresh event into Spring BeanFactory. Please, make a JIRA a it will be corrected in next 0.5.0 release. Meanwhile, in a moment i will give you a solution!!

      Many thanks

       
    • Francesc Xavier

      Francesc Xavier - 2007-12-08

      Error of NullPointerException is

      [BootstrapDispatcher] NullPointerException happened
      java.lang.NullPointerException
          at java.util.Collections.sort(Collections.java:158)
          at org.nexopenframework.core.factory.ComponentRegistryProcessorManager.contextInitialized(ComponentRegistryProcessorManager.java:120)
          at org.nexopenframework.spring.context.BootstrapDispatcher.onApplicationEvent(BootstrapDispatcher.java:123)
          at test043.spring.context.BootstrapDispatcher.onApplicationEvent(BootstrapDispatcher.java:16)
          at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
          at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
          at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
          at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
          at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:248)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
          at org.springframework.web.servlet.view.ResourceBundleViewResolver.initFactory(ResourceBundleViewResolver.java:244)
          at org.springframework.web.servlet.view.ResourceBundleViewResolver.loadView(ResourceBundleViewResolver.java:186)
          at org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:159)
          at org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:78)
          at org.springframework.web.servlet.DispatcherServlet.resolveViewName(DispatcherServlet.java:1178)
          at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1122)
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:878)
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:475)
          at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:430)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)

      How to prevent it in solutions less than 0.5.x as follows

      1.- Extend the class org.nexopenframework.spring.context.BootstrapDispatcher in the following way

      package com.mypackage.spring.context;

      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;
      import org.springframework.context.ApplicationEvent;

      public class BootstrapDispatcher extends
              org.nexopenframework.spring.context.BootstrapDispatcher {

          static final Log logger = LogFactory.getLog(BootstrapDispatcher.class);
         
          @Override
          public final void onApplicationEvent(ApplicationEvent event) {
              try {
                 super.onApplicationEvent(event);
              } catch (NullPointerException e) {
                  //avoid ugly problems
                  logger.debug("NullPointerException happened", e);
              }
          }
      }

      2.- In the file openfrwk-module-eventsDispatcher.xml redefine (change the NexOpen org.nexopenframework.spring.context.BootstrapDispatcher for your previous defined bean) the bootstrap bean

              <!-- bootstrap Spring BeanFactory dispatcher -->
          <bean id="bootstrap" class="com.mypackage.spring.context.BootstrapDispatcher">
              <description>Event boostrap dispatcher for handling notifications inside test043
                           about creation and destroying of the Spring BeanFactory</description>
          </bean>

      3.- be sure to define the iText libraries in the web pom.xml

                      <dependency>
                 <groupId>com.lowagie</groupId>
                 <artifactId>itext</artifactId>
                 <version>1.3.1</version>
              </dependency>

      and that's all

       
    • Francesc Xavier

      Francesc Xavier - 2007-12-08

      Just a curiosity, JasperReports in jrxml files opens a java process!!!!!!!so ugly :-(

       
    • iperalta

      iperalta - 2007-12-10

      It's run.

      Your appointment solution the exception, but ... the solution generate white reports, without content ...

      Any idea?

       
    • Francesc Xavier

      Francesc Xavier - 2007-12-10

      Please Ivan,

      put it in another thread!!! it could be interesting to be present at top!!if you will be so kind to open in Forum>Open Discusions will be try to help you as soon as possible

      Many thanks

       
    • Marc

      Marc - 2007-12-10

      Hey, about that white reports... how are you trying to get the info for them? Are you trying to make sql queries directly from Jasper defining them in the .jrmxl?

      The way we did it in our project was through the general NexOpen-MVC paradigma, so in the web controllers, we didn't just redirect to a jasper view were we did sql queries, but called to business objects to get the required model. This model had all the information needed by the report, by Key-Value pairs, so if in the report we were accessing to a parameter "$P{year}", we would add an element to our model with the "year" key and the propper value returned by the business object. If we wanted to iterate over a collection of elements in that report, we would add a "datasource" key element in our model, with a java.util.List of that class type objects beeing iterated.

      So, how are you trying to fill the report? Directly with sql calls from the .jasper or passing a model to it?

      Marc

       
      • Francesc Xavier

        Francesc Xavier - 2007-12-10

        Marc,

        if i understood from the mail, it appears a blank document to browser!!!neither errors nor warnings appears in console!!!
        NexOpen has not integrated/extended any component related to JasperReports.. do you remember if we have forgotten to integrate something???

        many thanks

         

Log in to post a comment.