aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2023-01-03 13:05:03 +0100
committergjoranv <gv@verizonmedia.com>2023-01-09 00:17:39 +0100
commit381ef443535f3cfc325466e7629fe07be4cd4686 (patch)
treea2215c859737bc96ffa551b89dcb6e917d9de003
parenta036ba2190b4676cf394e72dbed77a26c3a94eb3 (diff)
Include list of installed application bundles in error message
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java10
-rw-r--r--container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java15
2 files changed, 20 insertions, 5 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java
index e2f97c9ad6b..903169b1795 100644
--- a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java
+++ b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java
@@ -15,6 +15,7 @@ import com.yahoo.container.di.config.SubscriberFactory;
import com.yahoo.container.logging.AccessLog;
import com.yahoo.filedistribution.fileacquirer.FileAcquirer;
import com.yahoo.jdisc.application.OsgiFramework;
+import com.yahoo.jdisc.core.BsnVersion;
import com.yahoo.jdisc.handler.RequestHandler;
import com.yahoo.jdisc.service.ClientProvider;
import com.yahoo.jdisc.service.ServerProvider;
@@ -29,6 +30,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.stream.Collectors;
/**
* For internal use only.
@@ -107,6 +109,14 @@ public class HandlersConfigurerDi {
public Set<Bundle> completeBundleGeneration(GenerationStatus status) {
return applicationBundleLoader.completeGeneration(status);
}
+
+ @Override
+ protected String bundleResolutionErrorMessage() {
+ return String.format("Installed application bundles: [%s].",
+ applicationBundleLoader.activeBundlesBsnVersion().stream()
+ .map(BsnVersion::toReadableString)
+ .collect(Collectors.joining(", ")));
+ }
}
/**
diff --git a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java
index 2c7a0c2b86b..f0f9de9fe36 100644
--- a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java
+++ b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java
@@ -67,8 +67,8 @@ public class OsgiImpl implements Osgi {
}
/**
- * Tries to resolve the given class from this class' bundle classloader.
- * If unsuccessful, resolves the class from .
+ * Tries to resolve the given class from this class' bundle.
+ * If unsuccessful, resolves the class from the system bundle (jdisc_core).
*/
@SuppressWarnings("unchecked")
private Class<Object> resolveFromThisBundleOrSystemBundle(BundleInstantiationSpecification spec) {
@@ -86,9 +86,14 @@ public class OsgiImpl implements Osgi {
}
}
throw new IllegalArgumentException(
- "Could not create a component with id '" + spec.classId.getName() + "'. Tried to load class directly, " +
- "since no bundle was found for spec: " + spec.bundle + ". If a bundle with the same name is installed, " +
- "there is a either a version mismatch or the installed bundle's version contains a qualifier string.");
+ "Could not create a component with id '" + spec.classId.getName() +
+ "'. Tried to load class directly, since no bundle was found for spec: " + spec.bundle +
+ ". " + bundleResolutionErrorMessage());
+ }
+
+ protected String bundleResolutionErrorMessage() {
+ return " If a bundle with the same name is installed, there is a either a version mismatch " +
+ "or the installed bundle's version contains a qualifier string.";
}
@SuppressWarnings("unchecked")