Bug 845099

Summary: OSGi fails to resolve LogFactory
Product: [Fedora] Fedora Reporter: Andrew Robinson <andjrobins>
Component: apache-commons-loggingAssignee: Mikolaj Izdebski <mizdebsk>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: java-sig-commits, mat.booth, mizdebsk, SpikeFedora
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-08 14:37:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Andrew Robinson 2012-08-01 18:48:44 UTC
When OSGi tries to resolve org.apache.commons.logging.LogFactory it fails with error similar to below. Does not happen in Rawhide after f18 mass rebuild. Perhaps f17 needs a rebuild?

java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:187)
    at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:141)
    at org.fedoraproject.eclipse.packager.bodhi.api.BodhiClient.getClient(BodhiClient.java:346)
    at org.fedoraproject.eclipse.packager.bodhi.api.BodhiClient.<init>(BodhiClient.java:95)
    at org.fedoraproject.eclipse.packager.bodhi.internal.ui.UserValidationResponse.validate(UserValidationResponse.java:46)
    at org.fedoraproject.eclipse.packager.bodhi.internal.ui.UserValidationResponse.<init>(UserValidationResponse.java:39)
    at org.fedoraproject.eclipse.packager.bodhi.internal.ui.ValidationJob.run(ValidationJob.java:50)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 8 more

Comment 1 Mikolaj Izdebski 2012-08-02 03:44:43 UTC
Which OSGi Framework are you using? I tried Felix and Equinox, both worked for me:

$ cat Test.java
import java.util.*;
import org.osgi.framework.*;
import org.osgi.framework.launch.*;

class Test {
    public static void main(String[] args) throws BundleException, ClassNotFoundException {
	Framework f = ServiceLoader.load(FrameworkFactory.class).iterator().next().newFramework(Collections.EMPTY_MAP);
	f.start();

	Bundle b = f.getBundleContext().installBundle("file:///usr/share/java/apache-commons-logging.jar");
	System.err.println("installBundle() returned " + b);

	Class c = b.loadClass("org.apache.commons.logging.LogFactory");
	System.err.println("loadClass() returned " + c);
	System.exit(0);
    }
}

$ javac -cp `build-classpath felix` Test.java 

$ java -cp `build-classpath felix`:. Test
installBundle() returned org.apache.commons.logging [1]
loadClass() returned class org.apache.commons.logging.LogFactory

$ java -cp `build-classpath eclipse/osgi`:. Test
installBundle() returned org.apache.commons.logging_1.1.1.v20080605-1930 [2]
loadClass() returned class org.apache.commons.logging.LogFactory

In my case the bundle is resolved correctly. Can you provide more details on how exactly you are loading commons-logging bundle? A working reproducer would be great.

Comment 2 Andrew Robinson 2012-08-08 14:37:16 UTC
Seems to be fixed on all the machines I was using. Not sure what was causing it, but I'll close for now.