Apache Camel错误启动包

时间:2015-11-12 19:43:06

标签: apache-camel fuseesb jbossfuse

学习Apache Camel- 尝试在jboss-fuse-6.1.0.redhat-379上部署应用程序。

POM如下

    <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>com.dao</groupId>
        <artifactId>camelDAO</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>bundle</packaging>
        <properties>
        <camel-version>2.13.0</camel-version>
        </properties>
        <dependencies>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.17</version>
            </dependency>
            <dependency>
                <groupId>commons-dbcp</groupId>
                <artifactId>commons-dbcp</artifactId>
                <version>1.4</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-jdbc</artifactId>
                <version>2.13.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-sql</artifactId>
                <version>2.13.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-core</artifactId>
                <version>${camel-version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-spring</artifactId>
                <version>${camel-version}</version>
            </dependency>
            <dependency>
                <groupId>commons-pool</groupId>
                <artifactId>commons-pool</artifactId>
                <version>1.4</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <extensions>true</extensions>
                </plugin>

                <plugin>
                    <groupId>org.apache.camel</groupId>
                    <artifactId>camel-maven-plugin</artifactId>
                    <version>${camel-version}</version>
                </plugin>
            </plugins>
        </build>
    </project>

在数据库配置文件中配置了以下

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost/univ" />
        <property name="username" value="root" />
        <property name="password" value="pass" />
</bean>


<bean id="sqlComponent"                                       
      class="org.apache.camel.component.sql.SqlComponent">
      <property name="dataSource" ref="dataSource" />
</bean>

并且在路由中调用了sql组件

<to uri="sqlComponent:{{sql.insertData}}" />

在部署保险丝时 -

Error executing command: Error starting bundles:
    Unable to start bundle 255: Unresolved constraint in bundle  
com.dao.came
lDAO [255]: Unable to resolve 255.0: missing requirement [255.0]   
osgi.wiring.pac
kage; (&(osgi.wiring.package=org.apache.camel.component.sql)  
(version>=2.13.0)(!(
version>=3.0.0))) [caused by: Unable to resolve 253.0: missing   
requirement [253.
0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.camel) 
(version>=2.13.0
)(!(version>=3.0.0)))]

使用wrap:install安装了jar,仍然出现上述错误

请帮我搞清楚。感谢

2 个答案:

答案 0 :(得分:1)

尝试导入丢失的包:

    <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.3.7</version>
        <extensions>true</extensions>
        <configuration>
            <instructions>
                <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                <Bundle-Description>${project.description}</Bundle-Description>
                <Import-Package>
                    *,
                    org.apache.camel.osgi,
                    org.apache.camel.component.sql,
                    org.apache.camel
                </Import-Package>
            </instructions>
        </configuration>
    </plugin>

必须安装camel-sql功能。

更新:

  

使用wrap:install

安装了jar

您只需要为数据库驱动程序执行此操作,所有其他必须按功能安装。

>    <bean id="sqlComponent"                                       
>          class="org.apache.camel.component.sql.SqlComponent">
>          <property name="dataSource" ref="dataSource" />    
>    </bean>

可以更简单地实施:

<to uri="sql:{{sql.insertData}}?dataSource=dataSource" />

请检查您安装在jboss保险丝服务器上的Camel版本,它必须与您项目中指定的版本匹配。

答案 1 :(得分:1)

您需要在Jboss Fuse中安装Mysql Connector。 对于安装,我们需要在Fuse终端中运行以下语句。

osgi:install -s wrap:mvn:mysql / mysql-connector-java / 5.1.39

可以根据您使用的mysql连接器更改版本。

安装完成后。尝试运行你的项目。