带蓝图的骆驼 - 编组异常 - 杰克逊图书馆(无法创建数据格式 'json-jackson'))

Camel with Blueprint - Marshalling exception - Jackson Library (Data format 'json-jackson' could not be created))

我使用 JBoss Fuse (jboss-fuse-6.1.0.redhat-379),它预定义了安装有 Camel 功能的包Redhat 的。

根据建议,我们选择了 Blueprint DSL 进行配置。我的配置如下:

<?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:camel="http://camel.apache.org/schema/blueprint"
    xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
    xsi:schemaLocation="
        http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
        http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

    <cm:property-placeholder persistent-id="serviceUrlPlaceHolder"
        update-strategy="reload">
        <cm:default-properties>
            <cm:property name="CXFserver" value="http://localhost:8183/" />
            <cm:property name="service" value="copi" />
        </cm:default-properties>
    </cm:property-placeholder>


    <cxf:rsServer id="rsServer" address="http://localhost:8183/copi"
        serviceClass="com.karthik.services.InboxRestService"
        loggingFeatureEnabled="true" />

    <cxf:rsServer id="rsServerDup" address="http://localhost:8183/copi2"
        serviceClass="com.karthik.services.InboxRestService"
        loggingFeatureEnabled="true" />

    <camelContext id="inboxServiceRouterContext"
        xmlns="http://camel.apache.org/schema/blueprint">
        <route id="inboxRoute">
            <from uri="cxfrs:bean:rsServer?bindingStyle=SimpleConsumer" />
            <to uri="direct:inboxService" />
        </route>
        <route id="inboxRouteDup">
            <from uri="cxfrs:bean:rsServerDup" />
            <to uri="direct:inboxService" />
        </route>
        <route id="inboxServiceRoute">
            <from uri="direct:inboxService" />
            <to uri="bean:inboxService?method=updateCompletedTask" />
            <marshal ref="jsonDataformat" />
        </route>
    </camelContext>


    <bean id="inboxService" class="com.karthik.services.InboxService" />
    <bean id="jsonDataformat" class="org.apache.camel.model.dataformat.JsonDataFormat">
        <property name="unmarshalType" value="com.karthik.bo.Task" />
        <property name="library" value="Jackson"></property>
    </bean>

</blueprint>

请注意,我添加了 Jackson 库。 在安装我的功能时,出现以下异常。

Failed to create route inboxServiceRoute at: >>> Marshal[ref:jsonDataformat] <<< in route: Route(inboxServiceRoute)[[From[direct:inboxService]] -> [To[... because of Data format 'json-jackson' could not be created. Ensure that the data format is valid and the associated Camel component is present on the classpath

我在 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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.karthik</groupId>
    <artifactId>inboxServiceRouter</artifactId>
    <packaging>bundle</packaging>
    <version>1.0.0-SNAPSHOT</version>

    <name>Inbox ServiceRouter Camel Spring-CXF Route</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <camel.cxf.redhat.v>2.12.0.redhat-610379</camel.cxf.redhat.v>
        <jackson.version>1.8.6</jackson.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.fasterxml.jackson.jaxrs</groupId>
            <artifactId>jackson-jaxrs-json-provider</artifactId>
            <version>2.2.2</version>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
            <version>2.7.0.redhat-610379</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.1.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>${camel.cxf.redhat.v}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring</artifactId>
            <version>${camel.cxf.redhat.v}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-cxf-transport</artifactId>
            <version>${camel.cxf.redhat.v}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-cxf</artifactId>
            <version>${camel.cxf.redhat.v}</version>
            <scope>provided</scope>
            <!-- use the same version as your Camel core version -->
        </dependency>


        <!-- logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jackson</artifactId>
            <version>${camel.cxf.redhat.v}</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-jaxrs</artifactId>
            <version>${jackson.version}</version>
        </dependency>


    </dependencies>

    <build>
        <defaultGoal>install</defaultGoal>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.9.1</version>
                <configuration>
                    <mainClass>org.apache.camel.example.cxf.CamelRouteClient</mainClass>
                    <includePluginDependencies>false</includePluginDependencies>
                    <systemProperties>
                        <property>
                            <key>java.util.logging.config.file</key>
                            <value>logging.properties</value>
                        </property>
                    </systemProperties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <!-- allows the route to be ran via 'mvn camel:run' -->
            <plugin>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-maven-plugin</artifactId>
                <version>2.14.0</version>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.3.4</version>
                <configuration>
                    <instructions>
                        <!-- <Require-Bundle>org.apache.cxf.bundle</Require-Bundle> -->
                        <Import-Package>
                            org.apache.camel.spring,org.apache.cxf.jaxrs.impl,*
                        </Import-Package>
                    </instructions>

                </configuration>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.9.1</version>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>target/classes/features.xml</file>
                                    <type>xml</type>
                                    <classifier>features</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

我该如何解决这个问题?具有讽刺意味的是,这工作了一段时间并突然开始抱怨..

我必须同意 @Claus Ibsencamel-jackson[=17 的 功能安装的评论=].虽然我已经安装了,但 jBoss Fuse 还是有些不对劲。我必须删除 'data' 文件夹并进行安装。到目前为止,我还没有遇到任何问题。所以,我想应该是这样。

谢谢@Claus Ibsen。