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

时间:2015-04-23 09:32:04

标签: apache-camel jbossfuse

我使用 JBoss Fuse(jboss-fuse-6.1.0.redhat-379),它预装了与Redhat的Camel功能一起安装的软件包。

根据建议,我们选择使用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>

我该如何解决这个问题?具有讽刺意味的是,这种情况已经存在了一段时间,并开始突然抱怨......

1 个答案:

答案 0 :(得分:0)

我必须同意 @Claus Ibsen 驼峰杰克逊功能安装的评论。虽然我已经安装了,但jBoss Fuse有些不对劲。我不得不删除'data'文件夹,不得不进行安装。到目前为止我还没有遇到任何问题。所以,我想这应该是它。

谢谢@Claus Ibsen。