osgi.wiring.package; (&(osgi.wiring.package = org.json)(版本> = 0.0.0))未解决的要求:

时间:2017-12-05 18:27:16

标签: java json gradle osgi dotcms

我正在编译一个使用org.json的java插件。在我加入之前,该插件能够正确编译和运行。我在stackoverflow上看到过类似的问题,但是没有一个使用gradle来解决这个问题。

在我的课程顶部,我有以下

import org.json.JSONArray;
import org.json.JSONObject;

我的gradle构建脚本包含以下内容:

repositories {
    maven {
        url "http://repo.dotcms.com/artifactory/libs-release"
    }
    mavenCentral()
    flatDir {
        dirs 'src/main/resources/localLibs'
    }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile fileTree(dir: 'src/main/resources/libs', include: '*.jar')
    compile (group: 'com.dotcms', name: 'dotcms', version: '4.2.2'){
        transitive = true
    }
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.8'
    compile group: 'org.json', name: 'json', version: '20170516'
    compile group: 'org.simpleflatmapper', name: 'sfm-csv', version: '3.14.1'
    /* Specifying an alternate configuration (see above 'configurations') keeps servlet-api.jar from being added to our own output Jar. */
    providedCompile "javax.servlet:javax.servlet-api:3.1.0"
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

jar {
    manifest {
        name = 'Symplicity SOAP API Web Service'
        symbolicName = 'Symplicity SOAP API Web Service'
        instruction 'Bundle-Vendor', 'JustinKubicek'
        instruction 'Bundle-Name', 'Symplicity SOAP API Web Service'
        instruction 'Bundle-Description', 'This is a plugin to access the Symplicity SOAP API Web Service'
        instruction 'Bundle-DocURL', 'https://bitbucket.org/justinkubicek/symplicity-soap-api-plugin'
        instruction 'Bundle-Activator', 'com.symplicitysoapapi.soapapitool.osgi.Activator'
        instruction 'DynamicImport-Package', '*'
        instruction 'Import-Package', '*;version=0;'
    }
}    

我得到的错误就在这里。

javax.servlet.ServletException: Unable to resolve Symplicity SOAP API Web Service
[197](R 197.0): missing requirement [Symplicity SOAP API Web Service [197](R 197.0)]
osgi.wiring.package; (&(osgi.wiring.package=org.json)(version>=0.0.0))
Unresolved requirements: [[Symplicity SOAP API Web Service [197](R 197.0)]
osgi.wiring.package; (&(osgi.wiring.package=org.json)(version>=0.0.0))]
Unable to start bundle
at com.dotmarketing.portlets.osgi.AJAX.OSGIAJAX.start(OSGIAJAX.java:122)
~[dotcms_4.2.2_999999.jar:?]

1 个答案:

答案 0 :(得分:0)

除非您需要自定义版本的JSON库,否则我建议您更改导入以使用dotCMS库中包含的重新打包的类。这些类被重新打包,以允许开发人员在需要时包含此库的自定义版本。以下是4.2.2版本中可用的json类的列表:

./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/XMLTokener.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/XML.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/Test.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/JSONWriter.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/JSONTokener.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/JSONStringer.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/JSONString.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/JSONObject.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/JSONML.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/JSONException.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/JSONArray.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/HTTPTokener.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/HTTP.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/CookieList.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/Cookie.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/CDL.java
./dotserver/tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/dot.json-ukv_2.jar:com/dotcms/repackage/org/json/

当然要在运行时使用这些类,您需要确保它们列在“导出的包”列表中:https://dotcms.com/docs/latest/osgi-plugins#ExportedPackages