Reputation: 665
I'm a newbie of Java/ Karaf 4.0.9/ Maven/ Pom/ Camel, I'm unable to solve the issue
Json part in pom.xml
file, Here I changed the many Json version, but no use.
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20151123</version>
</dependency>
Here I attached my Pom.xml
file, I google it. And get the same issue in GSON but I don't know How can i fix the issue in 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 file
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
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)
How can I fix this?
Upvotes: 4
Views: 8408
Reputation: 19606
Your build looks great. So as far as I can see you produce a valid bundle.
Now at runtime you have to provide all bundles your project depends on. The error message tells you that your bundle needs a package org.json
. So you need to install a bunde that exports this package.
You can try with this package:
install -s mvn:org.json/json/20180813
You should also consider to create a feature file during the build that allows to install your code including dependencies in one go.
Upvotes: 5