force to use the classloader of the bundle to load the activator in OSGiBundleLifecycle + add an empty beans.xml in servlet module to ensure it is picked up even in cdi/servlet containers
diff --git a/winegrower-core/src/main/java/org/apache/winegrower/deployer/OSGiBundleLifecycle.java b/winegrower-core/src/main/java/org/apache/winegrower/deployer/OSGiBundleLifecycle.java
index 78ff557..ca1c3b3 100644
--- a/winegrower-core/src/main/java/org/apache/winegrower/deployer/OSGiBundleLifecycle.java
+++ b/winegrower-core/src/main/java/org/apache/winegrower/deployer/OSGiBundleLifecycle.java
@@ -55,15 +55,15 @@
final String activatorClass = context.getManifest().getMainAttributes().getValue("Bundle-Activator");
if (activatorClass != null) {
try {
- activator = new BundleActivatorHandler(BundleActivator.class.cast(
- Thread.currentThread().getContextClassLoader()
+ activator = new BundleActivatorHandler(BundleActivator.class.cast(getBundle().getLoader()
.loadClass(activatorClass)
.getConstructor()
.newInstance()), context);
activator.start();
- } catch (final InstantiationException | IllegalAccessException | NoSuchMethodException | ClassNotFoundException e) {
+ } catch (final NoClassDefFoundError | InstantiationException | IllegalAccessException |
+ NoSuchMethodException | ClassNotFoundException e) {
throw new IllegalArgumentException(e);
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
throw new IllegalArgumentException(e.getTargetException());
}
}
diff --git a/winegrower-extension/winegrower-servlet/src/main/resources/META-INF/beans.xml b/winegrower-extension/winegrower-servlet/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..2bb54d8
--- /dev/null
+++ b/winegrower-extension/winegrower-servlet/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,19 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans />