Hello Adobe Community,
We are trying to implement a servlet which needs to read csv file. To read csv file we have added dependency in core pom.xml
I’m facing an issue with a servlet deployment in AEM Cloud.The deployment completes successfully, but after deployment, the servlet remains in an satisfied state. Upon reviewing the error logs, I found the following stack trace related to an unresolved dependency:
org.apache.felix.log.LogException: java.lang.NoClassDefFoundError: com/opencsv/CSVReader
It seems the system is unable to resolve the OpenCSV dependency, specifically the CSVReader class, despite the deployment succeeding without any apparent issues.
java.lang.NoClassDefFoundError: com/opencsv/CSVReader
This suggests that the CSVReader class is not being found at runtime, even though the JAR appears to be bundled correctly.
Questions:
Has anyone encountered a similar issue with OSGi and OpenCSV?
Is there any other way I can troubleshoot or fix the unresolved dependency in the OSGi container?
29.04.2025 15:19:41.285 *WARN* [FelixLogListener] com..aem..core.servlets.BinAuthenticationServlet bundle com..aem..core:2.0.0.SNAPSHOT (622)[com..aem..core.servlets.BinAuthenticationServlet(4261)] : Failure loooking up method deactivate(org.osgi.service.component.ComponentContext) in class class com..aem..core.servlets.BinAuthenticationServlet. Assuming no such method. (org.apache.felix.log.LogException: java.lang.NoClassDefFoundError: com/opencsv/CSVReader)
org.apache.felix.log.LogException: java.lang.NoClassDefFoundError: com/opencsv/CSVReader
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
at java.base/java.lang.Class.getDeclaredMethod(Class.java:2473)
at org.apache.felix.scr.impl.inject.methods.BaseMethod.getMethod(BaseMethod.java:359) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.inject.methods.ActivateMethod.doFindMethod(ActivateMethod.java:70) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.inject.methods.BaseMethod.findMethod(BaseMethod.java:185) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$400(BaseMethod.java:41) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.inject.methods.BaseMethod$NotResolved.resolve(BaseMethod.java:638) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.inject.methods.BaseMethod$NotResolved.methodExists(BaseMethod.java:662) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.inject.methods.BaseMethod.methodExists(BaseMethod.java:563) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:315) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:307) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.SingleComponentManager.disposeImplementationObject(SingleComponentManager.java:421) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.SingleComponentManager.deleteComponent(SingleComponentManager.java:165) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.doDeactivate(AbstractComponentManager.java:853) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.deactivateInternal(AbstractComponentManager.java:825) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.DependencyManager.deactivateComponentManager(DependencyManager.java:2649) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.DependencyManager.access$400(DependencyManager.java:59) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.removedService(DependencyManager.java:1369) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.removedService(DependencyManager.java:1238) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1258) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1152) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.untrack(ServiceTracker.java:1012) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1192) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:117) [org.apache.felix.scr:2.2.12]
at org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990)
at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838)
at org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4863)
at org.apache.felix.framework.Felix.access$000(Felix.java:111)
at org.apache.felix.framework.Felix$1.serviceChanged(Felix.java:440)
at org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:170)
at org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:146)
at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.unregister(AbstractComponentManager.java:952) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.unregister(AbstractComponentManager.java:915) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:140) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.unregisterService(AbstractComponentManager.java:994) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.doDeactivate(AbstractComponentManager.java:844) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.deactivateInternal(AbstractComponentManager.java:825) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.dispose(AbstractComponentManager.java:589) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.disposeComponents(ConfigurableComponentHolder.java:722) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.BundleComponentActivator.dispose(BundleComponentActivator.java:505) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.Activator.disposeComponents(Activator.java:672) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.Activator.access$300(Activator.java:75) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.Activator$ScrExtension.destroy(Activator.java:510) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.AbstractExtender$1.run(AbstractExtender.java:216) [org.apache.felix.scr:2.2.12]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.felix.scr.impl.AbstractExtender.destroyExtension(AbstractExtender.java:238) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.AbstractExtender.bundleChanged(AbstractExtender.java:132) [org.apache.felix.scr:2.2.12]
at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:256) [org.apache.felix.scr:2.2.12]
at org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915)
at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834)
at org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:516)
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4847)
at org.apache.felix.framework.Felix.stopBundle(Felix.java:2812)
at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:1046)
at org.apache.felix.webconsole.internal.core.BaseUpdateInstallHelper.run(BaseUpdateInstallHelper.java:152) [org.apache.felix.webconsole:5.0.10]
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ClassNotFoundException: com.opencsv.CSVReader not found by com..aem..core [622]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1591)
at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1976)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)
... 59 common frames omitted
Views
Replies
Total Likes
Hi @RamanZa1,
Can you try?
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.7.1</version>
<scope>compile</scope>
</dependency>
scope changed to compile than provided. This will ensure that OpenCSV is included in the final OSGi bundle and can be accessed at runtime.
The issue you're facing is related to the OpenCSV dependency being in the "provided" scope, which means it won't be included in the final bundle deployed to AEM Cloud. The provided
scope typically tells Maven to include the dependency during compilation and testing but not at runtime. Since you're encountering a ClassNotFoundException
for com.opencsv.CSVReader
, it indicates that the dependency is missing at runtime.
Hope that helps!
Views
Replies
Total Likes
Hi @SantoshSai ,
Still not working after adding the compile to scope from dependency
Views
Replies
Total Likes
Hello @RamanZa1
The problem is that your Servlet can't find the CSVReader class from the OpenCSV library
org.apache.felix.log.LogException: java.lang.NoClassDefFoundError: com/opencsv/CSVReader
1. Ensure OpenCSV is included in your OSGi bundle
2. Remove 'provided' scope in the pom.xml
<scope>provided</scope>
The provided scope means "this will be present in the runtime environment" - but AEM does not provide OpenCSV by default.
Just declare the dependency without a <scope> (so it defaults to compile), and it should be picked up by the bundle plugin during the build
Views
Replies
Total Likes
Hi @muskaanchandwani ,
Still not working after removing the scope from dependency
Views
Replies
Total Likes
Hello @RamanZa1
After removing provided scope, can you try :
1. Add <Embed-Dependency>opencsv</Embed-Dependency> and <Embed-Transitive>true in maven-bundle-plugin in core/pom.xml
2. Add <Import-Package>!com.opencsv*,*</Import-Package> in the same plugin config
3. Run mvn clean install -PautoInstallBundle -pl core to build and deploy the core bundle
Views
Replies
Total Likes
For the missing dependency, we can install it in AEM using
<!-- Embed section of all/pom.xml-->
<embedded>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<type>jar</type>
<target>/apps/techrevel-packages/application/install</target>
</embedded>
<!-- Dependency section of all/pom.xml-->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
</dependency>
You would need to replace the groupId and artifactId as needed.
Views
Replies
Total Likes
Hi @aanchal-sikka ,
Still not working after adding the embeded packages and dependency as you mentioned
Views
Replies
Total Likes
Hi @RamanZa1 ,
The root cause of your issue is the use of the <scope>provided</scope> for the OpenCSV dependency in your core/pom.xml. In AEM as a Cloud Service (AEMaaCS), any dependency with provided scope will not be bundled into the OSGi JAR, which is why the servlet fails at runtime with a NoClassDefFoundError.
Solution
Update the dependency scope to compile so it gets packaged into your OSGi bundle:
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.7.1</version>
<scope>compile</scope> <!-- or just omit <scope> entirely -->
</dependency>
This ensures that OpenCSV is embedded in the bundle and available to your servlet at runtime.
Optional: Confirm It’s Being Bundled
To verify the dependency is included:
Check the JAR output in core/target/ using a tool like jar tf.
Or, inspect the Export-Package and Import-Package in the built bundle’s MANIFEST.MF.
Runtime Best Practice
Always avoid using provided for third-party libraries unless AEM already includes them (which OpenCSV is not).
You do not need to manually embed OpenCSV using the all/pom.xml unless you're doing advanced packaging or sharing across multiple bundles.
Regards,
Amit
Views
Replies
Total Likes
Hi @AmitVishwakarma
Still not working after removing the scope from dependency
Views
Replies
Total Likes
Hi @RamanZa1
I came across a similar issue recently where a servlet stayed in a satisfied state due to unresolved class dependencies. This article explains a solid approach that can help in such cases: AEM: Adding 3rd party jar using bnd-maven-plugin.
Key takeaways from the article:
Add the required third-party dependency (like OpenCSV) in your pom.xml without setting it to <scope>provided</scope>.
Use the bnd-maven-plugin and include instructions like -includeresource and -conditionalpackage to ensure the classes get embedded correctly in your OSGi bundle.
This approach worked well for another dependency I was dealing with, and for OpenCSV, it should help resolve the NoClassDefFoundError issue and get the servlet to activate properly in AEM Cloud.
Hope this helps!
Views
Replies
Total Likes
Views
Likes
Replies