0

I am using Birt viewer runtime in my web application along with Mechanize and have used log4j for logging in my application. It all was working fine, but then I used java mailing api in my application and I keep receiving this exception: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.

I initially was using mail.jar which was fine, for another requirement in my project, I started using mail.1.3.3.jar and it started throwing this exception. I think there is some jar conflict among Mechanize and latest java mail jars.

I need to use either mail.1.3.3.jar or java-mail-1.4.jar.

Please advice how shall I overcome this ??

Thanks.

Puneet Nebhani
  • 487
  • 1
  • 7
  • 17
  • It seems, you have several versions of `commons-logging` in your classpath. – Henry Jan 04 '14 at 08:46
  • This issue is encountered only on one of the servers which is identical to other environments and all other environments are working perfectly fine. – Puneet Nebhani Jan 04 '14 at 13:22
  • In my experience there is no such thing like an "identical server configuration". Some differences always creep in. Does the server have tool support to inspect the class path that gets used for the application? – Henry Jan 04 '14 at 17:55
  • There's no use of Apache Commons Logging in the JavaMail jar files, so I suspect the real problem is somewhere else. – Bill Shannon Jan 06 '14 at 04:32

1 Answers1

0

I was able to get rid of it.

Actually, the jar of Mechanize (version 0.11.1) contains pom.xml, which I referred and got enlightened about its usage on HttpClient jars. I used the HTTPClient jars of version 4.2.1 in my web application and it is working now.

The point to note here is: the pom.xml has a dependency:

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.0.1</version>
    <dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpmime</artifactId>
        <version>4.0.1</version>
    <dependency>
</dependencies>

<profiles>
    <profile>
    <id>latestHttpClient</id>
    <dependencies>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.2.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.2.1</version>
        </dependency>
    </dependencies>
    <profile>
<profiles>

This seems to be a bottleneck now because on one environment, the old versioned jars are working and on other environment, new ones. :(

Puneet Nebhani
  • 487
  • 1
  • 7
  • 17