mmornati / springboot-osgi-sample

OSGi framework integrated into SpringBoot application
Apache License 2.0
38 stars 18 forks source link

class cast exception #18

Closed kgarg-us closed 1 year ago

kgarg-us commented 1 year ago

Ran into this issue, so any help is appreciated. Environment; Windows OpenJDK 17; Springboot 2.7.9 (all other settings remain the same) java.lang.ClassCastException: class com.mornati.sample.plugin.psp.sample.Sample cannot be cast to class com.mornati.sample.commons.plugins.IPlugin (com.mornati.sample.plugin.psp.sample.Sample is in unnamed module of loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader @31065c31; com.mornati.sample.commons.plugins.IPlugin is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @18769467) at com.mornati.sample.service.SpringAwareBundleListener.lambda$bundleChanged$0(SpringAwareBundleListener.java:42) at java.base/java.util.Arrays$ArrayList.forEach(Arrays.java:4204)

To begin, I first ran into the issue below. I added an ExportPackage statement in the sample-bundle POM for the commons package. Error while starting bundle: file://springboot-osgi-sample-main/plugins/sample-bundle-0.0.1-SNAPSHOT.jar: org.osgi.framework.BundleException: Unable to resolve sample-bundle [6](R 6.0): missing requirement [sample-bundle [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=com.mornati.sample.commons.plugins) Unresolved requirements: [[sample-bundle [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=com.mornati.sample.commons.plugins)] org.osgi.framework.BundleException: Unable to resolve sample-bundle [6](R 6.0): missing requirement [sample-bundle [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=com.mornati.sample.commons.plugins) Unresolved requirements: [[sample-bundle [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=com.mornati.sample.commons.plugins)] at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4398)

kgarg-us commented 1 year ago

Nevermind, it's resolved now.