configuration - MyBatis-Spring: SqlSessionFactoryBean initialization: connection timeout -
i migrating ibatis 2 mybatis 3 in spring 3.0 environment. when attempt deploy application, or run junit test, config initialization fails connection timeout error follows:
error creating bean name 'sqlsessionfactory' defined in class path resource [testcontext-jndi.xml]: invocation of init method failed; nested exception org.apache.ibatis.builder.builderexception: error creating document instance. cause: java.net.connectexception: connection timed out: connect
it looks missing http proxy, eclipse proxy settings have worked other code. dtd definitions appear correct.
i using spring 3.0.0, , have included following jars in classpath:
- mybatis-3.2.2.jar
- mybatis-spring-1.2.0.jar
the relevant spring configuration follows:
foocontext-data.xml - (this test/resources configuration. when deploying web container, spring-configured data source uses jndi lookup credentials. both fail same way.)
<?xml version="1.0" encoding="utf-8"?> <!doctype beans public "-//spring//dtd bean//en" "http://www.springframework.org/dtd/spring-beans.dtd"> <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> <!-- mybatis stuff --> <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>
sqlmapconfig.xml
<?xml version="1.0" encoding="utf-8"?> <!doctype configuration public "-//www.mybatis.org//dtd config 3.0//en" "http://www.mybatis.org/dtd/mybatis-3-config.dtd"> <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>
i noticed others having problem, , related being wrong dtd of mybatis xml, or having bad network connection, preventing them pulling down dtd definition. not see how have problem, these bases appear covered in scenario.
i've been @ problem day , half, having scourged documentation both mybatis, , mybatis-spring, bit of site , others. ideas appreciated.
i found answer problem on mybatis users site here: dtd verification when www.mybatis.org down
turns out dtd links not supposed have www in front of them. is, rather than:
<!doctype configuration public "-//www.mybatis.org//dtd config 3.0//en" "http://www.mybatis.org/dtd/mybatis-3-config.dtd">
they supposed read:
<!doctype configuration public "-//mybatis.org//dtd config 3.0//en" "http://mybatis.org/dtd/mybatis-3-config.dtd">
i changed these, , works.
Configuration - Mybatis-Spring: Sqlsessionfactorybean Initialization:
ReplyDeleteConnection Timeout - >>>>> Download Now
>>>>> Download Full
Configuration - Mybatis-Spring: Sqlsessionfactorybean Initialization:
Connection Timeout - >>>>> Download LINK
>>>>> Download Now
Configuration - Mybatis-Spring: Sqlsessionfactorybean Initialization:
Connection Timeout - >>>>> Download Full
>>>>> Download LINK Lc