Re: Connection time out error

596 views
Skip to first unread message

Jose María Zaragoza

unread,
May 5, 2013, 4:06:26 PM5/5/13
to mybati...@googlegroups.com

Hi:

Maybe it would be fine if we can see applicationContext.xml, because the error is about this file

Regards


2013/5/3 Kavan Desai <kavan...@gmail.com>
Hi,
I am getting following exception while trying to connect to Netezza database using spring-mybatis.

Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderVersionMapper' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'netezzaSqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'netezzaSqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: java.net.ConnectException: Connection timed out: connect

I have checked the credentials they are fine.

Here are my two configuration file

-----------------------------------------------------------------------------

My batis config 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
        PUBLIC "-//www.mybatis.org//DTD Config 3.0//EN"
<configuration>
  

<typeAliases>  
<typeAlias type="com.barcap.rave.model.OrderVersion" alias="orderVersion"></typeAlias>  
</typeAliases> 

    <settings>
        <setting name="cacheEnabled" value="true"/>
        <setting name="safeResultHandlerEnabled" value="false"/>
        <setting name="defaultExecutorType" value="REUSE"/>
        <setting name="autoMappingBehavior" value="PARTIAL"/>
    </settings>
        
 
<mappers>
        <mapper resource="com/barcap/rave/mapper/OrderVersionMapper.xml"/>
    </mappers>
</configuration>

-----------------------------------------------------------------------------------------------------------------------------

Mapper file 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.barcap.rave.mapper.OrderVersionMapper">
<select id="getOrderVersionsByComplianceId" parameterType="string"
resultType="orderVersion">
SELECT
ORDERID,
OUTCLORDID,
ORDERVERSION,
PARENTCHILDTYPE
ACCOUNT,
ACCOUNTTYPEIND,
BLOCKORDERID,
CLIENTMASTERACCOUNTID,
CONTRABROKER,
CROSSID,
CROSSTYPE,
CUMQTY,
CUSTOMERACCOUNT,
EXECVERSION,
EXDESTINATION,
EXCHCLORDID,
EXCHEXECID,
EXCHORDID,
EXCHORIGCLORDID,
EXCHORIGORDID,
EXCHPARTICIPANTID,
EXCHSENDERCOMPID,
DESKID
FROM RAVE_VIEW
WHERE COMPLIANCEID = #{complianceId}  
   </select>

<!-- Instead of referencing Fully Qualified Class Names we can register 
Aliases in mybatis-config.xml and use Alias names. -->
<resultMap type="orderVersion" id="orderVersion">
<id property="account" column="ACCOUNT" />
<result property="orderId" column="ORDERID" />
<result property="outclordId" column="OUTCLORDID"/>
<result property="orderVersion" column="ORDERVERSION" />
<result property="parentChildType" column="PARENTCHILDTYPE" />
<result property="accountTypeInd" column="ACCOUNTTYPEIND" />
<result property="blockOrderId" column="BLOCKORDERID" />
<result property="clientMasterAccountId" column="CLIENTMASTERACCOUNTID" />
<result property="contrabroker" column="CONTRABROKER" />
<result property="crossId" column="CROSSID" />
<result property="crossType" column="CROSSTYPE" />
<result property="cumQty" column="CUMQTY" />
<result property="customerAccount" column="CUSTOMERACCOUNT" />
<result property="execversion" column="EXECVERSION"/>
<result property="exdestination" column="EXDESTINATION" />
<result property="exchclordId" column="EXCHCLORDID" />
<result property="exchexecId" column="EXCHEXECID" />
<result property="exchordid" column="EXCHORDID" />
<result property="exchorigclordId" column="EXCHORIGCLORDID" />
<result property="exchorigorid" column="EXCHORIGORDID" />
<result property="exchparticipantId" column="EXCHPARTICIPANTID" />
<result property="exchsendercompId" column="EXCHSENDERCOMPID" />
<result property="deskId" column="DESKID" />
</resultMap>
</mapper> 

I am stuck at this point since long any help would be great.


--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ross

unread,
Aug 12, 2013, 4:01:18 PM8/12/13
to mybati...@googlegroups.com
Hello Jose,

I had this same problem, and after 2 days of hair pulling, I found the
answer over here
<http://mybatis-user.963551.n3.nabble.com/How-to-skip-DTD-verification-when-www-mybatis-org-is-down-td4026165.html>
.

In short, your DTD declaration has a www. in front of it, and it should not.
(It should just say "http://mybatis.org/dtd/mybatis-3-config.dtd".

-Ross


Jose María Zaragoza wrote
>> -----------------------------------------------------------------------------
>>
>> My batis config
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> &lt;!DOCTYPE configuration
> &gt; PUBLIC "-//www.mybatis.org//DTD Config 3.0//EN"
>> "http://www.mybatis.org/dtd/mybatis-3-config.dtd">
>>
> <configuration>
>>
>>
>>
> <typeAliases>
>>
> <typeAlias type="com.barcap.rave.model.OrderVersion"
>>
> alias="orderVersion">
> </typeAlias>
>>
> </typeAliases>
>>
>>
> <settings>
>>
> <setting name="cacheEnabled" value="true"/>
>>
> <setting name="safeResultHandlerEnabled" value="false"/>
>>
> <setting name="defaultExecutorType" value="REUSE"/>
>>
> <setting name="autoMappingBehavior" value="PARTIAL"/>
>>
> </settings>
>>
>>
>>
> <mappers>
>>
> <mapper resource="com/barcap/rave/mapper/OrderVersionMapper.xml"/>
>>
> </mappers>
>>
> </configuration>
>>
>>
>>





--
View this message in context: http://mybatis-user.963551.n3.nabble.com/Connection-time-out-error-tp4026924p4027256.html
Sent from the mybatis-user mailing list archive at Nabble.com.

Ross

unread,
Aug 12, 2013, 12:15:27 PM8/12/13
to mybati...@googlegroups.com
I have having this exact same issue. I am using Spring 3.0.0 and the
following mybatis jars are in my classpath:

mybatis-3.2.2.jar
mybatis-spring-1.2.0.jar
-----------------------------------------------------------------------------------------------------
The same error occurs whether I am running a JUnit test or deploying the
application to a web container:

Error creating bean with name 'sqlSessionFactory' defined in class path
resource [testContext-jndi.xml]: Invocation of init method failed; nested
exception is org.apache.ibatis.builder.BuilderException: Error creating
document instance. Cause: java.net.ConnectException: Connection timed out:
connect
-----------------------------------------------------------------------------------------------------
I know the database credentials are good. They have not changed in years.
They work with iBatis 2. When deploying to web container, the data source
uses a JNDI lookup to gather the credentials from the server. In the unit
test environment they're in the Spring file itself. This is the relevant
part of my test/resources configuration:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot;
&quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;>

<beans>

<bean id="dataSourceFoo" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close" >
<property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@(DESCRIPTION =
(LOAD_BALANCE=on)(FAILOVER=on)(ADDRESS=(PROTOCOL=tcp)(HOST=foo1)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=foo2)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=foo.bar.boz)))"/>
<property name="username" value="fooUser"/>
<property name="password" value="fooPass"/>
</bean>


<bean id="sqlSessionFactory"
class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSourceFoo" />
<property name="configLocation" value="sqlMapConfig.xml" />
</bean>

<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>


</beans>
-----------------------------------------------------------------------------------------------------
Here is my sqlMap config:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC &quot;-//www.mybatis.org//DTD Config 3.0//EN&quot;
&quot;http://www.mybatis.org/dtd/mybatis-3-config.dtd&quot;>

<configuration>

<properties resource="ibatis.properties" />

<mappers>
<mapper resource="foo/dao/maps/mybatis/SqlMap1.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap2.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap3.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap4.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap5.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap6.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap7.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap8.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap9.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap10.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap11.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap12.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap13.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap14.xml"/>
<mapper resource="foo/dao/maps/mybatis/SqlMap15.xml"/>
</mappers>

</configuration>

----------------------------------------------------------------------------------------------------

All of the DAO and sqlMap wiring seems to be happening without a problem.

I noticed that some others were having this problem, and it was related to
something being wrong with the DTD of the myBatis xml, or having a bad
network connection, preventing them from pulling down the DTD definition. I
do not have this problem, and have removed ALL of my old iBatis 2 jars,
files, classes, etc. to make sure there is not a strange conflict between
the two versions.

Is there a compatibility problem with MyBatis 3.2.2, and Spring 3.0.0? I've
been at this problem for a day and a half, having scourged the documentation
for both MyBatis, and MyBatis-Spring, as well as a good bit of this site and
others. Any ideas would be appreciated.



--
View this message in context: http://mybatis-user.963551.n3.nabble.com/Connection-time-out-error-tp4026924p4027255.html
Reply all
Reply to author
Forward
0 new messages