Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Cannot deply gradle portlet with a external guava jar
Hello,
I have a service with gradle and I would and I would like to add a guava cache functionallity into a Utility Class of the web:
private static LoadingCache<Long,List<JournalArticle>> listOrderedArticles =
CacheBuilder.newBuilder()
.expireAfterWrite(10,TimeUnit.MINUTES)
.build(
new CacheLoader<Long, List<JournalArticle>>() {
@Override
public List<JournalArticle> load(Long aLong) throws Exception {
return getListOfOrderedArticles(aLong.longValue());
}
}
);
build.gradle:
dependencies {
compileOnly group: "com.liferay.portal", name: "release.portal.api"
compileOnly project(":my-service-api")
compileOnly group: "com.google.guava", name:"guava"
}
and with bnd.bnd:
Bundle-Name: My-App Web
Bundle-SymbolicName: com.my.app.web
Bundle-Version: 1.0.0
Import-Package: com.google.common.cache
The problem is that when ever I deploy the jar
com.liferay.portal.kernel.log.LogSanitizerException: org.osgi.framework.BundleException: Could not resolve module: my.app.web [1662]_ Unresolved requirement: Import-Package: com.google.common.cache; version="30.1.0"_ [Sanitized]
at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428) ~[org.eclipse.osgi.jar:?]
at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundle(DirectoryWatcher.java:1156) [bundleFile:?]
at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundles(DirectoryWatcher.java:1189) [bundleFile:?]
at com.liferay.portal.file.install.internal.DirectoryWatcher._startAllBundles(DirectoryWatcher.java:1130) [bundleFile:?]
at com.liferay.portal.file.install.internal.DirectoryWatcher._process(DirectoryWatcher.java:1041) [bundleFile:?]
at com.liferay.portal.file.install.internal.DirectoryWatcher.run(DirectoryWatcher.java:221) [bundleFile:?]
Could you please help?
Gogo Shell can help you resolve this kind of problems. In this case, from the detail that you provide, it's probable that the dependency you've introduced at compile time (google guava) is not available at runtime. In case Guava is packaged as OSGi bundle, you'll need to drop the matching version into Liferay's deploy folder, to make it available to the runtime as well (you'll only need to do this once). I don't know if Guava has transitive runtime-dependencies: For them, the same would apply.
Powered by Liferay™