Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
Index: src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java
===================================================================
--- src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java	(revision 831350)
+++ src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java	(working copy)
@@ -332,8 +332,12 @@
                     }
                     else
                     {
+                        System.out.println(
+                            "Constraint violation for " + importer
+                            + " detected; module can see "
+                            + rp + " and " + rpUses);
                         m_logger.log(
-                            Logger.LOG_DEBUG,
+                            Logger.LOG_ERROR,
                             "Constraint violation for " + importer
                             + " detected; module can see "
                             + rp + " and " + rpUses);
@@ -705,7 +709,7 @@
         catch (ResolveException ex)
         {
             m_logger.log(
-                Logger.LOG_DEBUG,
+                Logger.LOG_ERROR,
                 "Constraint violation for " + targetModule + " detected.",
                 ex);
             return false;
@@ -789,7 +793,7 @@
         catch (ResolveException ex)
         {
             m_logger.log(
-                Logger.LOG_DEBUG,
+                Logger.LOG_ERROR,
                 "Constraint violation for " + targetModule + " detected.",
                 ex);
             return false;
@@ -824,7 +828,7 @@
         catch (ResolveException ex)
         {
             m_logger.log(
-                Logger.LOG_DEBUG,
+                Logger.LOG_ERROR,
                 "Constraint violation for " + targetModule + " detected.",
                 ex);
             return false;
@@ -875,7 +879,7 @@
                     else
                     {
                         m_logger.log(
-                            Logger.LOG_DEBUG,
+                            Logger.LOG_ERROR,
                             "Constraint violation for " + targetModule
                             + " detected; module can see "
                             + rp + " and " + rpUses);
Index: src/main/java/org/apache/felix/framework/ModuleImpl.java
===================================================================
--- src/main/java/org/apache/felix/framework/ModuleImpl.java	(revision 831350)
+++ src/main/java/org/apache/felix/framework/ModuleImpl.java	(working copy)
@@ -1295,7 +1295,7 @@
 
     public String toString()
     {
-        return m_id;
+        return getSymbolicName() + " (" + m_id + ")";
     }
 
     private synchronized ModuleClassLoader getClassLoader()
@@ -1590,12 +1590,12 @@
 
             try
             {
-                dexFileClassLoadDex = dexFileClass.getMethod("loadDex", 
+                dexFileClassLoadDex = dexFileClass.getMethod("loadDex",
                     new Class[]{String.class, String.class, Integer.TYPE});
             }
             catch (Exception ex)
             {
-                // Nothing we need to do 
+                // Nothing we need to do
             }
             dexFileClassConstructor = dexFileClass.getConstructor(
                 new Class[] { java.io.File.class });
@@ -1717,7 +1717,7 @@
 
                         if (clazz == null)
                         {
-                            int activationPolicy = 
+                            int activationPolicy =
                                 ((BundleImpl) getBundle()).isDeclaredActivationPolicyUsed()
                                 ? ((BundleImpl) getBundle()).getCurrentModule().getDeclaredActivationPolicy()
                                 : IModule.EAGER_ACTIVATION;
@@ -1873,8 +1873,8 @@
                 {
                     if (m_dexFileClassLoadDex != null)
                     {
-                        dexFile = m_dexFileClassLoadDex.invoke(null, 
-                            new Object[]{content.getFile().getAbsolutePath(), 
+                        dexFile = m_dexFileClassLoadDex.invoke(null,
+                            new Object[]{content.getFile().getAbsolutePath(),
                                 content.getFile().getAbsolutePath() + ".dex", new Integer(0)});
                     }
                     else

Classloading problems

Frequently, you'll see build problems with attempting to load a class when starting a configuration. Most of the time, this is caused by a bundle resolution problem that occurs earlier, but the information has been swallowed. If you use the -X option on the build, the resolution error will be given earlier in the build and you can generally figure out what's missing from that.

Occasionally, the resolution error will be a very generic "Constraint violation" without much information on what actually failed. Turning on debug logging in Felix will give some information, but I've found that building Felix with the following patch applied helps diagnose the problem more quickly:

Code Block

Index: src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java
===================================================================
--- src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java	(revision 831350)
+++ src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java	(working copy)
@@ -332,8 +332,12 @@
                     }
                     else
                     {
+                        System.out.println(
+                            "Constraint violation for " + importer
+                            + " detected; module can see "
+                            + rp + " and " + rpUses);
                         m_logger.log(
-                            Logger.LOG_DEBUG,
+                            Logger.LOG_ERROR,
                             "Constraint violation for " + importer
                             + " detected; module can see "
                             + rp + " and " + rpUses);
@@ -705,7 +709,7 @@
         catch (ResolveException ex)
         {
             m_logger.log(
-                Logger.LOG_DEBUG,
+                Logger.LOG_ERROR,
                 "Constraint violation for " + targetModule + " detected.",
                 ex);
             return false;
@@ -789,7 +793,7 @@
         catch (ResolveException ex)
         {
             m_logger.log(
-                Logger.LOG_DEBUG,
+                Logger.LOG_ERROR,
                 "Constraint violation for " + targetModule + " detected.",
                 ex);
             return false;
@@ -824,7 +828,7 @@
         catch (ResolveException ex)
         {
             m_logger.log(
-                Logger.LOG_DEBUG,
+                Logger.LOG_ERROR,
                 "Constraint violation for " + targetModule + " detected.",
                 ex);
             return false;
@@ -875,7 +879,7 @@
                     else
                     {
                         m_logger.log(
-                            Logger.LOG_DEBUG,
+                            Logger.LOG_ERROR,
                             "Constraint violation for " + targetModule
                             + " detected; module can see "
                             + rp + " and " + rpUses);
Index: src/main/java/org/apache/felix/framework/ModuleImpl.java
===================================================================
--- src/main/java/org/apache/felix/framework/ModuleImpl.java	(revision 831350)
+++ src/main/java/org/apache/felix/framework/ModuleImpl.java	(working copy)
@@ -1295,7 +1295,7 @@
 
     public String toString()
     {
-        return m_id;
+        return getSymbolicName() + " (" + m_id + ")";
     }
 
     private synchronized ModuleClassLoader getClassLoader()
@@ -1590,12 +1590,12 @@
 
             try
             {
-                dexFileClassLoadDex = dexFileClass.getMethod("loadDex", 
+                dexFileClassLoadDex = dexFileClass.getMethod("loadDex",
                     new Class[]{String.class, String.class, Integer.TYPE});
             }
             catch (Exception ex)
             {
-                // Nothing we need to do 
+                // Nothing we need to do
             }
             dexFileClassConstructor = dexFileClass.getConstructor(
                 new Class[] { java.io.File.class });
@@ -1717,7 +1717,7 @@
 
                         if (clazz == null)
                         {
-                            int activationPolicy = 
+                            int activationPolicy =
                                 ((BundleImpl) getBundle()).isDeclaredActivationPolicyUsed()
                                 ? ((BundleImpl) getBundle()).getCurrentModule().getDeclaredActivationPolicy()
                                 : IModule.EAGER_ACTIVATION;
@@ -1873,8 +1873,8 @@
                 {
                     if (m_dexFileClassLoadDex != null)
                     {
-                        dexFile = m_dexFileClassLoadDex.invoke(null, 
-                            new Object[]{content.getFile().getAbsolutePath(), 
+                        dexFile = m_dexFileClassLoadDex.invoke(null,
+                            new Object[]{content.getFile().getAbsolutePath(),
                                 content.getFile().getAbsolutePath() + ".dex", new Integer(0)});
                     }
                     else

Logging conversion

When converting plugins make sure to avoid the following dependencies: log4j, jcl-over-slf4j,
jul-to-slf4j, slf4j-api, or slf4j-log4j12. Instead use pax-logging-api. This bundle exports all of these logging API.

...