मैं करफ (संस्करण 3.0.1) में एक बंडल शुरू करने में असमर्थ हूं।करफ/मेवेन - हल करने में असमर्थ: अनुपलब्ध आवश्यकता osgi.wiring.package
बंडल मैवेन का उपयोग करके बनाया गया है और यह gson आयात करता है।
मैं Maven में gson शामिल के रूप में आवश्यक:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
निर्माण ठीक हो जाता है। हालांकि, जब बंडल की तैनाती मैं Karaf से इस चेतावनी प्राप्त करते हैं:
2015-05-27 12:45:07,371 | WARN | 49-19-bin/deploy | fileinstall | 11 - org.apache.felix.fileinstall - 3.2.8 | Error while starting bundle: file:/Users/user/Documents/tools/MyBundle-1.0.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Unresolved constraint in bundle MyBundle [121]: Unable to resolve 121.13: missing requirement [121.13] osgi.wiring.package; (&(osgi.wiring.package=com.google.gson)(version>=2.3.0)(!(version>=3.0.0)))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2037)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1263)[11:org.apache.felix.fileinstall:3.2.8]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1235)[11:org.apache.felix.fileinstall:3.2.8]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1224)[11:org.apache.felix.fileinstall:3.2.8]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:519)[11:org.apache.felix.fileinstall:3.2.8]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:308)[11:org.apache.felix.fileinstall:3.2.8]
बंडल स्थापित नहीं है।
Import-Package
MANIFEST.MF
में शुरू होता है के साथ:
Import-Package: com.google.gson;version="[2.3,3)"
मैं के साथ बदलने की कोशिश की:
Import-Package: com.google.code.gson;version="[2.3,3)"
लेकिन यह मेरे लिए एक समान त्रुटि देता है:
missing requirement [121.13] osgi.wiring.package; (&(osgi.wiring.package=com.google.code.gson)
pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>groupid</groupId>
<artifactId>artifactid</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>groupid</groupId>
<artifactId>MyBundle</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>MyBundle</name>
<description>MyBundle</description>
<properties>
<skipTests>true</skipTests>
</properties>
<dependencies>
...
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.jetty</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>com.springsource.org.json</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.commons-httpclient</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1201-jdbc41</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
गूगल GSON (संस्करण Maven डाउनलोड जब मैं बंडल निर्माण) है की MANIFEST.MF
:
Manifest-Version: 1.0
Export-Package: com.google.gson;version=2.3.1, com.google.gson.annotat
ions;version=2.3.1, com.google.gson.reflect;version=2.3.1, com.google
.gson.stream;version=2.3.1, com.google.gson.internal;version=2.3.1, c
om.google.gson.internal.bind;version=2.3.1
Bundle-ClassPath: .
Built-By: inder
Bundle-Name: Gson
Created-By: Apache Maven 3.2.1
Bundle-RequiredExecutionEnvironment: J2SE-1.5, JavaSE-1.6, JavaSE-1.7,
JavaSE-1.8
Bundle-Vendor: Google Gson Project
Bundle-ContactAddress: http://code.google.com/p/google-gson/
Build-Jdk: 1.6.0_65
Bundle-Version: 2.3.1
Bundle-ManifestVersion: 2
Bundle-Description: Google Gson library
Bundle-SymbolicName: com.google.gson
Archiver-Version: Plexus Archiver
मैं भी
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>*;resolution:=optional</Import-Package>
<Embed-Dependency>*</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
</plugins>
</build>
अब निर्भरता एम्बेडेड रहे हैं के साथ की कोशिश की लेकिन Karaf नहीं कर सकते बंडल शुरू करें।
आप बेमेल के बारे में पता कर रहे हैं ' com.google.code.gson ' और 'osgi.wiring.package = com.google.gson' के बीच पैकेज में? –
javabrett
हाँ, धन्यवाद। मैंने पैकेज 'com.google.gson' की खोज की लेकिन afaik केवल' com.google.code.gson' है। हालांकि, मुझे नहीं पता कि आवश्यक पैकेज क्यों है 'com.google.gson' .. कोई सुराग? – gc5
ऐसा लगता है कि यह ठीक होना चाहिए। क्या आप अपने बंडल कॉन्फ़िगरेशन को पीओएम, 'आयात-पैकेज' आदि से पोस्ट कर सकते हैं? – javabrett