Hot questions for Using JasperReports in tomcat7

Question:

I am facing below error while trying to deploy the application on tomcat server. I am deploying the same code from this link: http://krams915.blogspot.in/2010/12/spring-3-mvc-jasper-integration.html without customization yet. I find the same error is reported on stackoverflow, but none of the solution worked for me. Hence decided to report once again considering issue for this source code.Please guide.

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/spring-jasper-integration]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1120)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/spring-jasper-integration]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
    ... 6 more
Caused by: java.lang.SecurityException: SHA1 digest error for org/bouncycastle/crypto/encodings/OAEPEncoding.class
    at sun.security.util.ManifestEntryVerifier.verify(ManifestEntryVerifier.java:220)
    at java.util.jar.JarVerifier.processEntry(JarVerifier.java:241)
    at java.util.jar.JarVerifier.update(JarVerifier.java:228)
    at java.util.jar.JarVerifier$VerifierStream.read(JarVerifier.java:483)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
    at java.io.DataInputStream.readInt(DataInputStream.java:387)
    at org.apache.tomcat.util.bcel.classfile.ClassParser.readID(ClassParser.java:201)
    at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:80)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2123)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1985)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1946)
    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1931)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1330)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5472)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 6 more

Feb 20, 2016 6:25:28 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1120)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:444)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:738)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:693)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1128)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 6 more

Feb 20, 2016 6:25:28 PM org.apache.catalina.startup.Catalina start
SEVERE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:693)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:738)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:444)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1128)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 11 more

The pom.xml for reference.

<properties>
        <java.version>1.7</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.0.5.RELEASE</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.0.5.RELEASE</version>
            <type>jar</type>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <artifactId>commons-logging</artifactId>
                    <groupId>commons-logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>3.0.5.RELEASE</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.0.5.RELEASE</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>3.0.5.RELEASE</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>3.7.6</version>
            <type>jar</type>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <artifactId>commons-collections</artifactId>
                    <groupId>commons-collections</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>commons-beanutils</artifactId>
                    <groupId>commons-beanutils</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>commons-digester</artifactId>
                    <groupId>commons-digester</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>commons-logging</artifactId>
                    <groupId>commons-logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>2.1</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.6</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
    </dependencies>

    <!-- Project Build -->
    <build>
        <finalName>spring-jasper-integration</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>**/*Tests.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>

Answer:

  1. You can forcely update your maven

mvn clean install -U

  1. If this procedure fails, then try to it with hard way
find ~/.m2/ -name "*.lastUpdated" | xargs rm
  1. If this procedure also fails, Then try to purge the local repo using the following:
mvn dependency:purge-local-repository

Then make clean and install by this command:

mvn dependency:purge-local-repository clean install

For better, you can follow the links

  1. How do I remove a cached local artifact that maven fetched?
  2. Force maven update

Question:

I just implemented a Jasper report to generate a pdf document from a java web app running on tomcat 7, but when the report is generated on my pc appears a java icon (img1.png) if I close that "java application" it stops my tomcat server and the execution of my web application, this is the code of my pdf generator method:

.xhtml button:

<h:form>
     <h:commandButton actionListener="#{menuController.jasperTestOne}" value="Jasper PDF" />
 </h:form>

Backend java code:

public void jasperTestOne() {
        try {
            Map<String,Object> parametros= new HashMap<String,Object>();
            parametros.put("PRINT_BY", "SomeUser");

            String jPath = "/Users/Documents/pdf/jasper/test.jasper";
            File jasper = new File(jPath);
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasper.getPath(),parametros, new JRBeanCollectionDataSource(this.getItems()));

            HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
            response.addHeader("Content-disposition","attachment; filename=jsfReporte.pdf");
            ServletOutputStream stream = response.getOutputStream();

            JasperExportManager.exportReportToPdfStream(jasperPrint, stream);

            stream.flush();
            stream.close();
            FacesContext.getCurrentInstance().responseComplete();
        } catch(Exception ex) {
            System.out.println("JASPER ERROR: " + ex.getMessage());
        }
    }

Answer:

The "java application" is the Tomcat process. OSX starts displaying an icon in the dock because JasperReports uses some graphical resources to measure texts while generating the report.

Creating the PDF does not terminate the server process, the process terminates when you close the application from the dock. If you leave the application in the dock Tomcat will continue to run.

If you don't want to see the Tomcat process in the dock you can add -Djava.awt.headless=true to the Tomcat Java options.

Question:

When using JasperReport 6.2.0 on a reporting having subreport, I got a java.lang.StackOverflowError

    net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:886) 
net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:352) 
net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:421) 
net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:396) 
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2028) 
...

Server is openSuse Linux 42.1, Tomcat7.0.53, Java is openjdk version "1.8.0_72", MariaDB database.

Adding log4j.logger.org.apache.commons.javaflow=info into log4j.properties as I found on some sites did NOT solve the problem.

I also have the commons-javaflow-20060411.jar library in my path.

Testing using JasperReport 6.3.0 raised a

net.sf.jasperreports.engine.JRRuntimeException: 
java.lang.NoSuchMethodError: 
org.apache.commons.javaflow.Continuation.suspend()Ljava/lang/Object;

...

Issues was NOT present when using Jasperreport 5.x version.

I have exactly the same install on various servers with same libraries versions, java versions, code version, etc... (Linux server, cloned disk installation), but only 3 of 17 servers have the issue...

Same database on refreshed on another server does NOT present the issue... Very strange... Like it's harware related, but it is not since some have same harware and one works and the other not.


Answer:

Finally I solved the issue using version 6.1.1 of Jasperreports. Solved it on all servers.

http://netcologne.dl.sourceforge.net/project/jasperreports/jasperreports/JasperReports%206.1.1/jasperreports-javaflow-6.1.1.jar http://netcologne.dl.sourceforge.net/project/jasperreports/jasperreports/JasperReports%206.1.1/jasperreports-fonts-6.1.1.jar http://jaist.dl.sourceforge.net/project/jasperreports/jasperreports/JasperReports%206.1.1/jasperreports-6.1.1.jar

UPDATE: Thanks to @dada67 advise, I upgraded to version 6.3.0 without including the jasperreports-javaflow-x.y.z.jar (and removing all 3 files from version 6.1.1) and everything is working fine now.

So the solution was to remove jasperreports-javaflow-x.y.z.jar