Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VerifyError on Tomcat 7 production server probably caused by Apache Commons Logging 1.0.4

Tags:

I'm developing webapp on Tomcat 7. Everything works fine on my local version of Tomcat, but when I deploy it on production server, it throws this exception.

java.lang.VerifyError: (class: org/apache/commons/logging/impl/Log4JLogger, method: fatal signature: (Ljava/lang/Object;Ljava/lang/Throwable;)V) Incompatible object argument for function call
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
    at java.lang.Class.getConstructor0(Class.java:2895)
    at java.lang.Class.getConstructor(Class.java:1731)
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:410)
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
    at org.apache.fop.apps.FopFactory.<clinit>(FopFactory.java:68)
    at cz.soma.tomcat.generator.DokumentaceUtils.createPdfDocument(DokumentaceUtils.java:818)
    at cz.soma.tomcat.generator.FileFactory.createPdfDocument(FileFactory.java:58)
    at cz.soma.tomcat.generator.Generator.doPost(Generator.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

The error is thrown, when I try to FopFactory.newInstance(); (from Apache FOP 1.0). After that, it tries to LogFactory.getLog(FopFactory.class);. It causes, that logClass.getConstructor(logConstructorSignature); is called, where logConstructorSignature contains one String.class. (at least on my local machine)

try {
    logConstructor = logClass.getConstructor(logConstructorSignature);
    return (logConstructor);
} catch (Throwable t) {
    throw new LogConfigurationException
        ("No suitable Log constructor " +
         logConstructorSignature+ " for " + logClassName, t);
}

After this are called the java.lang.Class functions and thrown exception. Have you any idea, why the error is only thrown on production server, but not on my local machine?

like image 277
Přemysl Šťastný Avatar asked Mar 03 '17 09:03

Přemysl Šťastný


2 Answers

Why this error(java.lang.VerifyError) occurs?

java.lang.VerifyError would be the result when you have compiled against a different library than you are using at runtime(in your production server).

Suggestion#1:

You can use commons-logging-1.1.1.jar instead of commons-logging-1.0.4.jar. Then rebuild your project and check.

Resource Link: http://www.java-samples.com/showtutorial.php?tutorialid=674

Suggestion#2:

If you are using maven,then add this dependency in your pom.xml,

<dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
</dependency>

and remove the following dependency from your pom.xml

<dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.0.4</version>
</dependency>

Resource Link: Getting java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory exception

Suggestion#3:

templatetypedef has dig the issue and give 2 solutions

A VerifyError usually means that you loaded in a class file that is somehow malformed or which references another class file that has changed in a way that causes the code in another class file to no longer be valid. For example, if you compiled a class file that referenced a method in some other class, then independently modified and recompiled the second class after altering that method's signature, you'd get this sort of error.

I'd suggest doing a clean build and seeing if this issue goes away. If not, check whether you're using up-to-date JARs and source files.

Resource Link: https://stackoverflow.com/a/5411528/2293534

Suggestion#4:

If your JDK version mismatch between local and production server, then make it same if possible. You may also try compiling with a different JDK version and on a different machine.

Resource Link: Causes of getting a java.lang.VerifyError

Hopefully it will help you.

like image 190
SkyWalker Avatar answered Sep 19 '22 17:09

SkyWalker


You probably have a different version of the logging jars in the common lib directory on the production Tomcat server. Have someone check the \lib directory and see if there are any logging jars in the lib directory. Either remove those jars so your local app jars are used or make sure the same version of dependencies are being defined in your application.

If you want to try reproducing locally replicate the set of jars in the production lib directory to your local install.

like image 29
M. Rizzo Avatar answered Sep 20 '22 17:09

M. Rizzo