0

I am a beginner in the big data area and I have a task of reducing the war size of a JEE project. I am getting the following error :

ERROR [stderr] (ServerService Thread Pool -- 81) log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.
ERROR [stderr] (ServerService Thread Pool -- 81) log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by 
ERROR [stderr] (ServerService Thread Pool -- 81) log4j:ERROR [ModuleClassLoader for Module "com.bigdata.hdfs.listener.hdfs-listener" from local module loader @56ef9176 (finder: local module finder @4566e5bd (roots: /opt/wildfly-20.0.1.Final/modules,/opt/wildfly-20.0.1.Final/modules/system/layers/base))] whereas object of type 
ERROR [stderr] (ServerService Thread Pool -- 81) log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [ModuleClassLoader for Module "org.jboss.log4j.logmanager" version 1.2.0.Final from local module loader @56ef9176 (finder: local module finder @4566e5bd (roots: /opt/wildfly-20.0.1.Final/modules,/opt/wildfly-20.0.1.Final/modules/system/layers/base))].
ERROR [stderr] (ServerService Thread Pool -- 81) log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator].
17:31:03,059 ERROR [stderr] (ServerService Thread Pool -- 81) log4j:WARN No appenders could be found for logger (com.bigdata.hdfs.listener.HdfsListenerMain$).
ERROR [stderr] (ServerService Thread Pool -- 81) log4j:WARN Please initialize the log4j system properly.

The main idea of this JEE project is, this has a hdfs-listener scala jar file added as a maven dependency in the pom.xml, whose (the scala jar file) main scala class is being called from a Java class.The JEE war file is deployed in wildfly server and at startup, the scala jar file's main class is invoked. When the wildfly server runs, parallely spark and hadoop has to run, since there is a need to add an xml file to hdfs directory, once the scala main class is invoked and by triggering that event, spark processes it to print an output in the wildfly server terminal (Architecture-Spark operates on top of Hadoop).

To reduce the war size, added scope tags to all pom dependencies, and added the required modules to the jboss-deployment-structure.xml after adding these modules to the $WILDFLY_HOME/modules/system/layers/base and added the following tag to the maven-war-plugin to exclude the lib folder of the war file.

enter code here
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
enter code here

Due to this the actual war size which was 121.4mb is reduced to 4.9kb

Following is the pom dependency for the log4j :

enter code here
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
    <scope>provided</scope>
</dependency>
enter code here
5
  • You probably don't mean J2EE, which is outdated for probably 15 years... May 4, 2021 at 12:29
  • Yes, thank you, I meant a Java Enterprise Edition project, and it is being called as JEE rather than J2EE (J2EE was due to java version 2) right? Thank You @J Fabian Meier for the information.
    – Lakkuga
    May 4, 2021 at 13:03
  • I'd guess you have somehow configured the modules in a wrong way. Also, why would you want to reduce the file size of your war file? As long as you don't use the libraries in more than one application, it makes not that much sense to include these dependencies as modules. It's just putting them out of your build process, which is, most likely, a bad idea since you'd have to reconfigure your WildFly with each iteration.
    – maio290
    May 4, 2021 at 13:08
  • @maio290 "Also, why would you want to reduce the file size of your war file?" : to enable speed download of the file by the client. Adding these dependencies to modules in the wildfly server means, adding them to the wildfly server classpath right? I thought putting these modules in the classpath will reduce the size of lib folder, since the pom dependencies fall into the target/WEB-INF/lib when deployed in wildfly server. Can you tell me how to reduce the war file size if this way is bad, because I have been struggling with this for two weeks?
    – Lakkuga
    May 5, 2021 at 7:47
  • Does anybody have a solution for the error please?
    – Lakkuga
    May 10, 2021 at 4:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.