After 6.4 upgrade, junits giving below mentioned error (Using Mockito for junits). This used to work in AEM 6.3. We looked at the packages inside Uber-jar-6.4.3-apis.jar (inside maven dependencies of eclipse ), and noticed that package "org.apache.sling.api.wrappers" is showing empty? ObjectConverter class which is not found is being referred from this package. Since the package is not present, we won't find this class. Is there any way we can fix it?
java.lang.NoClassDefFoundError: org/apache/sling/api/wrappers/impl/ObjectConverter
I believe this wrapper package implementation gets resolved via other transitive dependencies
check this --
/** | |
* This is copied from org.apache.sling.api.wrappers.impl.ObjectConverter | |
* to avoid dependency to latest Sling API. | |
* This can be removed when Sling API 2.17.0 or higher is referenced. | |
*/ |
Views
Replies
Total Likes
gauravb10066713 - What changes do you suggest to fix this, because our junits are looking for ObjectConverter in this package org/apache/sling/api/wrappers/impl/ObjectConverter through transitive dependency.
Views
Replies
Total Likes
You would need to update/fix your pom.xml per requirement with specific library versions and specific scope. It also depends on what maven archetype do you currently use and other osgi/scr annotation versions.
You may want to check WKND tutorial poms and take a reference about what versions are included. Alternatively, you may share your project code/pom.xmls so that I could check it.
Views
Replies
Total Likes
We are on 6.4.3 and using 6.4.3 uber jar. And we are using the following dependencies in our POM. Can you please review to see if we are using any incorrect version or do you have any working example of Junits in 6.4?
<!-- ====================================================================== -->
<!-- D E P E N D E N C I E S -->
<!-- ====================================================================== -->
<dependencyManagement>
<dependencies>
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr</artifactId>
<version>1.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.9.6</version>
<scope>provided</scope>
</dependency>
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.annotation</artifactId>
<version>6.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Logging Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>6.4.3</version>
<classifier>apis</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.all</artifactId>
<type>zip</type>
<version>2.2.2</version>
</dependency>
<!-- Apache Sling Dependencies -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.api</artifactId>
<version>1.3.6</version>
<scope>provided</scope>
</dependency>
<!-- Servlet API -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<!-- JCR -->
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<!-- Taglibs -->
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-taglib</artifactId>
<version>5.7.4</version>
<scope>provided</scope>
</dependency>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.sling-mock.junit4</artifactId>
<version>2.3.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
<version>1.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>
<!-- -->
<!-- Handlebars dependency starts here. -->
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.abego.treelayout/org.abego.treelayout.core -->
<dependency>
<groupId>org.abego.treelayout</groupId>
<artifactId>org.abego.treelayout.core</artifactId>
<version>1.0.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mozilla/rhino -->
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<version>1.7R4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars</artifactId>
<version>4.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.antlr/antlr4-runtime -->
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.5.1</version>
<scope>compile</scope>
</dependency>
<!-- Dependencies need to remediate -->
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.sling.commons</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.testing</artifactId>
<version>2.1.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>rhino</groupId>
<artifactId>js</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock</artifactId>
<version>1.7.0</version>
<scope>provided</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Dependencies need to remediate -->
</dependencies>
</dependencyManagement>
Views
Replies
Total Likes
I would require the complete code package to test/understand how do you use ObjectConverter. I may not be able to help just by looking at pom.xml library versions.
Views
Replies
Total Likes
Look here to learn how to work with these testing APIs.
Adobe Experience Manager Help | Getting Started with AEM Sites Chapter 8 - Unit Testing
In addition - good news - for those reading this thread. In March of 2019 - we are holding an Ask the AEM Community Experts on this subject.
Views
Replies
Total Likes
HI,
did you find an answer to this error?
I am facing the same issue.
I am upgrading from AEM 6.2 to AEM 6.5.
java.lang.NoClassDefFoundError: org/apache/sling/api/wrappers/impl/ObjectConverter
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.sling.api.wrappers.ValueMapDecorator.get(ValueMapDecorator.java:56)
at org.apache.sling.testing.resourceresolver.DeepReadModifiableValueMapDecorator.get(DeepReadModifiableValueMapDecorator.java:73)
at org.apache.sling.testing.resourceresolver.MockValueMap.get(MockValueMap.java:87)
at org.apache.sling.testing.resourceresolver.MockResource.getResourceType(MockResource.java:71)
at x.x.x.x.models.TestHelloWorldModel.testHelloWorld(TestHelloWorldModel.java:44)
Regards,
Prateek
Views
Replies
Total Likes
Try adding this to your POM (notice its scoped to test)
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
<version>2.18.4</version>
<scope>test</scope>
</dependency>
It worked ! Thanks
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies