Hi All,
In one of our OSGI component we have used ListUtils class and also required dependencies will also be added in parent and core poms.
But we are getting run time exception "java.lang.NoClassDefFoundError: org/apache/commons/ListUtils" ,particular dependency has been downloaded into .m2 repository.
And i have searched in online not understand that pom definitions of "commons-collections" needs to be modified to make this classes available in my project.
But not sure how to proceed for making these changes,if anyone come across these kind of issue,please help me.
Below dependency has been added in parent and core poms.
Parent:
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<scope>provided</scope>
</dependency>
Child:
Thanks,
Kishore
Views
Replies
Total Likes
The best way to proceed is to see if this package can be resolved using AEM Dependency Finder:
http://localhost:4502/system/console/depfinder
If it resolves and shows the package - then you can use the package in AEM. I installed
acs-aem-commons-content-2.3.0-min.zip
and then entered org.apache.commons.collections.ListUtils into DF:
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<scope>provided</scope>
</dependency>
Views
Replies
Total Likes
To add to Scott's reply. You have a provided dependency in your pom. This means that the runtime (JDK or a container) will provide the required dependency. AEM does not provide this OOTB, so you would have to embed it in your component, or deploy the acs-aem-commons-content package mentioned by Scott, since it provides the dependency.
Zyg
Views
Replies
Total Likes
Thanks Scott.
Just to know how this package will resolve this issue??
And also from where we can get this package?
Thanks,
Kishore
Views
Replies
Total Likes
Hi Kishore,
1. If the dependency in pom is failing to download to m2 repository, then try downloading from http://mvnrepository.com/artifact/commons-collections/commons-collections and paste it there
2. If the dependency in pom is able to download to m2 repository, then check with scott's method ie., goto - http://localhpost:4502/system/console/depfinder
and type "org.apache.commons.collections" and check. If it is not able to resolve and no output is there, then that means that particular bundle is not present in AEM for some reason.
In the second case, You need to debug why it is happening using error.log. But i can give a temporary solution.
Goto localhost:4502/system/console/bundles, Add the jar (bundle) you downloaded from http://mvnrepository.com/artifact/commons-collections/commons-collections and install it. This will solve your issue.
Few debugging steps I can suggest :
1. Try changing SCOPE
2. Try changing VERSION
3. Try pinging Adobe Nexus (If you are using Adobe repository for downloading)from browser
Please let me know if any of above inputs helped
Thanks,
Jaison
Views
Replies
Total Likes
i have downloaded jar
psjaison wrote...
Hi Kishore,
1. If the dependency in pom is failing to download to m2 repository, then try downloading from http://mvnrepository.com/artifact/commons-collections/commons-collections and paste it there
2. If the dependency in pom is able to download to m2 repository, then check with scott's method ie., goto - http://localhpost:4502/system/console/depfinder
and type "org.apache.commons.collections" and check. If it is not able to resolve and no output is there, then that means that particular bundle is not present in AEM for some reason.
In the second case, You need to debug why it is happening using error.log. But i can give a temporary solution.
Goto localhost:4502/system/console/bundles, Add the jar (bundle) you downloaded from http://mvnrepository.com/artifact/commons-collections/commons-collections and install it. This will solve your issue.
Few debugging steps I can suggest :
1. Try changing SCOPE
2. Try changing VERSION
3. Try pinging Adobe Nexus (If you are using Adobe repository for downloading)from browser
Please let me know if any of above inputs helped
Thanks,
Jaison
Dependecy is already presented able to see it from 'depfinder' but not required class is not getting reflected when that piece of code is execute.
Thanks,
Kishore
Views
Replies
Total Likes
For us to try and solve this - we need to reproduce your code. Can you paste part of it that uses this class in an AEM service.
Views
Replies
Total Likes
We are using sum() method of ListUtils class.Below line of code is responsible for this.
List<String> searchIndexMemberFirmList = ListUtils.sum(sitemapMemberFirmsList, snpMemberFirmsList);
FYI... Currently our application is running on AEM 6.0 instance
Thanks,
Kishore
Views
Replies
Total Likes
I am testing this to see if I get the same results if i use this API in an AEM service - will post back my results.
Views
Replies
Total Likes
We tested this API in an AEM Service and it worked perfectly. For tested purposes - I executed this Java code:
package foo.service.impl;
import foo.service.listService;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.ListUtils;
import java.util.Collections;
import java.util.List;
//This is a component so it can provide or consume services
@Component
@Service
public class listServiceImpl implements listService {
//Define a class member named key
private int key = 0 ;
@Override
//A basic setter method that sets key
public void setKey(int val)
{
//Set the key class member
this.key = val ;
}
@Override
//A basic getter that gets key
public String getKey()
{
//return the value of the key class member
//Convert the int to a String to display it within an AEM web page
String strI = Integer.toString(this.key);
List ii = return_empty_list_java ();
return "The size of the list is " + ii.size();
}
public List return_empty_list_java () {
List<String> emptyList = ListUtils.EMPTY_LIST;
return emptyList;
}
}
Views
Replies
Total Likes
As Smac rightly pointed you have issues with the provided written there. There are some ways to resolve . Like either you can deploy the bundle commons-collections by your own in felix console which I wouldn't prefer or what you can do is try to embed that jar inside your pom like
<Embed-Dependency>commons-collections;scope=compile;scope=compile</Embed-Dependency>
Also please change the scope from provided to compile.
Please try this out and let us know.
Regards,
Samir
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies