JbossFuse - 找不到一种简单的rest-dsl示例工作的方法......奇怪的,有些难以理解的异常

时间:2017-07-27 21:14:04

标签: java-8 apache-camel jbossfuse

不知道该例外的原因,每次部署尝试都会继续显示...

2017-07-27 16:54:15,583 | WARN  | edhat-187/deploy | fileinstall                      | 9 - org.apache.felix.fileinstall - 3.5.0 | Error while starting bundle: file:/C:/tools/jboss-fuse-6.3.0.redhat-187/deploy/cxf-rest4-1.jar
org.osgi.framework.BundleException: Unresolved constraint in bundle aaa.bbb.ccc.cxf-rest4 [307]: Unable to resolve 307.0: missing requirement [307.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.camel)(version>=2.19.0)(!(version>=3.0.0)))
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4002)[org.apache.felix.framework-4.4.1.jar:]
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2045)[org.apache.felix.framework-4.4.1.jar:]
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976)[org.apache.felix.framework-4.4.1.jar:]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245)[9:org.apache.felix.fileinstall:3.5.0]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217)[9:org.apache.felix.fileinstall:3.5.0]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:509)[9:org.apache.felix.fileinstall:3.5.0]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[9:org.apache.felix.fileinstall:3.5.0]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[9:org.apache.felix.fileinstall:3.5.0]

JBossFuse:karaf@root>

这个例外令人困惑(见下文)。作为一个JBoss-Fuse newby,我无法超越它,但是,领主知道,我已经尝试过: - )

下面是一个简单应用程序的代码,几乎逐字逐句地得出: https://github.com/rhtconsulting/fuse-quickstarts/tree/jboss-fuse-6.3/karaf/rest_dsl_simple

这是项目结构......

Here is the project structure:

SampleRoute.java

package aaa.bbb.ccc;

import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;

public class SampleRoute extends RouteBuilder {

    @Override
    public void configure() throws Exception {

    restConfiguration().component("restlet").host("localhost").port(8182).bindingMode(RestBindingMode.off);

    rest("/simplerest")
        .consumes("application/json") // Consume JSON Only
        .produces("application/json") // Return JSON Only
        .get("/get").to("direct:get") //GET request
        .post("/post").to("direct:post"); //POST request

    from("direct:get")
        .transform().constant("Successful GET Request"); //returns a plain string payload

    from("direct:post")//returns no response data and logs the success of the request
        .log(LoggingLevel.INFO, "com.redhat.consulting.fusequickstarts.karaf.rest.dsl.route", "Successful POST Request")
        .setHeader(Exchange.HTTP_RESPONSE_CODE,simple("200")); 
    }
}

驼route.xml

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
       xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws"
       xmlns:camel="http://camel.apache.org/schema/blueprint"
       xsi:schemaLocation="
         http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
         http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd
         http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
         ">
    <!-- The camel context which registers the route -->
    <camel:camelContext id="fusequickstart-restdsl-simple-camel"
            xmlns="http://camel.apache.org/schema/blueprint">

    <!-- Package Scanning finds the Routes -->
    <packageScan>
        <package>aaa.bbb.ccc</package>
    </packageScan>
    </camel:camelContext>

</blueprint>

的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>

    <groupId>aaa.bbb.ccc</groupId>
    <artifactId>cxf-rest4</artifactId>
    <version>1</version>
    <packaging>bundle</packaging>
    <name>cxf-rest4</name>
    <description>cxf-rest4</description>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <skipTests>true</skipTests>
    </properties>

    <dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.25</version>
        <scope>provided</scope>               
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.25</version>
        <scope>provided</scope>               
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>2.19.1</version>
        <scope>provided</scope>            
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-restlet</artifactId>
        <version>2.19.1</version>
        <scope>provided</scope>
    </dependency>        
    </dependencies>

    <build>
    <finalName>${project.artifactId}-${project.version}</finalName>

    <resources>
        <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        </resource>
    </resources>

    <plugins>

        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <showDeprecation>true</showDeprecation>
        </configuration>
        </plugin>   

        <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>3.3.0</version>                
        <extensions>true</extensions>
        <configuration>
            <manifestLocation>target/META-INF</manifestLocation>
            <instructions>
            <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
            <Export-Package />
            <Import-Package>
                org.apache.camel.*
            </Import-Package>
            </instructions>
        </configuration>
        </plugin>              

    </plugins>
    </build>
</project>

default.properties

AppName=system

环境:

java 8

的JBoss熔丝-6.3.0.redhat-187

行家

1 个答案:

答案 0 :(得分:1)

Fuse 6.3使用Camel 2.17。 enter image description here

您需要导入Fuse jboss-fuse-parent,如(编辑 - 如Claus所说 - 添加存储库:

<properties>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <version.maven-bundle-plugin>2.3.7</version.maven-bundle-plugin>
    <jboss.fuse.bom.version>6.2.1.redhat-084</jboss.fuse.bom.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.fuse.bom</groupId>
            <artifactId>jboss-fuse-parent</artifactId>
            <version>${jboss.fuse.bom.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

...

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-core</artifactId>
</dependency>

...
<repositories>
    <repository>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>fuse-public-repository</id>
        <name>FuseSource Community Release Repository</name>
        <url>https://repo.fusesource.com/nexus/content/groups/public</url>
    </repository>
    <repository>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>red-hat-ga-repository</id>
        <name>Red Hat GA Repository</name>
        <url>https://maven.repository.redhat.com/ga</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>fuse-public-repository</id>
        <name>FuseSource Community Release Repository</name>
        <url>https://repo.fusesource.com/nexus/content/groups/public</url>
    </pluginRepository>
    <pluginRepository>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>red-hat-ga-repository</id>
        <name>Red Hat GA Repository</name>
        <url>https://maven.repository.redhat.com/ga</url>
    </pluginRepository>
</pluginRepositories>
...