Question

i trying to build camel sql application, but i've stack.

I found informations about camel-sql in http://camel.apache.org/sql-component.html page.

I've created xml configurations, as shown in example, and in my FUSE ESB i found exception:

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name
     'camel-21': Invocation of init method failed; nested exception is 
    org.springframework.beans.factory.CannotLoadBeanClassException: 
Cannot find class [org.springframework.jdbc.datasource.DriverManagerDataSource] 
for bean with name 'esb' defined in URL [bundle://249.2:0/META-INF/spring/camel-context.xml]; nested exception is java.lang.ClassNotFoundException: 
org.springframework.jdbc.datasource.DriverManagerDataSource not found from bundle [camel]

but in my fuse console i have spring jdbc:

karaf@root> osgi:list | grep Spring

ID State Blueprint Spring Level Name [ 73] [Active ] [ ] [ ] [ 60] Spring Beans (3.0.5.RELEASE)

[ 74] [Active ] [ ] [ ] [ 60] Spring Context Support (3.0.5.RELEASE)

[ 75] [Active ] [ ] [ ] [ 60] Spring Context (3.0.5.RELEASE)

[ 76] [Active ] [ ] [ ] [ 60] Spring Expression Language (3.0.5.RELEASE)

[ 77] [Active ] [ ] [ ] [ 60] Spring ASM (3.0.5.RELEASE)

[ 78] [Active ] [ ] [ ] [ 60] Spring Core (3.0.5.RELEASE)

[ 79] [Active ] [ ] [ ] [ 60] Spring AOP (3.0.5.RELEASE)

[ 87] [Active ] [ ] [ ] [ 60] Apache XBean :: Spring (3.8)

[ 92] [Active ] [ ] [ ] [ 50] Spring Transaction (3.0.5.RELEASE)

[ 94] [Active ] [ ] [ ] [ 50] Spring JMS (3.0.5.RELEASE)

[ 169] [Active ] [ ] [ ] [ 50] Apache XBean :: Spring (3.7)

[ 223] [Active ] [ ] [ ] [ 60] Spring Web (3.0.5.RELEASE)

[ 224] [Active ] [ ] [ ] [ 60] Spring Web Servlet (3.0.5.RELEASE)

[ 252] [Active ] [ ] [ ] [ 50] Spring JDBC (3.0.5.RELEASE)

what do i have to do ?

UPDATE:

My POM is :

    <?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>camelWs</groupId>
  <artifactId>camel</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>

  <name>A Camel Route</name>
  <url>http://www.myorganization.org</url>

  <dependencies>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
      <version>2.9.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-spring</artifactId>
      <version>2.9.0</version>
    </dependency>

    <!-- logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.6.1</version>
    </dependency> 
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.6.1</version>
    </dependency>
    <dependency>
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.16</version> 
    </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-sql</artifactId>
            <version>2.8.0</version>
            <!-- use the same version as your Camel core version -->
        </dependency>
  </dependencies>

  <build>
    <defaultGoal>install</defaultGoal>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>


        </configuration>
      </plugin>
      <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.1.0</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Import-Package>
                            org.springframework.jdbc.datasource
                        </Import-Package>

                    </instructions>
                </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.9.0</version>
        <configuration>

          <instructions>

                        <Import-Package>
                            *,
                            org.springframework.jdbc,
                            org.springframework.jdbc.datasource

                        </Import-Package>

                           <DynamicImport-Package>camel.*</DynamicImport-Package>

                    </instructions>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

but when i'm using osgi:headers i don't see imported classes, what is wrong im my pom.xml ?

osgi:headers:

camel (271)
-----------
Manifest-Version = 1.0
Bnd-LastModified = 1332154265299
Archiver-Version = Plexus Archiver
Tool = Bnd-0.0.357
Originally-Created-By = Apache Maven
Generated-By-Ops4j-Pax-From = wrap:file:/.../$Bundle-SymbolicName=camel&Bundle-Version=1.0.0.SNAPSHOT
Build-Jdk = 1.6.0_29
Created-By = 1.6.0_29 (Apple Inc.)

Bundle-Name = camel
Bundle-SymbolicName = camel
Bundle-Version = 1.0.0.SNAPSHOT
Bundle-ManifestVersion = 2

Private-Package = 
    .
Import-Package = 
    camel;resolution:=optional,
    org.apache.camel.builder;resolution:=optional,
    org.apache.camel.model;resolution:=optional,
    org.apache.camel.spring;resolution:=optional
Export-Package = 
    camel;uses:="org.apache.camel.builder,org.apache.camel.model,org.apache.camel.spring"
Was it helpful?

Solution

OSGi can be a bit troublesome for installing and using JDBC drivers easily. A proven solution is to install the JDBC driver as a fragment bundle to your bundle.

Its been discussed at the FuseSource forums where there is instructions how to resolve this. A starting point is this link: http://fusesource.com/forums/thread.jspa?messageID=13043&#13043, and then follow the references for other discussions for more details and how to resolve it.

OTHER TIPS

You should make sure your route has an import-package on org.springframework.jdbc.datasource. You can verify it using the header command in karaf.

OK, i found solution.

It was quite easy - i just have to install mysql connector.

Thanks all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top