FELIX-2119 Prevent ClassDefNotFoundException if OBR API is not available: Use constant string for service name instead of PackageAdmin.class expression, which requires the class to load
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@918449 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/UpdateHelper.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/UpdateHelper.java
index 73d7d74..4a9ba3e 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/UpdateHelper.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/UpdateHelper.java
@@ -38,6 +38,10 @@
abstract class UpdateHelper extends BaseUpdateInstallHelper
{
+ // Define a constant of that name to prevent NoClassDefFoundError in
+ // updateFromOBR trying to load the class with RepositoryAdmin.class
+ private static final String REPOSITORY_ADMIN_NAME = "org.osgi.service.obr.RepositoryAdmin";
+
private final Bundle bundle;
@@ -128,7 +132,7 @@
private boolean updateFromOBR()
{
- RepositoryAdmin ra = ( RepositoryAdmin ) getService( RepositoryAdmin.class.getName() );
+ RepositoryAdmin ra = ( RepositoryAdmin ) getService( REPOSITORY_ADMIN_NAME );
if ( ra != null )
{
getLog().log( LogService.LOG_DEBUG, "Trying to update from OSGi Bundle Repository" );
@@ -179,7 +183,7 @@
}
else
{
- getLog().log( LogService.LOG_DEBUG, "Cannot updated from OSGi Bundle Repository: Service not available" );
+ getLog().log( LogService.LOG_INFO, "Cannot update from OSGi Bundle Repository: Service not available" );
}
// fallback to false, nothing done
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/obr/BundleRepositoryRender.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/obr/BundleRepositoryRender.java
index c87fa69..1410110 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/obr/BundleRepositoryRender.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/obr/BundleRepositoryRender.java
@@ -49,6 +49,10 @@
private static final String TITLE = "OSGi Repository";
private static final String[] CSS = null;
+ // Define a constant of that name to prevent NoClassDefFoundError in
+ // updateFromOBR trying to load the class with RepositoryAdmin.class
+ private static final String REPOSITORY_ADMIN_NAME = "org.osgi.service.obr.RepositoryAdmin";
+
// templates
private final String TEMPLATE;
@@ -115,7 +119,7 @@
{
try
{
- return (RepositoryAdmin) super.getService(RepositoryAdmin.class.getName());
+ return ( RepositoryAdmin ) super.getService( REPOSITORY_ADMIN_NAME );
}
catch (Throwable t)
{