You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2015/03/27 18:08:59 UTC

Re: MyBatis Camel Route Config - ### Error opening session. Cause: java.lang.NullPointerException

Hi

Do you have a stacktarce of the NPE?

On Fri, Mar 27, 2015 at 5:35 PM, Wilkerson, Daniel
<dw...@fullsail.com> wrote:
> Hi everyone. I'm working on a small prototype using Camel, Bindy, and MyBatis. I'm currently doing this as a standalone Camel app. I'm not currently using Spring or Blueprint, just Java DSL. I'm trying to keep this a simple as possible for the time being. We are looking at this strategy to port an existing MyBatis based integration solution to Camel and MyBatis.
>
> My code and Camel are able to bring in CSV files via the sFTP endpoint, process (bind) the files to a list of Bean, and I'm trying to route it directly to a camel-mybatis endpoint. Everything seems to be working fine until it tries to create the SqlSession. I get the error: ### Error opening session.  Cause: java.lang.NullPointerException
>
> I have distilled our previous mybatis-config.xml down to one single <environment></environment> for testing. I've read the MyBatis component page on the Camel site and see that for a Spring based config, the session has to be externalized outside of the SqlMapConfig.xml.  I'm doing my development in Eclipse using a Maven project. The Maven runtime I'm using inside of Eclipse is 3.0.4
>
> Is this the same for a DSL implementation not using Spring? How do I get Camel to crank up a SqlSession? Also, once I get it to connect, how do I switch between different connections configured in between <environment></environment> tags?
>
> My DSL route that's inside my RouteBuilder subclass is:
>
>   DataFormat bindy = new BindyCsvDataFormat("com.some.package.path.domain");
>
>             from ("sftp:user@somedomain:4444/?password=********&binary=false&download=true&fileName=data.csv&consumer.delay=" + delay)
>             .log("<<<<Before Unmarshall>>>>").unmarshal(bindy).log(LoggingLevel.INFO, "BODY OUTPUT: ${body}")
>             .to("mybatis:insert?statementType=Insert&executorType=batch");
>
>
> I think once I get the SqlSession to work the above route will work great. Thanks in advance for any help!
>
> Daniel



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: MyBatis Camel Route Config - ### Error opening session. Cause: java.lang.NullPointerException

Posted by "Wilkerson, Daniel" <dw...@fullsail.com>.
Hi Claus. Thank you for responding. I appreciate it very much. I have
pasted the stack trace below.

Here's what I see in the Eclipse console:


Exchange[
Id ID-macc02m6b0yfd57-workdomain-com-56687-1427475721397-0-2
angePattern InOnly
Headers 
{breadcrumbId=ID-macc02m6b0yfd57-workplace-com-56687-1427475721397-0-1,
CamelFileAbsolute=false, CamelFileAbsolutePath=Data.csv,
CamelFileHost=somehost, CamelFileLastModified=1427444104000,
CamelFileLength=1761, CamelFileName=Data.csv,
CamelFileNameConsumed=Data.csv, CamelFileNameOnly=Data.csv,
CamelFileParent=/, CamelFilePath=/Data.csv,
CamelFileRelativePath=Data.csv, CamelRedelivered=false,
CamelRedeliveryCounter=0}
BodyType java.util.ArrayList
Body 
[{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data
.domain.Data@1ef51a57},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@6d9455a1},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@2581f53b},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@770b07b9},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@75283fbd},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@2570cd62},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@10bbf022},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@229250c3},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@33f443f0},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@69985c35},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@11cdd1bc},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@5f8496c5},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@79c69080},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@5b3901f5},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@7bafaa9c},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@3181aa5d},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@37d7d90f},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@3beb846d},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@63432ed6},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@4fb81683},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@3ece1b58},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@4d654e9e},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@360c8ec4},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@72710194},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@591ed63e},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@7783ae27},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@661ebfbd},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@6cbe45ab},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@3fd01553},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@76281cdf},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@437fb113},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@74427903},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@3816ef96},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@69cb7d9e},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@2ea44655},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@23058e5f},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@41c610ef},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@3281dca5},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@6bbcee8a},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@40d0dd48},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@506fc336},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@5979377b},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@25299a21},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@4e45ff96},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@558ef8ff},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@1d7d593b},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@106d3f9d},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@746b64d7},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@36a99af7},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@38fcea2a},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@647188a0},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@59c0f3e4},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@acc2bc5},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@624d980c},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@54396e3f},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@675154c},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@70c933e3},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@296db5ee},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@61c33181},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@55e73e4b},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@40aad9fc},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@10cd508f},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@1763e4e7},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@1f4905b0},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@731475db},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@4445b7e3},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@3d2bbb19},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@20885af},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@7d80a533},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@8ddf7a4},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@24ad3488},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@6753df87},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@33784d10},
{com.workplace.staging.lms.data.domain.Data=com.workplace.staging.lms.data.
domain.Data@1f0b6fd6}]
]

Stacktrace
---------------------------------------------------------------------------
------------------------------------------------------------
org.apache.ibatis.exceptions.PersistenceException:
### Error opening session. Cause: java.lang.NullPointerException
### Cause: java.lang.NullPointerException
at 
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactor
y.java:26)
at 
org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFrom
DataSource(DefaultSqlSessionFactory.java:91)
at 
org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(Def
aultSqlSessionFactory.java:54)
at 
org.apache.camel.component.mybatis.MyBatisProducer.process(MyBatisProducer.
java:54)
at 
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcess
orBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:129)
at 
org.apache.camel.management.InstrumentationProcessor.process(Instrumentatio
nProcessor.java:77)
at 
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHa
ndler.java:448)
at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProc
essor.java:191)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at 
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.jav
a:109)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:60)
at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProc
essor.java:166)
at 
org.apache.camel.component.file.GenericFileConsumer.processExchange(Generic
FileConsumer.java:433)
at 
org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(R
emoteFileConsumer.java:101)
at 
org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFil
eConsumer.java:211)
at 
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsume
r.java:175)
at 
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.jav
a:174)
at 
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:
101)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access
$301(ScheduledThreadPoolExecutor.java:178)
at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Sc
heduledThreadPoolExecutor.java:293)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1
145)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:
615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at 
org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFrom
DataSource(DefaultSqlSessionFactory.java:86)
... 25 more
[- sftp://user@somedomain:4444/] Pipeline DEBUG Message exchange has
failed: so breaking out of pipeline for exchange: Exchange[Data.csv]
Exception: org.apache.ibatis.exceptions.PersistenceException:
### Error opening session. Cause: java.lang.NullPointerException
### Cause: java.lang.NullPointerException
[- sftp://user@somedomain:4444/] GenericFileOnCompletion DEBUG Done
processing file: RemoteFile[Data.csv] using exchange: Exchange[Data.csv]
[- sftp://user@somedomain:4444/] GenericFileOnCompletion WARN Rollback
file strategy: 
org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrategy@1d6
c530a for file: RemoteFile[Data.csv]






On 3/27/15 1:08 PM, "Claus Ibsen" <cl...@gmail.com> wrote:

>Hi
>
>Do you have a stacktarce of the NPE?
>
>On Fri, Mar 27, 2015 at 5:35 PM, Wilkerson, Daniel
><dw...@fullsail.com> wrote:
>> Hi everyone. I'm working on a small prototype using Camel, Bindy, and
>>MyBatis. I'm currently doing this as a standalone Camel app. I'm not
>>currently using Spring or Blueprint, just Java DSL. I'm trying to keep
>>this a simple as possible for the time being. We are looking at this
>>strategy to port an existing MyBatis based integration solution to Camel
>>and MyBatis.
>>
>> My code and Camel are able to bring in CSV files via the sFTP endpoint,
>>process (bind) the files to a list of Bean, and I'm trying to route it
>>directly to a camel-mybatis endpoint. Everything seems to be working
>>fine until it tries to create the SqlSession. I get the error: ### Error
>>opening session.  Cause: java.lang.NullPointerException
>>
>> I have distilled our previous mybatis-config.xml down to one single
>><environment></environment> for testing. I've read the MyBatis component
>>page on the Camel site and see that for a Spring based config, the
>>session has to be externalized outside of the SqlMapConfig.xml.  I'm
>>doing my development in Eclipse using a Maven project. The Maven runtime
>>I'm using inside of Eclipse is 3.0.4
>>
>> Is this the same for a DSL implementation not using Spring? How do I
>>get Camel to crank up a SqlSession? Also, once I get it to connect, how
>>do I switch between different connections configured in between
>><environment></environment> tags?
>>
>> My DSL route that's inside my RouteBuilder subclass is:
>>
>>   DataFormat bindy = new
>>BindyCsvDataFormat("com.some.package.path.domain");
>>
>>             from
>>("sftp:user@somedomain:4444/?password=********&binary=false&download=true
>>&fileName=data.csv&consumer.delay=" + delay)
>>             .log("<<<<Before
>>Unmarshall>>>>").unmarshal(bindy).log(LoggingLevel.INFO, "BODY OUTPUT:
>>${body}")
>>             
>>.to("mybatis:insert?statementType=Insert&executorType=batch");
>>
>>
>> I think once I get the SqlSession to work the above route will work
>>great. Thanks in advance for any help!
>>
>> Daniel
>
>
>
>-- 
>Claus Ibsen
>-----------------
>Red Hat, Inc.
>Email: cibsen@redhat.com
>Twitter: davsclaus
>Blog: http://davsclaus.com
>Author of Camel in Action: http://www.manning.com/ibsen
>hawtio: http://hawt.io/
>fabric8: http://fabric8.io/


Re: MyBatis Camel Route Config - ### Error opening session. Cause: java.lang.NullPointerException

Posted by "Wilkerson, Daniel" <dw...@fullsail.com>.
Hi Everyone. I solved the issue. It was a case of tired eyes: naming issue
in SqlMapConfig <environment> tag. Thank you for taking a look Claus. I
appreciate it.



On 3/27/15 1:08 PM, "Claus Ibsen" <cl...@gmail.com> wrote:

>Hi
>
>Do you have a stacktarce of the NPE?
>
>On Fri, Mar 27, 2015 at 5:35 PM, Wilkerson, Daniel
><dw...@fullsail.com> wrote:
>> Hi everyone. I'm working on a small prototype using Camel, Bindy, and
>>MyBatis. I'm currently doing this as a standalone Camel app. I'm not
>>currently using Spring or Blueprint, just Java DSL. I'm trying to keep
>>this a simple as possible for the time being. We are looking at this
>>strategy to port an existing MyBatis based integration solution to Camel
>>and MyBatis.
>>
>> My code and Camel are able to bring in CSV files via the sFTP endpoint,
>>process (bind) the files to a list of Bean, and I'm trying to route it
>>directly to a camel-mybatis endpoint. Everything seems to be working
>>fine until it tries to create the SqlSession. I get the error: ### Error
>>opening session.  Cause: java.lang.NullPointerException
>>
>> I have distilled our previous mybatis-config.xml down to one single
>><environment></environment> for testing. I've read the MyBatis component
>>page on the Camel site and see that for a Spring based config, the
>>session has to be externalized outside of the SqlMapConfig.xml.  I'm
>>doing my development in Eclipse using a Maven project. The Maven runtime
>>I'm using inside of Eclipse is 3.0.4
>>
>> Is this the same for a DSL implementation not using Spring? How do I
>>get Camel to crank up a SqlSession? Also, once I get it to connect, how
>>do I switch between different connections configured in between
>><environment></environment> tags?
>>
>> My DSL route that's inside my RouteBuilder subclass is:
>>
>>   DataFormat bindy = new
>>BindyCsvDataFormat("com.some.package.path.domain");
>>
>>             from
>>("sftp:user@somedomain:4444/?password=********&binary=false&download=true
>>&fileName=data.csv&consumer.delay=" + delay)
>>             .log("<<<<Before
>>Unmarshall>>>>").unmarshal(bindy).log(LoggingLevel.INFO, "BODY OUTPUT:
>>${body}")
>>             
>>.to("mybatis:insert?statementType=Insert&executorType=batch");
>>
>>
>> I think once I get the SqlSession to work the above route will work
>>great. Thanks in advance for any help!
>>
>> Daniel
>
>
>
>-- 
>Claus Ibsen
>-----------------
>Red Hat, Inc.
>Email: cibsen@redhat.com
>Twitter: davsclaus
>Blog: http://davsclaus.com
>Author of Camel in Action: http://www.manning.com/ibsen
>hawtio: http://hawt.io/
>fabric8: http://fabric8.io/