daust / JasperReportsIntegration

JasperReportsIntegration provides an interface to use the JasperReports reporting engine in an Oracle database application, specifically with Oracle Application Express (Oracle APEX).
BSD 3-Clause "New" or "Revised" License
55 stars 23 forks source link

Error deploying on Wildfly application server. #108

Closed sanderleget closed 2 years ago

sanderleget commented 2 years ago

With the latest issues in spring4shell we wanted to have an updated version of Jasper Reports Integration deployed.

Tried building version 2.8.1 but this seems to no longer able to be deployed. While the last version we run version 2.7.1 had no problems with WildFly 22 & 26.

I did some investigation myself and tried a few options. But i ran out of idees why it no longer should work. Maybe u have some insight in what changed.

Error Message:

{"WFLYDC0074: Operation failed or was rolled back on all servers. Server failures:" => {"server-group" => {"reporting_group" => {"host" => {"master" => {"reporting_server_one" => {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"JasperReportsIntegration.war\".undertow-deployment" => "java.lang.RuntimeException: java.lang.ClassCastException: class org.jboss.logmanager.log4j.JBossLoggerContext cannot be cast to class org.apache.logging.log4j.core.LoggerContext (org.jboss.logmanager.log4j.JBossLoggerContext is in unnamed module of loader 'org.jboss.logmanager.log4j2@1.1.1.Final' @621bd734; org.apache.logging.log4j.core.LoggerContext is in unnamed module of loader 'deployment.JasperReportsIntegration.war' @634b81a1) Caused by: java.lang.RuntimeException: java.lang.ClassCastException: class org.jboss.logmanager.log4j.JBossLoggerContext cannot be cast to class org.apache.logging.log4j.core.LoggerContext (org.jboss.logmanager.log4j.JBossLoggerContext is in unnamed module of loader 'org.jboss.logmanager.log4j2@1.1.1.Final' @621bd734; org.apache.logging.log4j.core.LoggerContext is in unnamed module of loader 'deployment.JasperReportsIntegration.war' @634b81a1) Caused by: java.lang.ClassCastException: class org.jboss.logmanager.log4j.JBossLoggerContext cannot be cast to class org.apache.logging.log4j.core.LoggerContext (org.jboss.logmanager.log4j.JBossLoggerContext is in unnamed module of loader 'org.jboss.logmanager.log4j2@1.1.1.Final' @621bd734; org.apache.logging.log4j.core.LoggerContext is in unnamed module of loader 'deployment.JasperReportsIntegration.war' @634b81a1)"}}}}}}}}

WildFly Versions: 22.0.1.final & 26.1.0.final

Java Version: jdk-11.0.14.1+1

OS Version: Windows Server 2012 R2

daust commented 2 years ago

I see that you are using Java 11. There are issues with logger that I have already identified. #107

Try downgrading to Java 8 and report your finding. Thank you.

sanderleget commented 2 years ago

After testing with JDK 8u322-b06

I do get a similar error,

{"WFLYDC0074: Operation failed or was rolled back on all servers. Server failures:" => {"server-group" => {"reporting_group" => {"host" => {"master" => {"reporting_server_one" => {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"JasperReportsIntegration.war\".undertow-deployment" => "java.lang.RuntimeException: java.lang.ClassCastException: org.jboss.logmanager.log4j.JBossLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext Caused by: java.lang.RuntimeException: java.lang.ClassCastException: org.jboss.logmanager.log4j.JBossLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext Caused by: java.lang.ClassCastException: org.jboss.logmanager.log4j.JBossLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext"}}}}}}}}

daust commented 2 years ago

I could reproduce and fix it on my local machine.

Add a file named jboss-deployment-structure.xml to the jri.war file, put it into the folder WEB-INF.

image

with this contents:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <deployment>
        <exclusions>
            <module name="org.apache.logging.log4j.api" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>

Just FYI, I have tested using the following Java version:

C:\Users\daust>java -version java version "1.8.0_331" Java(TM) SE Runtime Environment (build 1.8.0_331-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.331-b09, mixed mode)

That should fix it.

More information can be found here: 4.2.4. Creating a Log4j2 LogManager implementation in this document: https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.4/pdf/development_guide/development-guide.pdf

I will add it to the next release, so that the new jboss-deployment descriptor is included automatically.

Best ~Dietmar.

daust commented 2 years ago

The bottom line on this issue was the following. We moved to log4j2 and (only) Wildfly has some automatic behavior in regard to that. Thus, it caused a conflict. After the configuration change, it works fine.