Cannot deply gradle portlet with a external guava jar

Olaf Kock, modified 1 Year ago. New Member Posts: 7 Join Date: 7/3/13 Recent Posts

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?

 

thumbnail
Olaf Kock, modified 1 Year ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

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.