gpt4 book ai didi

java - org.osgi.framework.BundleException : Unable to resolve: missing requirement: osgi. wiring.package; (osgi.wiring.package=org.json)

转载 作者:行者123 更新时间:2023-11-30 07:41:38 28 4
gpt4 key购买 nike

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

pom.xml文件中的Json部分,这里我改了很多Json version , 但没有用。

            <dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20151123</version>
</dependency>

我在这里附上了我的 Pom.xml 文件,我用谷歌搜索了它。并得到 same issue in GSON但我不知道如何解决 felix 中的问题。

        <?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文件

    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);
}
}

错误

    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)

我该如何解决这个问题?

最佳答案

您的构建看起来很棒。据我所知,您生成了一个有效的 bundle 。

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

你可以试试这个包:

 install -s mvn:org.json/json/20180813

您还应该考虑在构建期间创建一个功能文件,允许一次性安装您的代码,包括依赖项。

关于java - org.osgi.framework.BundleException : Unable to resolve: missing requirement: osgi. wiring.package; (osgi.wiring.package=org.json),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55862916/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com