Failed load org.apache.commons.logging.impl.LogFactoryImpl

Hi all,

Sorry guys, I’m out of luck and looking for some help here.
I already placed all the required jar files under lib folder

and this is my code ( ya, just few lines ) Any ideas ?

Best Regards,
Ivan

public void viewDidLoad(){
	
	LogFactory.releaseAll();
	LogManager.getLogManager().reset();
           HttpClient httpclient = HttpClients.createDefault();
  }

and this is how my build.gradle look like, basically just the default setting :

buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
// Multi-OS Engine plugin
classpath group: ‘org.multi-os-engine’, name: ‘moe-gradle’, version: ‘1.3.+’
}
}

// Apply plugins
apply plugin: ‘eclipse’
apply plugin: ‘moe’

// Set source and target to Java 8
sourceCompatibility = “1.8”
targetCompatibility = “1.8”

// Set maven repository
repositories {
jcenter()
}

// Exclude all files from Gradle’s test runner
test { exclude ‘**’ }

// Setup Multi-OS Engine
moe {
xcode {
project ‘xcode/test-apache-httpclient.xcodeproj’
mainTarget ‘test-apache-httpclient’
testTarget ‘test-apache-httpclient-Test’

    // Uncomment and change these settings if you are working with a Xcode workspace
    // workspace 'xcode/test-apache-httpclient.xcworkspace'
    // mainScheme 'test-apache-httpclient'
    // testScheme 'test-apache-httpclient-Test'
}

}

dependencies {
// Compile with ‘jar’ files in the project’s ‘lib’ directory
compile fileTree(dir: ‘lib’, include: ‘*.jar’)
}

// Setup Eclipse
eclipse {
// Set Multi-OS Engine nature
project {
natures ‘org.multi-os-engine.project’
}
}

===================================================

org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl (Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl)
at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1158)
at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:960)
at java.security.AccessController.doPrivileged(AccessController.java:45)
at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:957)
at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:624)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
at org.apache.http.impl.client.CloseableHttpClient.(CloseableHttpClient.java:59)
at org.apache.http.impl.client.AbstractHttpClient.(AbstractHttpClient.java:232)
at org.apache.http.impl.client.DefaultHttpClient.(DefaultHttpClient.java:148)
at com.xyprox.test.httpclient.ui.AppViewController.viewDidLoad(AppViewController.java:51)
at ap
ple.uikit.c.UIKit.UIApplicationMain(Native Method)
at com.xyprox.test.httpclient.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:792)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:852)
at java.lang.ClassLoader.loadClass(ClassLoader.java:480)
at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1020)
… 11 more
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/commons/logging/impl/LogFactoryImpl;
… 16 more

BUILD SUCCESSFUL

Total time: 14.089 secs

This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html

I’ve had this as well (but with org.apache.httpcomponents:httpclient:4.5.2). Some things I did to get around this:

In ios/proguard.append.cfg, add:

# Apache HTTP
-keep class org.apache.http.** { *; }
-keep interface org.apache.http.** { *; }
-keep class * extends org.apache.commons.logging.LogFactory { *; }
-keep class org.apache.commons.logging.impl.NoOpLog { *; }
-keep class org.apache.commons.logging.impl.ServletContextCleaner { *; }
-keep interface javax.servlet.ServletContextListener { *; }
-keep class javax.servlet.ServletContextEvent { *; }

In the AppDelegate or Main, turn off logging:
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");

In ios/build.gradle, add servlet dependency (since Apache assumes it’s already there, but it’s not):

dependencies {
    compile 'javax.servlet:servlet-api:2.3'
}
1 Like

Great!! I will give it a try! Thanks again! Thank you so much!