首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >org.osgi.framework.BundleException:无法解决:缺少需求: osgi.wiring.package;(osgi.wiring.package=org.json)

org.osgi.framework.BundleException:无法解决:缺少需求: osgi.wiring.package;(osgi.wiring.package=org.json)
EN

Stack Overflow用户
提问于 2019-04-26 07:37:50
回答 1查看 5.1K关注 0票数 3

我是Java/ Karaf 4.0.9/ Maven/ Pom/ Camel的新手,我无法解决这个问题

Json部分在pom.xml文件中,这里我修改了很多Json版本,但是没有用。

代码语言:javascript
复制
            <dependency>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
                <version>20151123</version>
            </dependency>

这里我附上了我的Pom.xml文件,我谷歌它。得到GSON中同样的问题,但我不知道如何在felix中解决这个问题。

代码语言:javascript
复制
        <?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/maven-v4_0_0.xsd">

            <modelVersion>4.0.0</modelVersion>

            <groupId>PaxelESBNotification</groupId>
            <artifactId>PaxelESBNotification</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <packaging>jar</packaging>

            <name>A Camel Blueprint Route</name>

            <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            </properties>

            <dependencyManagement>
                <dependencies>
                    <!-- Camel BOM -->
                    <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-parent</artifactId>
                        <version>2.16.5</version>
                        <scope>import</scope>
                        <type>pom</type>
                    </dependency>
                </dependencies>
            </dependencyManagement>

            <dependencies>
                <!-- Camel -->
                <dependency>
                    <groupId>org.apache.camel</groupId>
                    <artifactId>camel-core</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.apache.camel</groupId>
                    <artifactId>camel-rabbitmq</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.json</groupId>
                    <artifactId>json</artifactId>
                    <version>20151123</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.camel</groupId>
                    <artifactId>camel-mail</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.apache.camel</groupId>
                    <artifactId>camel-stream</artifactId>
                </dependency>

                <!-- Testing -->
                <dependency>
                    <groupId>org.apache.camel</groupId>
                    <artifactId>camel-test-blueprint</artifactId>
                    <scope>test</scope>
                </dependency>

                <!-- logging -->
                <dependency>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-api</artifactId>
                    <version>2.7</version>
                </dependency>
                <!-- <dependency>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-core</artifactId>
                    <version>2.7</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-slf4j-impl</artifactId>
                    <version>2.7</version>
                </dependency> -->
            </dependencies>

            <build>
                <plugins>
                <!-- compiler plugin -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.7.0</version>
                        <configuration>
                            <source>1.8</source>
                            <target>1.8</target>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.0.2</version>
                        <configuration>
                            <encoding>UTF-8</encoding>
                        </configuration>
                    </plugin>

                    <!-- to generate the MANIFEST.MF of the bundle -->
                    <plugin>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>maven-bundle-plugin</artifactId>
                        <version>3.5.0</version>
                        <extensions>false</extensions>
                        <executions>
                            <execution>
                                <id>bundle-manifest</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>manifest</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- to include MANIFEST.MF in the bundle -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.0.2</version>
                        <configuration>
                            <archive>
                                <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                            </archive>
                        </configuration>
                    </plugin>

                    <!-- to run the example using mvn camel:run -->
                    <plugin>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-maven-plugin</artifactId>
                        <version>2.16.5</version>
                        <!-- <version>3.3.3</version> -->
                    </plugin>
                </plugins>
            </build>

        </project>

java文件

代码语言:javascript
复制
    import org.apache.camel.Exchange;
    import org.apache.camel.Processor;
    import org.json.JSONObject;

    public class EmailProcessor implements Processor {
        public void process(Exchange exchange) throws Exception {
            String RequestPayload = exchange.getIn().getBody(String.class);
            JSONObject obj = new JSONObject(RequestPayload);
            String mail_id_to = obj.get("email").toString();
            String mail_subject = obj.get("subject").toString();
            String mail_content = obj.get("content").toString();

            System.out.print(mail_id_to);
            System.out.print(mail_subject);
            System.out.print(mail_content);
        }
    }

错误

代码语言:javascript
复制
    ERROR: Bundle PaxelESBNotification [226] Error starting file:/home/ubuntu/Software/service_mix/apache-servicemix-7.0.1/deploy/PaxelESBNotification-0.0.1-SNAPSHOT.jar (org.osgi.framework.BundleException: Unable to resolve PaxelESBNotification [226](R 226.0): missing requirement [PaxelESBNotification [226](R 226.0)] osgi.wiring.package; (osgi.wiring.package=org.json) Unresolved requirements: [[PaxelESBNotification [226](R 226.0)] osgi.wiring.package; (osgi.wiring.package=org.json)])
    org.osgi.framework.BundleException: Unable to resolve PaxelESBNotification [226](R 226.0): missing requirement [PaxelESBNotification [226](R 226.0)] osgi.wiring.package; (osgi.wiring.package=org.json) Unresolved requirements: [[PaxelESBNotification [226](R 226.0)] osgi.wiring.package; (osgi.wiring.package=org.json)]
        at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4132)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2117)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371)
        at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
        at java.lang.Thread.run(Thread.java:748)

,我怎样才能解决这个问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-26 09:49:59

你的身材看起来很棒。据我所知,你们生产了一个有效的包。

现在,在运行时,您必须提供项目所依赖的所有包。错误消息告诉您,您的包需要一个包org.json。所以你需要安装一个能输出这个软件包的bunde。

您可以尝试使用这个包:

代码语言:javascript
复制
 install -s mvn:org.json/json/20180813

您还应该考虑在构建过程中创建一个特性文件,允许一次性安装代码(包括依赖项)。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55862916

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档