【问题标题】:Camel with Blueprint - Marshalling exception - Jackson Library (Data format 'json-jackson' could not be created))带蓝图的骆驼 - 编组异常 - 杰克逊图书馆(无法创建数据格式“json-jackson”))
【发布时间】:2015-04-23 09:32:04
【问题描述】:

我使用 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>

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

【问题讨论】:

  • 只是为了确保你已经完成了一个功能:安装camel-jackson,如果你在shell中运行list命令,它就会安装并启动?
  • 感谢您的回复@Claus lbsen 是的。我安装了功能 camel-jackson,并且还将该功能与其他捆绑包一起包含在 features.xml 中。我有一个问题 - 我有 jackson-core-asl、jackson-mapper-asl 等这些数据格式参考 link。还是功能本身就足以达到目的?
  • @ClausIbsen - 我相信它与骆驼杰克逊功能有关。目前它有效,我不确定为什么这会突然停止。我不得不删除数据文件夹并且必须重新安装所有现在工作。请让我知道上面关于数据格式依赖项的评论中发布的查询

标签: apache-camel jbossfuse


【解决方案1】:

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

谢谢@克劳斯易卜生。

【讨论】:

    猜你喜欢
    • 2016-12-21
    • 2019-07-20
    • 1970-01-01
    • 2016-09-10
    • 2012-05-18
    • 2023-04-02
    • 2015-05-31
    • 2021-09-10
    • 1970-01-01
    相关资源
    最近更新 更多