[mule-user] Problem doing INSERTS to MSSQL in Mule 3.1

15 views
Skip to first unread message

Emmanuel Becerra

unread,
Jan 28, 2011, 5:40:29 PM1/28/11
to us...@mule.codehaus.org
Hi, I need to use MSSQL as my database engine but I am having problems when I try to insert 200 records in my database at once(sort of), somehow the pool of connections to my DB just appear to run out.

*Here is my configuration for the datasource(ms-sql.xml):*

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd">

<!-- Beans for the JBoss transaction manager -->
<spring:bean name="ArjunaFactory"
class="org.mule.module.jboss.transaction.JBossArjunaTransactionManagerFactory" />
<spring:bean name="DefaultConfiguration"
class="org.mule.config.DefaultMuleConfiguration" />
<spring:bean id="arjunaTM" factory-bean="ArjunaFactory"
factory-method="create">
<spring:constructor-arg ref="DefaultConfiguration" />
</spring:bean>

<!-- SQL SERVER 2008 Data Source -->
<spring:bean id="SQLServerjdbcDataSource"
class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
<spring:property name="transactionManager" ref="arjunaTM" />
<spring:property name="driverName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<spring:property name="url"
value="jdbc:sqlserver://MY_INSTANCE\SQLEXPRESS;password=user1;user=pass2" />
</spring:bean>

<spring:bean id="SQLServerjdbcDataSourceXA"
class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
<spring:property name="dataSource" ref="SQLServerjdbcDataSource" />
<spring:property name="maxSize" value="50" />
</spring:bean>
</mule>


*Here is a sample of my configuration file in mule:*
...
<spring:beans>
<spring:import resource="ms-sql.xml" />
</spring:beans>
...
<jdbc:connector name="MsSqljdbcConnector"
dataSource-ref="SQLServerjdbcDataSourceXA">

<jdbc:query key="insertData"
value="INSERT INTO my_table(val1,val2)
VALUES (
#[map-payload:VAL_1],
#[map-payload:VAL2])" />
</jdbc:connector>
...
<flow name="saveMyInfo">
<vm:inbound-endpoint path="myQueue.infoToStore" />
<collection-splitter enableCorrelation="IF_NOT_SET" />
<jdbc:outbound-endpoint queryKey="insertData"
connector-ref="MsSqljdbcConnector" transformer-refs="MyCustomObjectToMapTransformer">
</jdbc:outbound-endpoint>
</flow>


*Here is my test case that I am running:*
public void testInsertLotsOfInfo() throws Exception {
MuleClient mClient = new MuleClient(muleContext);
MuleMessage mInputMessage;
MuleMessage mOutputMessage;
List<MyCustomObject> infoList = getInfo(); //This list will get populated with 200 objects.

mInputMessage = new DefaultMuleMessage(mTrips, mClient.getMuleContext());

mClient.sendAsync("vm://myQueue.infoToStore", mInputMessage);

mOutputMessage = mClient.request("vm://nameOut", DEFAULT_TIMEOUT); //I do this or the test doesn't run, I don't really understand why....
}


The error I get says:

java.lang.NullPointerException
at org.enhydra.jdbc.pool.GenericPool.getFromPool(GenericPool.java:200)
at org.enhydra.jdbc.pool.GenericPool.checkOut(GenericPool.java:351)
at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:194)
at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)
at org.mule.transport.jdbc.JdbcConnector.getConnection(JdbcConnector.java:243)
at org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy.executeStatement(SimpleUpdateSqlStatementStrategy.java:61)
at org.mule.transport.jdbc.JdbcMessageDispatcher.doSend(JdbcMessageDispatcher.java:68)
at org.mule.transport.jdbc.JdbcMessageDispatcher.doDispatch(JdbcMessageDispatcher.java:54)
at org.mule.transport.AbstractMessageDispatcher.process(AbstractMessageDispatcher.java:93)
at org.mule.transport.AbstractConnector$DispatcherMessageProcessor.process(AbstractConnector.java:2452)
at org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingMessageProcessor.java:75)
at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)
at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:129)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:219)
at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:41)
at org.mule.work.WorkerContext.run(WorkerContext.java:309)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
at java.lang.Thread.run(Unknown Source)
java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.lang.NullPointerException
at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:204)
at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)
at org.mule.transport.jdbc.JdbcConnector.getConnection(JdbcConnector.java:243)
at org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy.executeStatement(SimpleUpdateSqlStatementStrategy.java:61)
at org.mule.transport.jdbc.JdbcMessageDispatcher.doSend(JdbcMessageDispatcher.java:68)
at org.mule.transport.jdbc.JdbcMessageDispatcher.doDispatch(JdbcMessageDispatcher.java:54)
at org.mule.transport.AbstractMessageDispatcher.process(AbstractMessageDispatcher.java:93)
at org.mule.transport.AbstractConnector$DispatcherMessageProcessor.process(AbstractConnector.java:2452)
at org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingMessageProcessor.java:75)
at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)
at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:129)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:219)
at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:41)
at org.mule.work.WorkerContext.run(WorkerContext.java:309)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
at java.lang.Thread.run(Unknown Source)
[01-28 16:34:34] ERROR DefaultServiceExceptionStrategy [MsSqljdbcConnector.dispatcher.13]:
********************************************************************************
Message : SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.lang.NullPointerException (java.sql.SQLException)
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. SQLException in StandardPoolDataSource:getConnection no connection available java.lang.NullPointerException(SQL Code: 0, SQL State: + null) (java.sql.SQLException)
org.enhydra.jdbc.pool.StandardPoolDataSource:204 (null)
2. SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.lang.NullPointerException(SQL Code: 0, SQL State: + null) (java.sql.SQLException)
org.enhydra.jdbc.pool.StandardPoolDataSource:213 (null)
3. SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.lang.NullPointerException (java.sql.SQLException) (org.mule.transport.ConnectException)
org.mule.transport.jdbc.JdbcConnector:247 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/ConnectException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.lang.NullPointerException
at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:204)
at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)
at org.mule.transport.jdbc.JdbcConnector.getConnection(JdbcConnector.java:243)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

I get many more errors exactly like these, and only about 85 - 100 records get inserted into my database out of the 200 that I need.

Could anyone please let me know what I'm doing wrong? Is the problem in my configurations? In SQL Server?

Thanks!

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Emmanuel Becerra

unread,
Mar 8, 2011, 9:47:40 AM3/8/11
to us...@mule.codehaus.org
Hi, I'm still struggling with this issue, has anyone encountered a problem like this before?
Reply all
Reply to author
Forward
0 new messages