JDBC Connection object in Camel Processor

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

JDBC Connection object in Camel Processor

contactreji
This post was updated on .
Hi

I am trying to do a database operation inside a Processor class.

I have a code

private static Connection createConnection() {
                Connection conn=null;
               
                try {
                        Class.forName("com.mysql.jdbc.Driver");

                        // Get a connection
                       
                } catch (Exception except) {
                        LOGGER.info("Error Loading Driver Class");
                        except.printStackTrace();
                }
                try {
                        conn = DriverManager.getConnection(dbURL,"root","");
                } catch (SQLException e) {
                        LOGGER.info("Error initializing the connection object from Driver Manager");
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                return conn;
        }



I get following log

12:12:23,609 | INFO  | sumer[EAMBuffer] | DBActions                        | 271 - com.outotec.asset-down-time - 1.0.0 | Error Loading Driver Class
12:12:23,675 | INFO  | sumer[EAMBuffer] | DBActions                        | 271 - com.outotec.asset-down-time - 1.0.0 | Error initializing the connection object from Driver Manager


This happens only when the project is deployed to Jboss Fuse. The same works fine when I run the program in Maven standalone using camel:run maven goal.


Is there any specific way in camel projects to obtain a connection object using spring configuration/java dsl to use the object in my java processor.
According to my requirement, I don't want to do it via camel SQL component.


My POM file already contains dependency
<dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
</dependency>

Please suggest

Regards
Reji Mathews


Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
Reply | Threaded
Open this post in threaded view
|

Re: JDBC Connection object in Camel Processor

Claus Ibsen-2
Hi

You can lookup a bean in the registry from exchange

Object myBean = exchange.getContext().getRegistry().lookup("someName");



When you use  Class.forName("com.mysql.jdbc.Driver"); in OSGi then you
need to have com.mysql.jdbc in your import package in the MANIFEST.MF
file, for it to work in OSGi. Or use dynamic import in the MANIFEST.MF
to allow loading classes dynamic.






On Tue, Feb 25, 2014 at 7:47 AM, contactreji <[hidden email]> wrote:

> Hi
>
> I am trying to do a database operation inside a Processor class.
>
> I have a code
>
> *private static Connection createConnection() {
>                 Connection conn=null;
>
>                 try {
>                         Class.forName("com.mysql.jdbc.Driver");
>
>                         // Get a connection
>
>                 } catch (Exception except) {
>                         LOGGER.info("Error Loading Driver Class");
>                         except.printStackTrace();
>                 }
>                 try {
>                         conn = DriverManager.getConnection(dbURL,"root","");
>                 } catch (SQLException e) {
>                         LOGGER.info("Error initializing the connection object from Driver
> Manager");
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 }
>                 return conn;
>         }*
>
>
> I get following log
>
> *12:12:23,609 | INFO  | sumer[EAMBuffer] | DBActions
> | 271 - com.outotec.asset-down-time - 1.0.0 | Error Loading Driver Class
> 12:12:23,675 | INFO  | sumer[EAMBuffer] | DBActions                        |
> 271 - com.outotec.asset-down-time - 1.0.0 | Error initializing the
> connection object from Driver Manager*
>
> This happens only when the project is deployed to Jboss Fuse. The same works
> fine when I run the program in Maven standalone using camel:run maven goal.
>
>
> *Is there any specific way in camel projects to obtain a connection object
> using spring configuration/java dsl to use the object in my java processor.*
> According to my requirement, I don't want to do it via camel SQL component.
>
> Please suggest
>
> Regards
> Reji Mathews
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/JDBC-Connection-object-in-Camel-Processor-tp5747896.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io
Reply | Threaded
Open this post in threaded view
|

Re: JDBC Connection object in Camel Processor

Christian Mueller
Administrator
In reply to this post by contactreji
Create/Configure a connection pool in Spring and inject this into your
Processor, which you should also create/configure in Spring.

Best,
Christian
Am 25.02.2014 07:48 schrieb "contactreji" <[hidden email]>:

> Hi
>
> I am trying to do a database operation inside a Processor class.
>
> I have a code
>
> *private static Connection createConnection() {
>                 Connection conn=null;
>
>                 try {
>                         Class.forName("com.mysql.jdbc.Driver");
>
>                         // Get a connection
>
>                 } catch (Exception except) {
>                         LOGGER.info("Error Loading Driver Class");
>                         except.printStackTrace();
>                 }
>                 try {
>                         conn =
> DriverManager.getConnection(dbURL,"root","");
>                 } catch (SQLException e) {
>                         LOGGER.info("Error initializing the connection
> object from Driver
> Manager");
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 }
>                 return conn;
>         }*
>
>
> I get following log
>
> *12:12:23,609 | INFO  | sumer[EAMBuffer] | DBActions
> | 271 - com.outotec.asset-down-time - 1.0.0 | Error Loading Driver Class
> 12:12:23,675 | INFO  | sumer[EAMBuffer] | DBActions
>  |
> 271 - com.outotec.asset-down-time - 1.0.0 | Error initializing the
> connection object from Driver Manager*
>
> This happens only when the project is deployed to Jboss Fuse. The same
> works
> fine when I run the program in Maven standalone using camel:run maven goal.
>
>
> *Is there any specific way in camel projects to obtain a connection object
> using spring configuration/java dsl to use the object in my java
> processor.*
> According to my requirement, I don't want to do it via camel SQL component.
>
> Please suggest
>
> Regards
> Reji Mathews
>
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/JDBC-Connection-object-in-Camel-Processor-tp5747896.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: JDBC Connection object in Camel Processor

contactreji
In reply to this post by Claus Ibsen-2
Hi Clause

Thanks for your prompt help! :-)

I followed your advice and did following changes in the POM file.

<plugin>
                                <groupId>org.apache.felix</groupId>
                                <artifactId>maven-bundle-plugin</artifactId>
                                <version>2.3.4</version>
                                <extensions>true</extensions>
                                <configuration>

                                        <instructions>
                                                <Import-Package>org.apache.activemq.xbean,
                                                        javax.activation;version=1.1,
                                                        org.apache.activemq.spring,
                                                        org.apache.activemq.broker,
                                                        org.apache.activemq.security,
                                                        org.apache.activemq.jaas,
                                                        org.apache.activemq.pool,
                                                        org.apache.activemq.camel.component,
                                                        org.apache.camel.component.jms,
                                                        *</Import-Package>
                                                <DynamicImport-Package>com.mysql.jdbc</DynamicImport-Package>
                                </instructions>
                </configuration>
</plugin>


How ever, I couldnt get a difference. On building project in maven, I got a deployable jar file. Following is the content of the MANIFEST file inside the jar file.
It shows the Dynamic Import of the package DynamicImport-Package: com.mysql.jdbc

Manifest-Version: 1.0
Export-Package: com.ibm.maximo;uses:="javax.xml.bind.annotation,javax.
 xml.bind,javax.xml.datatype,com.ibm.maximo.runtime,javax.xml.bind.ann
 otation.adapters,javax.xml.namespace",com.ibm.maximo.runtime;uses:="j
 avax.xml.bind.annotation.adapters,javax.xml.bind",com.ibm.maximo.wsdl
 .otecwebservices_otecdowntime;uses:="javax.xml.ws,javax.xml.namespace
 ,javax.jws.soap,com.ibm.maximo,javax.jws,javax.xml.bind.annotation",c
 om.outotec.asset.downtime;uses:="javax.activation,org.apache.camel,or
 g.apache.log4j,org.springframework.beans.factory.annotation,org.apach
 e.cxf.ws.addressing,org.apache.cxf.binding,org.apache.cxf.message,org
 .apache.cxf.configuration.security,org.apache.cxf.transport,org.apach
 e.cxf.binding.soap.interceptor,org.apache.cxf.endpoint,org.apache.cxf
 .interceptor,javax.xml.parsers,javax.xml.transform.dom,org.w3c.dom,co
 m.ibm.maximo.wsdl.otecwebservices_otecdowntime,com.ibm.maximo,javax.s
 ql,javax.xml.transform,javax.xml.transform.stream,javax.xml.bind,outo
 tec.pi.mes.id51.plantstanstillhours",com.outotec.serializationclasses
 ;uses:="com.ibm.maximo,org.apache.camel,javax.xml.bind,javax.jms,org.
 apache.activemq",outotec.pi.mes.id51.plantstanstillhours;uses:="javax
 .jws.soap,com.ibm.maximo,javax.jws,javax.xml.bind.annotation,javax.xm
 l.ws,javax.xml.namespace"
Built-By: RE267981
Tool: Bnd-1.15.0
Bundle-Name: Plant StandStill hours/Asset Down Time
Created-By: Apache Maven Bundle Plugin
DynamicImport-Package: com.mysql.jdbc
Build-Jdk: 1.7.0_04
Bundle-Version: 1.0.0
Bnd-LastModified: 1393395488065
Bundle-ManifestVersion: 2
Bundle-Description: Creates a web service using the Asset Down Time Ws
 dl. We are exposing to MES. We will consume EAM and PI Service.
Bundle-SymbolicName: com.outotec.asset-down-time
Import-Package: javax.activation;version="1.1",javax.jms;version="[1.1
 ,2)",javax.jws,javax.jws.soap,javax.sql,javax.xml.bind,javax.xml.bind
 .annotation,javax.xml.bind.annotation.adapters,javax.xml.datatype,jav
 ax.xml.namespace,javax.xml.parsers,javax.xml.transform,javax.xml.tran
 sform.dom,javax.xml.transform.stream,javax.xml.ws,org.apache.activemq
 ,org.apache.activemq.broker,org.apache.activemq.camel.component,org.a
 pache.activemq.jaas,org.apache.activemq.pool,org.apache.activemq.secu
 rity,org.apache.activemq.spring,org.apache.activemq.xbean,org.apache.
 camel;version="[2.10,3)",org.apache.camel.builder;version="[2.10,3)",
 org.apache.camel.component.jms;version="[2.10,3)",org.apache.camel.pr
 ocessor;version="[2.10,3)",org.apache.cxf.binding;version="[2.6,3)",o
 rg.apache.cxf.binding.soap.interceptor;version="[2.6,3)",org.apache.c
 xf.configuration.security;version="[2.6,3)",org.apache.cxf.endpoint;v
 ersion="[2.6,3)",org.apache.cxf.interceptor;version="[2.6,3)",org.apa
 che.cxf.message;version="[2.6,3)",org.apache.cxf.transport;version="[
 2.6,3)",org.apache.cxf.ws.addressing;version="[2.6,3)",org.apache.log
 4j,org.springframework.beans.factory.annotation;version="[3.0,4)",org
 .w3c.dom



Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
Reply | Threaded
Open this post in threaded view
|

Re: JDBC Connection object in Camel Processor

Claus Ibsen-2
Hi

Try with
      <DynamicImport-Package>*</DynamicImport-Package>



On Wed, Feb 26, 2014 at 7:26 AM, contactreji <[hidden email]> wrote:

> Hi Clause
>
> Thanks for your prompt help! :-)
>
> I followed your advice and did following changes in the POM file.
>
> *<plugin>
>                                 <groupId>org.apache.felix</groupId>
>                                 <artifactId>maven-bundle-plugin</artifactId>
>                                 <version>2.3.4</version>
>                                 <extensions>true</extensions>
>                                 <configuration>
>
>                                         <instructions>
>                                                 <Import-Package>org.apache.activemq.xbean,
>                                                         javax.activation;version=1.1,
>                                                         org.apache.activemq.spring,
>                                                         org.apache.activemq.broker,
>                                                         org.apache.activemq.security,
>                                                         org.apache.activemq.jaas,
>                                                         org.apache.activemq.pool,
>                                                         org.apache.activemq.camel.component,
>                                                         org.apache.camel.component.jms,
>                                                         *</Import-Package>
>                                                 <DynamicImport-Package>com.mysql.jdbc</DynamicImport-Package>
>                                 </instructions>
>                 </configuration>
> </plugin>*
>
> How ever, I couldnt get a difference. On building project in maven, I got a
> deployable jar file. Following is the content of the MANIFEST file inside
> the jar file.
> It shows the Dynamic Import of the package *DynamicImport-Package:
> com.mysql.jdbc*
>
> *Manifest-Version: 1.0
> Export-Package: com.ibm.maximo;uses:="javax.xml.bind.annotation,javax.
>  xml.bind,javax.xml.datatype,com.ibm.maximo.runtime,javax.xml.bind.ann
>  otation.adapters,javax.xml.namespace",com.ibm.maximo.runtime;uses:="j
>  avax.xml.bind.annotation.adapters,javax.xml.bind",com.ibm.maximo.wsdl
>  .otecwebservices_otecdowntime;uses:="javax.xml.ws,javax.xml.namespace
>  ,javax.jws.soap,com.ibm.maximo,javax.jws,javax.xml.bind.annotation",c
>  om.outotec.asset.downtime;uses:="javax.activation,org.apache.camel,or
>  g.apache.log4j,org.springframework.beans.factory.annotation,org.apach
>  e.cxf.ws.addressing,org.apache.cxf.binding,org.apache.cxf.message,org
>  .apache.cxf.configuration.security,org.apache.cxf.transport,org.apach
>  e.cxf.binding.soap.interceptor,org.apache.cxf.endpoint,org.apache.cxf
>  .interceptor,javax.xml.parsers,javax.xml.transform.dom,org.w3c.dom,co
>  m.ibm.maximo.wsdl.otecwebservices_otecdowntime,com.ibm.maximo,javax.s
>  ql,javax.xml.transform,javax.xml.transform.stream,javax.xml.bind,outo
>  tec.pi.mes.id51.plantstanstillhours",com.outotec.serializationclasses
>  ;uses:="com.ibm.maximo,org.apache.camel,javax.xml.bind,javax.jms,org.
>  apache.activemq",outotec.pi.mes.id51.plantstanstillhours;uses:="javax
>  .jws.soap,com.ibm.maximo,javax.jws,javax.xml.bind.annotation,javax.xm
>  l.ws,javax.xml.namespace"
> Built-By: RE267981
> Tool: Bnd-1.15.0
> Bundle-Name: Plant StandStill hours/Asset Down Time
> Created-By: Apache Maven Bundle Plugin
> DynamicImport-Package: com.mysql.jdbc
> Build-Jdk: 1.7.0_04
> Bundle-Version: 1.0.0
> Bnd-LastModified: 1393395488065
> Bundle-ManifestVersion: 2
> Bundle-Description: Creates a web service using the Asset Down Time Ws
>  dl. We are exposing to MES. We will consume EAM and PI Service.
> Bundle-SymbolicName: com.outotec.asset-down-time
> Import-Package: javax.activation;version="1.1",javax.jms;version="[1.1
>  ,2)",javax.jws,javax.jws.soap,javax.sql,javax.xml.bind,javax.xml.bind
>  .annotation,javax.xml.bind.annotation.adapters,javax.xml.datatype,jav
>  ax.xml.namespace,javax.xml.parsers,javax.xml.transform,javax.xml.tran
>  sform.dom,javax.xml.transform.stream,javax.xml.ws,org.apache.activemq
>  ,org.apache.activemq.broker,org.apache.activemq.camel.component,org.a
>  pache.activemq.jaas,org.apache.activemq.pool,org.apache.activemq.secu
>  rity,org.apache.activemq.spring,org.apache.activemq.xbean,org.apache.
>  camel;version="[2.10,3)",org.apache.camel.builder;version="[2.10,3)",
>  org.apache.camel.component.jms;version="[2.10,3)",org.apache.camel.pr
>  ocessor;version="[2.10,3)",org.apache.cxf.binding;version="[2.6,3)",o
>  rg.apache.cxf.binding.soap.interceptor;version="[2.6,3)",org.apache.c
>  xf.configuration.security;version="[2.6,3)",org.apache.cxf.endpoint;v
>  ersion="[2.6,3)",org.apache.cxf.interceptor;version="[2.6,3)",org.apa
>  che.cxf.message;version="[2.6,3)",org.apache.cxf.transport;version="[
>  2.6,3)",org.apache.cxf.ws.addressing;version="[2.6,3)",org.apache.log
>  4j,org.springframework.beans.factory.annotation;version="[3.0,4)",org
>  .w3c.dom*
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/JDBC-Connection-object-in-Camel-Processor-tp5747896p5747989.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io
Reply | Threaded
Open this post in threaded view
|

Re: JDBC Connection object in Camel Processor

contactreji
Hi Claus

I have modified my POM to look like

        <plugin>
                                <groupId>org.apache.felix</groupId>
                                <artifactId>maven-bundle-plugin</artifactId>
                                <version>2.3.4</version>
                                <extensions>true</extensions>
                                <configuration>

                                        <instructions>
                                                <Import-Package>org.apache.activemq.xbean,
                                                        javax.activation;version=1.1,
                                                        org.apache.activemq.spring,
                                                        org.apache.activemq.broker,
                                                        org.apache.activemq.security,
                                                        org.apache.activemq.jaas,
                                                        org.apache.activemq.pool,
                                                        org.apache.activemq.camel.component,
                                                        org.apache.camel.component.jms,
                                                        *</Import-Package>
                                                <DynamicImport-Package>*</DynamicImport-Package>
                                        </instructions>
                                </configuration>
                        </plugin>


The MANIFEST file too contains the DynamicImport details

Manifest-Version: 1.0
Export-Package: com.ibm.maximo;uses:="javax.xml.bind.annotation,javax.
 xml.bind,javax.xml.datatype,com.ibm.maximo.runtime,javax.xml.bind.ann
 otation.adapters,javax.xml.namespace",com.ibm.maximo.runtime;uses:="j
 avax.xml.bind.annotation.adapters,javax.xml.bind",com.ibm.maximo.wsdl
 .otecwebservices_otecdowntime;uses:="javax.xml.ws,javax.xml.namespace
 ,javax.jws.soap,com.ibm.maximo,javax.jws,javax.xml.bind.annotation",c
 om.outotec.asset.downtime;uses:="javax.activation,org.apache.camel,or
 g.apache.log4j,org.springframework.beans.factory.annotation,org.apach
 e.cxf.ws.addressing,org.apache.cxf.binding,org.apache.cxf.message,org
 .apache.cxf.configuration.security,org.apache.cxf.transport,org.apach
 e.cxf.binding.soap.interceptor,org.apache.cxf.endpoint,org.apache.cxf
 .interceptor,javax.xml.parsers,javax.xml.transform.dom,org.w3c.dom,co
 m.ibm.maximo.wsdl.otecwebservices_otecdowntime,com.ibm.maximo,javax.s
 ql,javax.xml.transform,javax.xml.transform.stream,javax.xml.bind,outo
 tec.pi.mes.id51.plantstanstillhours",com.outotec.serializationclasses
 ;uses:="com.ibm.maximo,org.apache.camel,javax.xml.bind,javax.jms,org.
 apache.activemq",com.test;uses:="javax.sql,org.apache.camel,org.sprin
 gframework.jdbc.core",outotec.pi.mes.id51.plantstanstillhours;uses:="
 javax.jws.soap,com.ibm.maximo,javax.jws,javax.xml.bind.annotation,jav
 ax.xml.ws,javax.xml.namespace"
Built-By: RE267981
Tool: Bnd-1.15.0
Bundle-Name: Plant StandStill hours/Asset Down Time
Created-By: Apache Maven Bundle Plugin
DynamicImport-Package: *
Build-Jdk: 1.7.0_04
Bundle-Version: 1.0.0
Bnd-LastModified: 1393403229333
Bundle-ManifestVersion: 2


Still I get the same error.

Can you advice me if I need to add any spl maven dependency apart from those added as show
<dependencies>

                <dependency>
                        <groupId>org.osgi</groupId>
                        <artifactId>org.osgi.core</artifactId>
                        <version>4.3.0</version>
                </dependency>

                <dependency>
                        <groupId>hsqldb</groupId>
                        <artifactId>hsqldb</artifactId>
                        <version>1.8.0.10</version>
                </dependency>

                <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.6</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-sql</artifactId>
                        <version>2.10.0.fuse-71-047</version>
                </dependency>

               
                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-core</artifactId>
                        <version>2.10.0.fuse-71-047</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-cxf</artifactId>
                        <version>2.10.0.fuse-71-047</version>
                </dependency>

                <dependency>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                        <version>1.2.16</version>
                </dependency>

               
                <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>org.apache.cxf</groupId>
                        <artifactId>cxf-rt-transports-http-jetty</artifactId>
                        <version>2.6.0.fuse-71-047</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-test-spring</artifactId>
                        <version>2.10.0.fuse-71-047</version>
                        <scope>test</scope>
                </dependency>

                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                        <version>4.10</version>
                        <scope>test</scope>
                </dependency>


               


                <dependency>
                        <groupId>commons-lang</groupId>
                        <artifactId>commons-lang</artifactId>
                        <version>2.6</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.commons</groupId>
                        <artifactId>commons-lang3</artifactId>
                        <version>3.1</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-mail</artifactId>
                        <version>2.10.6</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.servicemix.specs</groupId>
                        <artifactId>org.apache.servicemix.specs.activation-api-1.1</artifactId>
                        <version>2.1.0</version>
                </dependency>

                <dependency>
                        <groupId>javax.mail</groupId>
                        <artifactId>mail</artifactId>
                        <version>1.4</version>
                </dependency>


                <dependency>
                        <groupId>org.apache.activemq</groupId>
                        <artifactId>activemq-camel</artifactId>
                        <version>5.8.0</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-mail</artifactId>
                        <version>2.10.0.fuse-71-047</version>

                </dependency>


               

                <dependency>
                        <groupId>commons-dbcp</groupId>
                        <artifactId>commons-dbcp</artifactId>
                        <version>20030825.184428</version>
                </dependency>


        </dependencies>

I have enabled camel-sql feature in the Jboss Fuse features too.
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
Reply | Threaded
Open this post in threaded view
|

Re: JDBC Connection object in Camel Processor

Claus Ibsen-2
You need to install the JDBC driver first.
Then afterwards your own application.


On Wed, Feb 26, 2014 at 9:49 AM, contactreji <[hidden email]> wrote:

> Hi Claus
>
> I have modified my POM to look like
>
>         <plugin>
>                                 <groupId>org.apache.felix</groupId>
>                                 <artifactId>maven-bundle-plugin</artifactId>
>                                 <version>2.3.4</version>
>                                 <extensions>true</extensions>
>                                 <configuration>
>
>                                         <instructions>
>                                                 <Import-Package>org.apache.activemq.xbean,
>                                                         javax.activation;version=1.1,
>                                                         org.apache.activemq.spring,
>                                                         org.apache.activemq.broker,
>                                                         org.apache.activemq.security,
>                                                         org.apache.activemq.jaas,
>                                                         org.apache.activemq.pool,
>                                                         org.apache.activemq.camel.component,
>                                                         org.apache.camel.component.jms,
>                                                         *</Import-Package>
>                                                 <DynamicImport-Package>*</DynamicImport-Package>
>                                         </instructions>
>                                 </configuration>
>                         </plugin>
>
>
> The MANIFEST file too contains the DynamicImport details
>
> Manifest-Version: 1.0
> Export-Package: com.ibm.maximo;uses:="javax.xml.bind.annotation,javax.
>  xml.bind,javax.xml.datatype,com.ibm.maximo.runtime,javax.xml.bind.ann
>  otation.adapters,javax.xml.namespace",com.ibm.maximo.runtime;uses:="j
>  avax.xml.bind.annotation.adapters,javax.xml.bind",com.ibm.maximo.wsdl
>  .otecwebservices_otecdowntime;uses:="javax.xml.ws,javax.xml.namespace
>  ,javax.jws.soap,com.ibm.maximo,javax.jws,javax.xml.bind.annotation",c
>  om.outotec.asset.downtime;uses:="javax.activation,org.apache.camel,or
>  g.apache.log4j,org.springframework.beans.factory.annotation,org.apach
>  e.cxf.ws.addressing,org.apache.cxf.binding,org.apache.cxf.message,org
>  .apache.cxf.configuration.security,org.apache.cxf.transport,org.apach
>  e.cxf.binding.soap.interceptor,org.apache.cxf.endpoint,org.apache.cxf
>  .interceptor,javax.xml.parsers,javax.xml.transform.dom,org.w3c.dom,co
>  m.ibm.maximo.wsdl.otecwebservices_otecdowntime,com.ibm.maximo,javax.s
>  ql,javax.xml.transform,javax.xml.transform.stream,javax.xml.bind,outo
>  tec.pi.mes.id51.plantstanstillhours",com.outotec.serializationclasses
>  ;uses:="com.ibm.maximo,org.apache.camel,javax.xml.bind,javax.jms,org.
>  apache.activemq",com.test;uses:="javax.sql,org.apache.camel,org.sprin
>  gframework.jdbc.core",outotec.pi.mes.id51.plantstanstillhours;uses:="
>  javax.jws.soap,com.ibm.maximo,javax.jws,javax.xml.bind.annotation,jav
>  ax.xml.ws,javax.xml.namespace"
> Built-By: RE267981
> Tool: Bnd-1.15.0
> Bundle-Name: Plant StandStill hours/Asset Down Time
> Created-By: Apache Maven Bundle Plugin
> *DynamicImport-Package: **
> Build-Jdk: 1.7.0_04
> Bundle-Version: 1.0.0
> Bnd-LastModified: 1393403229333
> Bundle-ManifestVersion: 2
>
>
> Still I get the same error.
>
> Can you advice me if I need to add any spl maven dependency apart from those
> added as show
> <dependencies>
>
>                 <dependency>
>                         <groupId>org.osgi</groupId>
>                         <artifactId>org.osgi.core</artifactId>
>                         <version>4.3.0</version>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>hsqldb</groupId>
>                         <artifactId>hsqldb</artifactId>
>                         <version>1.8.0.10</version>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>mysql</groupId>
>                         <artifactId>mysql-connector-java</artifactId>
>                         <version>5.1.6</version>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>org.apache.camel</groupId>
>                         <artifactId>camel-sql</artifactId>
>                         <version>2.10.0.fuse-71-047</version>
>                 </dependency>
>
>
>                 <dependency>
>                         <groupId>org.apache.camel</groupId>
>                         <artifactId>camel-core</artifactId>
>                         <version>2.10.0.fuse-71-047</version>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>org.apache.camel</groupId>
>                         <artifactId>camel-cxf</artifactId>
>                         <version>2.10.0.fuse-71-047</version>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>log4j</groupId>
>                         <artifactId>log4j</artifactId>
>                         <version>1.2.16</version>
>                 </dependency>
>
>
>                 <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>org.apache.cxf</groupId>
>                         <artifactId>cxf-rt-transports-http-jetty</artifactId>
>                         <version>2.6.0.fuse-71-047</version>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>org.apache.camel</groupId>
>                         <artifactId>camel-test-spring</artifactId>
>                         <version>2.10.0.fuse-71-047</version>
>                         <scope>test</scope>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>junit</groupId>
>                         <artifactId>junit</artifactId>
>                         <version>4.10</version>
>                         <scope>test</scope>
>                 </dependency>
>
>
>
>
>
>                 <dependency>
>                         <groupId>commons-lang</groupId>
>                         <artifactId>commons-lang</artifactId>
>                         <version>2.6</version>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>org.apache.commons</groupId>
>                         <artifactId>commons-lang3</artifactId>
>                         <version>3.1</version>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>org.apache.camel</groupId>
>                         <artifactId>camel-mail</artifactId>
>                         <version>2.10.6</version>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>org.apache.servicemix.specs</groupId>
>                         <artifactId>org.apache.servicemix.specs.activation-api-1.1</artifactId>
>                         <version>2.1.0</version>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>javax.mail</groupId>
>                         <artifactId>mail</artifactId>
>                         <version>1.4</version>
>                 </dependency>
>
>
>                 <dependency>
>                         <groupId>org.apache.activemq</groupId>
>                         <artifactId>activemq-camel</artifactId>
>                         <version>5.8.0</version>
>                 </dependency>
>
>                 <dependency>
>                         <groupId>org.apache.camel</groupId>
>                         <artifactId>camel-mail</artifactId>
>                         <version>2.10.0.fuse-71-047</version>
>
>                 </dependency>
>
>
>
>
>                 <dependency>
>                         <groupId>commons-dbcp</groupId>
>                         <artifactId>commons-dbcp</artifactId>
>                         <version>20030825.184428</version>
>                 </dependency>
>
>
>         </dependencies>
>
> I have enabled camel-sql feature in the Jboss Fuse features too.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/JDBC-Connection-object-in-Camel-Processor-tp5747896p5747996.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io
Reply | Threaded
Open this post in threaded view
|

Re: JDBC Connection object in Camel Processor

contactreji
Hi Claus

I have installed the driver from the link http://dev.mysql.com/downloads/connector/j/5.1.html

I am using windows platform. hence I used the driver available at the above link.

I am still getting the same error. The driver doesn't seem to load.

Do we have anything else to check in the camel - project itself? Any change to be made to Jboss Fuse configurations?

Regards
Reji Mathews
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
Reply | Threaded
Open this post in threaded view
|

Re: JDBC Connection object in Camel Processor

contactreji
In reply to this post by Christian Mueller
Hi Christian

Can you give me the link of an example which  illustrated injection of the connection pool?
It will be helpful for me to understand in a better way.

Regards
Reji Mathews
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
Reply | Threaded
Open this post in threaded view
|

Re: JDBC Connection object in Camel Processor

Christian Mueller
Administrator
This is an example how to configure a pooled data source which is injected
into a transaction manager. You have to inject it into a processor instead.

[1]
https://github.com/muellerc/camel-in-transaction/blob/master/src/test/resources/META-INF/spring/JdbcTransactionSampleTest-context.xml

Best,

Christian
-----------------

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Wed, Feb 26, 2014 at 11:02 AM, contactreji <[hidden email]> wrote:

> Hi Christian
>
> Can you give me the link of an example which  illustrated injection of the
> connection pool?
> It will be helpful for me to understand in a better way.
>
> Regards
> Reji Mathews
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/JDBC-Connection-object-in-Camel-Processor-tp5747896p5748005.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: JDBC Connection object in Camel Processor

ceposta
also consider using an osgi service for your pooling facotry and
blueprint (or declarative services) to grab the connection/pool

On Fri, Feb 28, 2014 at 2:18 PM, Christian Müller
<[hidden email]> wrote:

> This is an example how to configure a pooled data source which is injected
> into a transaction manager. You have to inject it into a processor instead.
>
> [1]
> https://github.com/muellerc/camel-in-transaction/blob/master/src/test/resources/META-INF/spring/JdbcTransactionSampleTest-context.xml
>
> Best,
>
> Christian
> -----------------
>
> Software Integration Specialist
>
> Apache Member
> V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
> Apache Incubator PMC Member
>
> https://www.linkedin.com/pub/christian-mueller/11/551/642
>
>
> On Wed, Feb 26, 2014 at 11:02 AM, contactreji <[hidden email]> wrote:
>
>> Hi Christian
>>
>> Can you give me the link of an example which  illustrated injection of the
>> connection pool?
>> It will be helpful for me to understand in a better way.
>>
>> Regards
>> Reji Mathews
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/JDBC-Connection-object-in-Camel-Processor-tp5747896p5748005.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>



--
Christian Posta
http://www.christianposta.com/blog
twitter: @christianposta