You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Shiv <sh...@gmail.com> on 2014/05/02 11:35:03 UTC

java.lang.NullPointerException in Camel JDBC component for Select statement

Hi all,
I am using Camel JDBC component for first time and I need to query a table
in MS SQL Server 2008 R2 and push the results to an ActiveMQ queue. I used
the details on http://camel.apache.org/jdbc.html page and tried to get the
setup. Once my route define in Spring configuration file is started, I am
getting java.lang.NullPointerException  in log. I am using Camel 2.2.0 (it
is pretty old but is part of a legacy system).  I have camel-jdbc-2.2.0,
sqljdbc4 and org.springframework.jdbc-2.5.6 jars on classpath. any input
will be great.

Route detail:
-----------------------------
<from uri="timer://kickoff?period=1000"/>
            <setBody><constant>select * from test</constant></setBody>
<to uri="jdbc:testdb"/>
<to uri="activemq:queue:testdb"/>

Data Source:
-----------------
<bean id="testdb"
class="org.springframework.jdbc.datasource.SimpleDriverDataSource"> 
        <property name="driverClass"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/> 
        <property name=&quot;url&quot;
value=&quot;jdbc:microsoft:sqlserver://&lt;host
name>:1433;DatabaseName=test"/> 
        <property name="username" value="test"/> 
        <property name="password" value="test"/> 
</bean>

Exception log:
-------------------
2014-05-02 14:39:59,467 | INFO  | Exchange[
, Id:6d87d9ba-85ef-4cf6-a9f7-a4b1be999f1b
,
Properties:{CamelToEndpoint=log://toDLC?multiline=true&showAll=true&showCaughtException=true,
CamelTimerFiredTime=Fri May 02 14:39:59 IST 2014,
CamelFailureEndpoint=jdbc://testdb, CamelTimerPeriod=1000,
CamelTimerName=kickoff, CamelExceptionCaught=java.lang.NullPointerException}
, Headers:{firedTime=Fri May 02 14:39:59 IST 2014}
, BodyType:String
, Body:select * from test
, CaughtExceptionType:java.lang.NullPointerException,
CaughtExceptionMessage:null, StackTrace:java.lang.NullPointerException
	at
org.apache.camel.component.jdbc.JdbcProducer.process(JdbcProducer.java:67)
	at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97)
	at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:95)
	at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
	at
org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
	at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
	at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
	at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93)
	at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
	at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:177)
	at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:143)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:88)
	at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:56)
	at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
	at
org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:66)
	at
org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
	at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:103)
	at
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:50)
	at java.util.TimerThread.mainLoop(Timer.java:512)



--
View this message in context: http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Charles Moulliard <ch...@gmail.com>.
You jar must be deployed as a bundle on Karaf. If this jar is not a bundle,
then you should use wrap protocol to generate OSGI metadata required
toexport/import packages

https://ops4j1.jira.com/wiki/display/paxurl/Wrap+Protocol
http://fusesource.com/docs/esb/4.2/deploy_osgi/DeployJar-Wrap.html



On Wed, May 7, 2014 at 7:40 AM, Shiv <sh...@gmail.com> wrote:

> Also, if I remove sqljdbc jar from lib folder, I am getting below
> exception.
> Seems if the jar is present it is able to pick the class and if it is not
> present it fails:
>
> INFO   | jvm 1    | 2014/05/07 11:04:54 | ERROR:
> java.lang.RuntimeException:
> Failed to execute start task. Reason:
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean
> with name 'testdb' defined in class path resource [app.xml]: Initialization
> of bean failed; nested exception is
> org.springframework.beans.TypeMismatchException: Failed to convert property
> value of type [java.lang.String] to required type [java.lang.Class] for
> property 'driverClass'; nested exception is
> java.lang.IllegalArgumentException: Cannot find class
> [com.microsoft.sqlserver.jdbc.SQLServerDriver]
>
> I don't get this error when sqljdbc jar is present.
>
> Thanks
> Shiv
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750942.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Shiv <sh...@gmail.com>.
Finally i got the root cause of issue and fixed it. It was not actually
related to classpath but it was caused due to wrong DB connection string.

It was defined as <property name=&quot;url&quot;
value=&quot;jdbc:microsoft:sqlserver://&lt;hostname>:1433;DatabaseName=testdb"/> 
as per info from Fuse ESB page JDBC page (table 6) but it should be
<property name=&quot;url&quot;
value=&quot;jdbc:sqlserver://&lt;hostname>:1433;DatabaseName=testdb"/>

Post changes I am able to run select query.

Now I am trying with SQL language in my querying. I copied
camel-script-2.2.0 and camel-josql-2.2.0 jars. My route is as below:

<from uri="timer://kickoff?period=5000"/>
<setBody>
	<sql>select * from test</sql>
</setBody>
<to uri="jdbc:testdb"/>

But it is giving below exception:
2014-05-07 12:35:04,158 | DEBUG | Failed delivery for exchangeId:
278c5aa1-4605-407c-bb38-173521a45fe3. On delivery attempt: 0 caught:
java.lang.IllegalArgumentException: No script engine could be created for:
sql | org.apache.camel.processor.DeadLetterChannel | kickoff

2014-05-07 12:35:04,165 | DEBUG | Failed delivery for exchangeId:
278c5aa1-4605-407c-bb38-173521a45fe3. On delivery attempt: 0 caught:
org.apache.camel.InvalidPayloadException: No body available of type:
java.lang.String on: Message: [Body is null]. Caused by: No type converter
available to convert from type: null to the required type: java.lang.String
with value null. Exchange[Message: [Body is null]]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type: null to the required type: java.lang.String
with value null] | org.apache.camel.processor.DefaultErrorHandler | kickoff
2014-05-07 12:35:04,166 | ERROR | Failed delivery for exchangeId:
278c5aa1-4605-407c-bb38-173521a45fe3. Exhausted after delivery attempt: 1
caught: org.apache.camel.InvalidPayloadException: No body available of type:
java.lang.String on: Message: [Body is null]. Caused by: No type converter
available to convert from type: null to the required type: java.lang.String
with value null. Exchange[Message: [Body is null]]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type: null to the required type: java.lang.String
with value null] | org.apache.camel.processor.DefaultErrorHandler | kickoff
org.apache.camel.InvalidPayloadException: No body available of type:
java.lang.String on: Message: [Body is null]. Caused by: No type converter
available to convert from type: null to the required type: java.lang.String
with value null. Exchange[Message: [Body is null]]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type: null to the required type: java.lang.String
with value null]
	at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:103)
	at
org.apache.camel.processor.ConvertBodyProcessor.process(ConvertBodyProcessor.java:55




--
View this message in context: http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750943.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Shiv <sh...@gmail.com>.
Also, if I remove sqljdbc jar from lib folder, I am getting below exception.
Seems if the jar is present it is able to pick the class and if it is not
present it fails:

INFO   | jvm 1    | 2014/05/07 11:04:54 | ERROR: java.lang.RuntimeException:
Failed to execute start task. Reason:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'testdb' defined in class path resource [app.xml]: Initialization
of bean failed; nested exception is
org.springframework.beans.TypeMismatchException: Failed to convert property
value of type [java.lang.String] to required type [java.lang.Class] for
property 'driverClass'; nested exception is
java.lang.IllegalArgumentException: Cannot find class
[com.microsoft.sqlserver.jdbc.SQLServerDriver]

I don't get this error when sqljdbc jar is present.

Thanks
Shiv



--
View this message in context: http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750942.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Abby Van Rooyen <ab...@precisionsourcing.com.au>.
Ok my apologies, I will re direct my self to those groups...

Abby Van Rooyen 
Practice Team Lead- Development 
Precision Sourcing 

> On 6 May 2014, at 4:16 pm, "Charles Moulliard" <ch...@gmail.com> wrote:
> 
> Hy Abby,
> 
> Such a message should not be posted here on that mailing list. I would like
> to invite you to use social media like Apache Camel group on linkedin or
> Google+ Apache Camel for such announcement.
> 
> Regards,
> 
> 
> On Tue, May 6, 2014 at 1:54 AM, Abby Van Rooyen <
> abby@precisionsourcing.com.au> wrote:
> 
>> Hey guys and girls!
>> 
>> I wonder if you can help me at all?
>> 
>> I am currently working with a client of mine to find some strong
>> integration developers who have quality Fuse and Camel skills to work on
>> either a contract or permanent basis in Sydney.
>> 
>> Can anyone suggest a suitable candidate for me? We also offer a $500
>> referral scheme if someone that you refer secures the role.
>> 
>> Thanks
>> 
>> Kind Regards,
>> 
>> Abby Van Rooyen
>> Practice Team Lead - Development
>> Precision Sourcing
>> D: +61 2 8246 7702
>> 
>> 
>> -----Original Message-----
>> From: Charles Moulliard [mailto:ch007m@gmail.com]
>> Sent: Tuesday, 6 May 2014 4:52 AM
>> To: users@camel.apache.org
>> Subject: Re: java.lang.NullPointerException in Camel JDBC component for
>> Select statement
>> 
>> That means that Spring JDBC has not been able to load your MSQL Driver
>> Class. I recommend that you have a look to the classpath.
>> 
>> 
>>> On Mon, May 5, 2014 at 8:00 PM, Shiv <sh...@gmail.com> wrote:
>>> 
>>> I do not see any log statement from DriverManagerDataSource class in
>>> my log file :(.
>>> 
>>> Thanks
>>> Shiv
>>> 
>>> 
>>> 
>>> --
>>> View this message in context:
>>> http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Ca
>>> mel-JDBC-component-for-Select-statement-tp5750783p5750881.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>> 
>> 
>> 
>> --
>> Charles Moulliard
>> Apache Committer / Architect @RedHat
>> Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
> 
> 
> 
> -- 
> Charles Moulliard
> Apache Committer / Architect @RedHat
> Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Charles Moulliard <ch...@gmail.com>.
Hy Abby,

Such a message should not be posted here on that mailing list. I would like
to invite you to use social media like Apache Camel group on linkedin or
Google+ Apache Camel for such announcement.

Regards,


On Tue, May 6, 2014 at 1:54 AM, Abby Van Rooyen <
abby@precisionsourcing.com.au> wrote:

> Hey guys and girls!
>
> I wonder if you can help me at all?
>
> I am currently working with a client of mine to find some strong
> integration developers who have quality Fuse and Camel skills to work on
> either a contract or permanent basis in Sydney.
>
> Can anyone suggest a suitable candidate for me? We also offer a $500
> referral scheme if someone that you refer secures the role.
>
> Thanks
>
> Kind Regards,
>
> Abby Van Rooyen
> Practice Team Lead - Development
> Precision Sourcing
> D: +61 2 8246 7702
>
>
> -----Original Message-----
> From: Charles Moulliard [mailto:ch007m@gmail.com]
> Sent: Tuesday, 6 May 2014 4:52 AM
> To: users@camel.apache.org
> Subject: Re: java.lang.NullPointerException in Camel JDBC component for
> Select statement
>
> That means that Spring JDBC has not been able to load your MSQL Driver
> Class. I recommend that you have a look to the classpath.
>
>
> On Mon, May 5, 2014 at 8:00 PM, Shiv <sh...@gmail.com> wrote:
>
> > I do not see any log statement from DriverManagerDataSource class in
> > my log file :(.
> >
> > Thanks
> > Shiv
> >
> >
> >
> > --
> > View this message in context:
> > http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Ca
> > mel-JDBC-component-for-Select-statement-tp5750783p5750881.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>
>
>
> --
> Charles Moulliard
> Apache Committer / Architect @RedHat
> Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

RE: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Abby Van Rooyen <ab...@precisionsourcing.com.au>.
Hey guys and girls! 

I wonder if you can help me at all? 

I am currently working with a client of mine to find some strong integration developers who have quality Fuse and Camel skills to work on either a contract or permanent basis in Sydney. 

Can anyone suggest a suitable candidate for me? We also offer a $500 referral scheme if someone that you refer secures the role. 

Thanks 

Kind Regards,

Abby Van Rooyen
Practice Team Lead - Development
Precision Sourcing
D: +61 2 8246 7702


-----Original Message-----
From: Charles Moulliard [mailto:ch007m@gmail.com] 
Sent: Tuesday, 6 May 2014 4:52 AM
To: users@camel.apache.org
Subject: Re: java.lang.NullPointerException in Camel JDBC component for Select statement

That means that Spring JDBC has not been able to load your MSQL Driver Class. I recommend that you have a look to the classpath.


On Mon, May 5, 2014 at 8:00 PM, Shiv <sh...@gmail.com> wrote:

> I do not see any log statement from DriverManagerDataSource class in 
> my log file :(.
>
> Thanks
> Shiv
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Ca
> mel-JDBC-component-for-Select-statement-tp5750783p5750881.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Charles Moulliard <ch...@gmail.com>.
As Fuse ESB is an OSGI platform, the jar file should be deployed as bundles
using osgi:install command on karaf (
http://karaf.apache.org/manual/latest-2.3.x/commands/osgi-install.html). A
feature file exist to deploy the camel bundles so normally you should use
features:install camel-jdbc or camel-sql if you use camel with Spring for
SQL


On Wed, May 7, 2014 at 8:33 AM, Shiv <sh...@gmail.com> wrote:

> Since I am using Fuse ESB 5.3.0, I have copied sqljdbc.jar,
> org.springframework.jdbc-2.5.6.jar and camel-jdbc-2.2.0.jar to FUSE
> HOME/lib
> folder.
>
> Is this is not the right location or do we need more jars?
>
> Thanks
> Shiv
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750941.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Shiv <sh...@gmail.com>.
Since I am using Fuse ESB 5.3.0, I have copied sqljdbc.jar,
org.springframework.jdbc-2.5.6.jar and camel-jdbc-2.2.0.jar to FUSE HOME/lib
folder.

Is this is not the right location or do we need more jars?

Thanks
Shiv



--
View this message in context: http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750941.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Charles Moulliard <ch...@gmail.com>.
That means that Spring JDBC has not been able to load your MSQL Driver
Class. I recommend that you have a look to the classpath.


On Mon, May 5, 2014 at 8:00 PM, Shiv <sh...@gmail.com> wrote:

> I do not see any log statement from DriverManagerDataSource class in my log
> file :(.
>
> Thanks
> Shiv
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750881.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Shiv <sh...@gmail.com>.
I do not see any log statement from DriverManagerDataSource class in my log
file :(.

Thanks
Shiv



--
View this message in context: http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750881.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Charles Moulliard <ch...@gmail.com>.
Can you verify that in your log Spring has reported that the Driver has
been loaded correctly ?
https://github.com/spring-projects/spring-framework/blob/master/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DriverManagerDataSource.java#L133


On Mon, May 5, 2014 at 4:46 PM, Shiv <sh...@gmail.com> wrote:

> conn maybe null if any of the parameters is invalid, right?
>
> If everything alright with below configuration for MS SQL Server?
> <bean id="testdb"
> class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
>         <property name="driverClass"
> value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
>         <property name="url"
> value="jdbc:microsoft:sqlserver://hostname:1433;DatabaseName=testdb"/>
>         <property name="username" value="test"/>
>         <property name="password" value="test"/>
> </bean>
>
> Also, if I understand the flow correctly, JDBC Producer class calls conn =
> dataSource.getConnection() which is handled by SimpleDriverDataSource
> class's getConnectionFromDriver method given all parameters (driverClass,
> url, username, password) are set. Here all the arguments defined in Spring
> configuration file are String but SimpleDriverDataSource class has one
> method setDriver(Driver) which is expecting java.sql.Driver. Though i doubt
> it but if this conversion is not happening properly? - Just a wild guess.
>
> Also, since i am using camel core and camel jdbc 2.2.0 jars, if there is
> any
> fixed version of spring jdbc jar has to be used. Currently, i downloaded
> 2.5.6 version of spring jdbc jar. Any compatibility issue?
>
> Thanks
> Shiv
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750872.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Shiv <sh...@gmail.com>.
conn maybe null if any of the parameters is invalid, right?

If everything alright with below configuration for MS SQL Server?
<bean id="testdb"
class="org.springframework.jdbc.datasource.SimpleDriverDataSource"> 
        <property name="driverClass"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/> 
        <property name="url"
value="jdbc:microsoft:sqlserver://hostname:1433;DatabaseName=testdb"/> 
        <property name="username" value="test"/> 
        <property name="password" value="test"/> 
</bean>

Also, if I understand the flow correctly, JDBC Producer class calls conn =
dataSource.getConnection() which is handled by SimpleDriverDataSource
class's getConnectionFromDriver method given all parameters (driverClass,
url, username, password) are set. Here all the arguments defined in Spring
configuration file are String but SimpleDriverDataSource class has one
method setDriver(Driver) which is expecting java.sql.Driver. Though i doubt
it but if this conversion is not happening properly? - Just a wild guess.

Also, since i am using camel core and camel jdbc 2.2.0 jars, if there is any
fixed version of spring jdbc jar has to be used. Currently, i downloaded
2.5.6 version of spring jdbc jar. Any compatibility issue?

Thanks
Shiv



--
View this message in context: http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750872.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Charles Moulliard <ch...@gmail.com>.
IF you read the message, it tells you that it will create the connection
(not that the connection has been created). So Spring logs the message
before to call
https://github.com/spring-projects/spring-framework/blob/master/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/SimpleDriverDataSource.java#L140

return driver.connect(url, props);

So the connection object could be null


On Mon, May 5, 2014 at 7:36 AM, Shiv <sh...@gmail.com> wrote:

> As per your suggestion, I changed the logging level of the package and got
> below line in log:
>
> 2014-05-05 10:53:46,007 | DEBUG | Creating new JDBC Driver Connection to
> [jdbc:microsoft:sqlserver://<host name>:1433;DatabaseName=TESTDB] |
> org.springframework.jdbc.datasource.SimpleDriverDataSource
>
> Does it also expect to log successful connection message if connection is
> created successfully?
>
> Thanks
> Shiv
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750852.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Shiv <sh...@gmail.com>.
As per your suggestion, I changed the logging level of the package and got
below line in log:

2014-05-05 10:53:46,007 | DEBUG | Creating new JDBC Driver Connection to
[jdbc:microsoft:sqlserver://<host name>:1433;DatabaseName=TESTDB] |
org.springframework.jdbc.datasource.SimpleDriverDataSource

Does it also expect to log successful connection message if connection is
created successfully?

Thanks
Shiv



--
View this message in context: http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750852.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Charles Moulliard <ch...@gmail.com>.
You could try to increase debug level for this package
org/springframework/jdbc/datasource/ to see if Spring reports this message
: "logger.debug("Creating new JDBC Driver Connection to [" + url + "]");"




On Fri, May 2, 2014 at 1:50 PM, Shiv <sh...@gmail.com> wrote:

> I am however able to connect to SQL Server DB using the given DB name, user
> name and password via SQL Server Management Studio client and can run
> select
> and insert queries directly.
>
> For SQL Server driver name, I used the reference from
>
> https://access.redhat.com/site/documentation/en-US/Fuse_ESB_Enterprise/7.1/html/EIP_Transaction_Guide/files/TxnManagers-Samples-JDBC.html
> site to get the value. It says driver name should be
> com.microsoft.jdbc.sqlserver.SQLServerDriver but sqljdbc4 jar does not
> contain this class and rather the class name is
> com.microsoft.sqlserver.jdbc.SQLServerDriver. That was one difference.
>
> If there are ways to get more debug information to fix this issue?
>
> Thanks
> Shiv
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750788.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Shiv <sh...@gmail.com>.
I am however able to connect to SQL Server DB using the given DB name, user
name and password via SQL Server Management Studio client and can run select
and insert queries directly.

For SQL Server driver name, I used the reference from
https://access.redhat.com/site/documentation/en-US/Fuse_ESB_Enterprise/7.1/html/EIP_Transaction_Guide/files/TxnManagers-Samples-JDBC.html
site to get the value. It says driver name should be
com.microsoft.jdbc.sqlserver.SQLServerDriver but sqljdbc4 jar does not
contain this class and rather the class name is
com.microsoft.sqlserver.jdbc.SQLServerDriver. That was one difference.

If there are ways to get more debug information to fix this issue?

Thanks
Shiv



--
View this message in context: http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783p5750788.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: java.lang.NullPointerException in Camel JDBC component for Select statement

Posted by Charles Moulliard <ch...@gmail.com>.
You get this error because the Connection object is null (
https://github.com/apache/camel/blob/camel-2.2.0/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java#L67).
So I suspect that a problem occurred during creation of the DataSource
object


On Fri, May 2, 2014 at 11:35 AM, Shiv <sh...@gmail.com> wrote:

> Hi all,
> I am using Camel JDBC component for first time and I need to query a table
> in MS SQL Server 2008 R2 and push the results to an ActiveMQ queue. I used
> the details on http://camel.apache.org/jdbc.html page and tried to get the
> setup. Once my route define in Spring configuration file is started, I am
> getting java.lang.NullPointerException  in log. I am using Camel 2.2.0 (it
> is pretty old but is part of a legacy system).  I have camel-jdbc-2.2.0,
> sqljdbc4 and org.springframework.jdbc-2.5.6 jars on classpath. any input
> will be great.
>
> Route detail:
> -----------------------------
> <from uri="timer://kickoff?period=1000"/>
>             <setBody><constant>select * from test</constant></setBody>
> <to uri="jdbc:testdb"/>
> <to uri="activemq:queue:testdb"/>
>
> Data Source:
> -----------------
> <bean id="testdb"
> class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
>         <property name="driverClass"
> value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
>         <property name=&quot;url&quot;
> value=&quot;jdbc:microsoft:sqlserver://&lt;host
> name>:1433;DatabaseName=test"/>
>         <property name="username" value="test"/>
>         <property name="password" value="test"/>
> </bean>
>
> Exception log:
> -------------------
> 2014-05-02 14:39:59,467 | INFO  | Exchange[
> , Id:6d87d9ba-85ef-4cf6-a9f7-a4b1be999f1b
> ,
>
> Properties:{CamelToEndpoint=log://toDLC?multiline=true&showAll=true&showCaughtException=true,
> CamelTimerFiredTime=Fri May 02 14:39:59 IST 2014,
> CamelFailureEndpoint=jdbc://testdb, CamelTimerPeriod=1000,
> CamelTimerName=kickoff,
> CamelExceptionCaught=java.lang.NullPointerException}
> , Headers:{firedTime=Fri May 02 14:39:59 IST 2014}
> , BodyType:String
> , Body:select * from test
> , CaughtExceptionType:java.lang.NullPointerException,
> CaughtExceptionMessage:null, StackTrace:java.lang.NullPointerException
>         at
> org.apache.camel.component.jdbc.JdbcProducer.process(JdbcProducer.java:67)
>         at
>
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97)
>         at
>
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:95)
>         at
> org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
>         at
> org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)
>         at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)
>         at
>
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>         at
>
> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>         at
>
> org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>         at
>
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93)
>         at
>
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
>         at
>
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>         at
>
> org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:177)
>         at
>
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:143)
>         at
>
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:88)
>         at
>
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:56)
>         at
> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
>         at
>
> org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:66)
>         at
>
> org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>         at
>
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>         at
>
> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:103)
>         at
> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:50)
>         at java.util.TimerThread.mainLoop(Timer.java:512)
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/java-lang-NullPointerException-in-Camel-JDBC-component-for-Select-statement-tp5750783.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io