I'm trying to use a JSON class in my web service, however when I deploy my service there's an issue with it and my JSON dependency, specifically this line in my build.gradle file:
compile group: "javax.json", name: "javax.json-api", version: "1.1.2"
When I look in a Gogo shell at my services it'll show Installed
, instead of Active
and when I start the service manually it says:
g! start 809
org.osgi.framework.BundleException: Could not resolve module:
visualization.fileentries.service.service [809]
Unresolved requirement: Import-Package: javax.json; version="[1.1.0,2.0.0)"
Is this dependency declared incorrect correctly, or is this dependency (or version of it) not support in Service Builder?
Here is the build.gradle:
dependencies {
compileOnly group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.1.0"
compileOnly group: "com.liferay", name: "com.liferay.osgi.util", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.portal.spring.extender", version: "2.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.6.0"
compileOnly group: "javax.json", name: "javax.json-api", version: "1.1.2"
compile project(":modules:visualization-fileentries-service:visualization-
fileentries-service-api")
}
buildService {
apiDir = "../visualization-fileentries-service-api/src/main/java"
}
group = "visualization.fileentries.service"
And the bnd.bnd file:
Bundle-Name: visualization-fileentries-service-service
Bundle-SymbolicName: visualization.fileentries.service.service
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true
I needed to use the JSON parser and related classes for my Liferay modicule as well. I ran into similar issues as yours along with other errors. The following worked for me (compile and deploys fine).
In the build.gradle file.
compile group: 'org.json', name: 'json', version: '20131018'
My imports for the java module class were:
import org.json.JSONArray;
import org.json.JSONObject;
Hope this helps.