|
Hi people,
I'm getting an error on Mybatis Migrations when I have a properties file like this: database=mydb All migrations commands seem not to support property evaluation in my properties file. Is this supposed to work that way?
|
|
Some solution for this issue?
On Wed, Jun 15, 2011 at 6:27 PM, Rafael Ponte <[hidden email]> wrote: Hi people, Rafael Ponte http://www.triadworks.com.br |
|
This was a known issue in mybatis-spring 1.0 and it was supposed to be fixed in the 1.1 release but I just ran into the issue myself.
I'm trying to track down the bug to find out what happened. I will post when I find out. Basically, Spring 3.1 changed the way the XML files were parsed and the MapperScannerConfigurers were getting constructed before the data sources were configured with their properties. This was the reason for the addition of the setXXXBeanName methods in the MapperScannerConfigurer and the deprecation of the setSqlSession[Factory|Template] methods. HTH, --adam |
|
In reply to this post by Rafael Ponte
Here it is: http://code.google.com/p/mybatis/issues/detail?id=414
Not sure how this was supposed to be fixed however, because it's not working for me - could be my bean names are not right. --adam
On Thursday, January 5, 2012 6:39:01 AM UTC-7, Rafael Ponte wrote: Some solution for this issue? |
|
Adam, could you please post your config and the error?
El día 14 de marzo de 2012 18:27, Adam Gordon <[hidden email]> escribió: > Here it is: http://code.google.com/p/mybatis/issues/detail?id=414 > > Not sure how this was supposed to be fixed however, because it's not working > for me - could be my bean names are not right. > > --adam > > On Thursday, January 5, 2012 6:39:01 AM UTC-7, Rafael Ponte wrote: >> >> Some solution for this issue? >> >> On Wed, Jun 15, 2011 at 6:27 PM, Rafael Ponte <> wrote: >>> >>> Hi people, >>> >>> I'm getting an error on Mybatis Migrations when I have a properties file >>> like this: >>>> >>>> database=mydb >>>> url=jdbc:jtds:sqlserver://localhost:1433/${database} >>> >>> >>> All migrations commands seem not to support property evaluation in my >>> properties file. Is this supposed to work that way? >>> >>> -- >>> Rafael Ponte >>> http://www.rponte.com.br >> >> >> >> >> -- >> Rafael Ponte >> http://www.triadworks.com.br |
|
Sure. The error is that it cannot resolve the port number. Here's the relevant stuff - note that I have multiple datasources but they are configured similarly. I would have loved to see an example of both the SqlSessionFactoryBean config AND the MapperScannerConfigurer, but all I could find was this: http://www.mybatis.org/spring/apidocs/reference/org/mybatis/spring/mapper/MapperScannerConfigurer.html. Here's the relevant code/config:
Error org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Invalid number format for port number ### The error may exist in com/twc/mystro/mbo/mboui/bms/persistence/bm/ProviderMapper.xml ### The error may involve com.twc.mystro.mbo.mboui.bms.persistence.bm.ProviderMapper.getProviderList ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Invalid number format for port number MapperScanner config <bean id="bmsMapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.foo.bms.persistence"/> <property name="sqlSessionFactoryBeanName" value="bmsSqlSessionFactory"/> <property name="annotationClass" value="com.foo.bms.persistence.BmsDatabase"/> </bean> SqlSessionFactory config <bean id="bmsSqlSessionFactory" name="bmsSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="bmsDataSource"/> <property name="configLocation" value="classpath:mybatis-config.xml"/> <property name="typeAliasesPackage" value="com.foo.bms.model, com.foo.alert.model"/> </bean> Database config <context:property-placeholder location="classpath:com/foo/bms/persistence/jdbc.properties"/> <!-- the bms database data source --> <bean id="bmsDataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close"> <property name="URL" value="jdbc:oracle:thin:@//${bmsdb.host}:${jdbc.port}/${bmsdb.dbName}"/> <property name="user" value="${bmsdb.username}"/> <property name="password" value="${bmsdb.password}"/> <property name="connectionCachingEnabled" value="true"/> <property name="connectionCacheProperties"> <props merge="default"> <prop key="MinLimit">1</prop> <prop key="MaxLimit">10</prop> <prop key="ConnectionWaitTimeout">30</prop> </props> </property> </bean> Thanks, --adam On Wednesday, March 14, 2012 11:30:26 AM UTC-6, Eduardo wrote: Adam, could you please post your config and the error? |
|
Sorry, I am a bit lost with the new google groups interface.
The problem that Rafael pointed has nothing to do with mybatis spring and mapperscannerconfigurer. It is a migrations problem (I do not know if that was solved, I do not use migrations) In your case. Are you using more than one datasource? If you are not then remove the line: <property name="sqlSessionFactoryBeanName" > value="bmsSqlSessionFactory"/> On 14 mar, 19:14, Adam Gordon <[hidden email]> wrote: > Sure. The error is that it cannot resolve the port number. Here's the > relevant stuff - note that I have multiple datasources but they are > configured similarly. I would have loved to see an example of both the > SqlSessionFactoryBean config AND the MapperScannerConfigurer, but all I > could find was this: http://www.mybatis.org/spring/apidocs/reference/org/mybatis/spring/ma.... > Here's the relevant code/config: > > *Error* > org.mybatis.spring.MyBatisSystemException: nested exception is > org.apache.ibatis.exceptions.PersistenceException: > ### Error querying database. Cause: > org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get > JDBC Connection; nested exception is java.sql.SQLException: Invalid number > format for port number > ### The error may exist in > com/twc/mystro/mbo/mboui/bms/persistence/bm/ProviderMapper.xml > ### The error may involve > com.twc.mystro.mbo.mboui.bms.persistence.bm.ProviderMapper.getProviderList > ### The error occurred while executing a query > ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could > not get JDBC Connection; nested exception is java.sql.SQLException: Invalid > number format for port number > > *MapperScanner config* > <bean id="bmsMapperScannerConfigurer" > class="org.mybatis.spring.mapper.MapperScannerConfigurer"> > <property name="basePackage" value="com.foo.bms.persistence"/> > <property name="sqlSessionFactoryBeanName" > value="bmsSqlSessionFactory"/> > <property name="annotationClass" > value="com.foo.bms.persistence.BmsDatabase"/> > </bean> > > *SqlSessionFactory config* > <bean id="bmsSqlSessionFactory" name="bmsSqlSessionFactory" > class="org.mybatis.spring.SqlSessionFactoryBean"> > <property name="dataSource" ref="bmsDataSource"/> > <property name="configLocation" value="classpath:mybatis-config.xml"/> > <property name="typeAliasesPackage" value="com.foo.bms.model, > com.foo.alert.model"/> > </bean> > > *Database config* > <context:property-placeholder > location="classpath:com/foo/bms/persistence/jdbc.properties"/> > > <!-- the bms database data source --> > <bean id="bmsDataSource" class="oracle.jdbc.pool.OracleDataSource" > destroy-method="close"> > <property name="URL" > value="jdbc:oracle:thin:@//${bmsdb.host}:${jdbc.port}/${bmsdb.dbName}"/> > <property name="user" value="${bmsdb.username}"/> > <property name="password" value="${bmsdb.password}"/> > <property name="connectionCachingEnabled" value="true"/> > <property name="connectionCacheProperties"> > <props merge="default"> > <prop key="MinLimit">1</prop> > <prop key="MaxLimit">10</prop> > <prop key="ConnectionWaitTimeout">30</prop> > </props> > </property> > </bean> > > Thanks, > > --adam > > > > > > > > On Wednesday, March 14, 2012 11:30:26 AM UTC-6, Eduardo wrote: > > > Adam, could you please post your config and the error? > > > El día 14 de marzo de 2012 18:27, Adam Gordon escribió: > > > Here it is: http://code.google.com/p/mybatis/issues/detail?id=414 > > > > Not sure how this was supposed to be fixed however, because it's not > > working > > > for me - could be my bean names are not right. > > > > --adam > > > > On Thursday, January 5, 2012 6:39:01 AM UTC-7, Rafael Ponte wrote: > > > >> Some solution for this issue? > > > >> On Wed, Jun 15, 2011 at 6:27 PM, Rafael Ponte <> wrote: > > > >>> Hi people, > > > >>> I'm getting an error on Mybatis Migrations when I have a properties > > file > > >>> like this: > > > >>>> database=mydb > > >>>> url=jdbc:jtds:sqlserver://localhost:1433/${database} > > > >>> All migrations commands seem not to support property evaluation in my > > >>> properties file. Is this supposed to work that way? > > > >>> -- > > >>> Rafael Ponte > > >>>http://www.rponte.com.br > > > >> -- > > >> Rafael Ponte > > >>http://www.triadworks.com.br |
|
No worries, it's a bit much, IMO.
I am using two datasources, but everything is independent: the data source definitions (obviously), the transaction managers, sql session factories, and the mapper scanner configurers. If I switch back to the util:properties method of loading properties files, it works - and I am using the sqlSessionFactoryBeanName property. I am using Spring 3.1.1-RELEASE, MyBatis 3.1.0, and mybatis-spring 1.1.0. --adam
On Wednesday, March 14, 2012 12:39:54 PM UTC-6, Eduardo wrote: Sorry, I am a bit lost with the new google groups interface. |
|
Your config looks right and the beanname thing works for me!
If that gets annoying enough please isolate it in a test and fill and issue so we can have a look to see whats going on. El día 14 de marzo de 2012 19:49, Adam Gordon <[hidden email]> escribió: > No worries, it's a bit much, IMO. > > I am using two datasources, but everything is independent: the data source > definitions (obviously), the transaction managers, sql session factories, > and the mapper scanner configurers. > > If I switch back to the util:properties method of loading properties files, > it works - and I am using the sqlSessionFactoryBeanName property. > > I am using Spring 3.1.1-RELEASE, MyBatis 3.1.0, and mybatis-spring 1.1.0. > > --adam > > > On Wednesday, March 14, 2012 12:39:54 PM UTC-6, Eduardo wrote: >> >> Sorry, I am a bit lost with the new google groups interface. >> >> The problem that Rafael pointed has nothing to do with mybatis spring >> and mapperscannerconfigurer. It is a migrations problem (I do not know >> if that was solved, I do not use migrations) >> >> In your case. Are you using more than one datasource? If you are not >> then remove the line: >> >> <property name="sqlSessionFactoryBeanName" >> > value="bmsSqlSessionFactory"/> >> >> On 14 mar, 19:14, Adam Gordon <[hidden email]> wrote: >> > Sure. The error is that it cannot resolve the port number. Here's the >> > relevant stuff - note that I have multiple datasources but they are >> > configured similarly. I would have loved to see an example of both the >> > SqlSessionFactoryBean config AND the MapperScannerConfigurer, but all I >> > could find was this: >> > http://www.mybatis.org/spring/apidocs/reference/org/mybatis/spring/ma.... >> > Here's the relevant code/config: >> > >> > *Error* >> > org.mybatis.spring.MyBatisSystemException: nested exception is >> > org.apache.ibatis.exceptions.PersistenceException: >> > ### Error querying database. Cause: >> > org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get >> > JDBC Connection; nested exception is java.sql.SQLException: Invalid >> > number >> > format for port number >> > ### The error may exist in >> > com/twc/mystro/mbo/mboui/bms/persistence/bm/ProviderMapper.xml >> > ### The error may involve >> > >> > com.twc.mystro.mbo.mboui.bms.persistence.bm.ProviderMapper.getProviderList >> > ### The error occurred while executing a query >> > ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: >> > Could >> > not get JDBC Connection; nested exception is java.sql.SQLException: >> > Invalid >> > number format for port number >> > >> > *MapperScanner config* >> > <bean id="bmsMapperScannerConfigurer" >> > class="org.mybatis.spring.mapper.MapperScannerConfigurer"> >> > <property name="basePackage" value="com.foo.bms.persistence"/> >> > <property name="sqlSessionFactoryBeanName" >> > value="bmsSqlSessionFactory"/> >> > <property name="annotationClass" >> > value="com.foo.bms.persistence.BmsDatabase"/> >> > </bean> >> > >> > *SqlSessionFactory config* >> > <bean id="bmsSqlSessionFactory" name="bmsSqlSessionFactory" >> > class="org.mybatis.spring.SqlSessionFactoryBean"> >> > <property name="dataSource" ref="bmsDataSource"/> >> > <property name="configLocation" >> > value="classpath:mybatis-config.xml"/> >> > <property name="typeAliasesPackage" value="com.foo.bms.model, >> > com.foo.alert.model"/> >> > </bean> >> > >> > *Database config* >> > <context:property-placeholder >> > location="classpath:com/foo/bms/persistence/jdbc.properties"/> >> > >> > <!-- the bms database data source --> >> > <bean id="bmsDataSource" class="oracle.jdbc.pool.OracleDataSource" >> > destroy-method="close"> >> > <property name="URL" >> > value="jdbc:oracle:thin:@//${bmsdb.host}:${jdbc.port}/${bmsdb.dbName}"/> >> > <property name="user" value="${bmsdb.username}"/> >> > <property name="password" value="${bmsdb.password}"/> >> > <property name="connectionCachingEnabled" value="true"/> >> > <property name="connectionCacheProperties"> >> > <props merge="default"> >> > <prop key="MinLimit">1</prop> >> > <prop key="MaxLimit">10</prop> >> > <prop key="ConnectionWaitTimeout">30</prop> >> > </props> >> > </property> >> > </bean> >> > >> > Thanks, >> > >> > --adam >> > >> > >> > >> > >> > >> > >> > >> > On Wednesday, March 14, 2012 11:30:26 AM UTC-6, Eduardo wrote: >> > >> > > Adam, could you please post your config and the error? >> > >> > > El día 14 de marzo de 2012 18:27, Adam Gordon escribió: >> > > > Here it is: http://code.google.com/p/mybatis/issues/detail?id=414 >> > >> > > > Not sure how this was supposed to be fixed however, because it's not >> > > working >> > > > for me - could be my bean names are not right. >> > >> > > > --adam >> > >> > > > On Thursday, January 5, 2012 6:39:01 AM UTC-7, Rafael Ponte wrote: >> > >> > > >> Some solution for this issue? >> > >> > > >> On Wed, Jun 15, 2011 at 6:27 PM, Rafael Ponte <> wrote: >> > >> > > >>> Hi people, >> > >> > > >>> I'm getting an error on Mybatis Migrations when I have a >> > > >>> properties >> > > file >> > > >>> like this: >> > >> > > >>>> database=mydb >> > > >>>> url=jdbc:jtds:sqlserver://localhost:1433/${database} >> > >> > > >>> All migrations commands seem not to support property evaluation in >> > > >>> my >> > > >>> properties file. Is this supposed to work that way? >> > >> > > >>> -- >> > > >>> Rafael Ponte >> > > >>>http://www.rponte.com.br >> > >> > > >> -- >> > > >> Rafael Ponte >> > > >>http://www.triadworks.com.br |
|
Ok, I can get it to fail in an isolated project during a functional test in maven. The failure doesn't actually occur until a mapper method is executed.
I have it as an intellij project, do you want me to tar/gz it and attach it to a new bug? --adam On Wednesday, March 14, 2012 12:57:56 PM UTC-6, Eduardo wrote: Your config looks right and the beanname thing works for me! |
|
Yes please.
El día 14 de marzo de 2012 20:29, Adam Gordon <[hidden email]> escribió: > Ok, I can get it to fail in an isolated project during a functional test in > maven. The failure doesn't actually occur until a mapper method is > executed. > > I have it as an intellij project, do you want me to tar/gz it and attach it > to a new bug? > > --adam > > On Wednesday, March 14, 2012 12:57:56 PM UTC-6, Eduardo wrote: >> >> Your config looks right and the beanname thing works for me! >> >> If that gets annoying enough please isolate it in a test and fill and >> issue so we can have a look to see whats going on. >> >> El día 14 de marzo de 2012 19:49, Adam Gordon escribió: >> >> >> > No worries, it's a bit much, IMO. >> > >> > I am using two datasources, but everything is independent: the data >> > source >> > definitions (obviously), the transaction managers, sql session >> > factories, >> > and the mapper scanner configurers. >> > >> > If I switch back to the util:properties method of loading properties >> > files, >> > it works - and I am using the sqlSessionFactoryBeanName property. >> > >> > I am using Spring 3.1.1-RELEASE, MyBatis 3.1.0, and mybatis-spring >> > 1.1.0. >> > >> > --adam >> > >> > >> > On Wednesday, March 14, 2012 12:39:54 PM UTC-6, Eduardo wrote: >> >> >> >> Sorry, I am a bit lost with the new google groups interface. >> >> >> >> The problem that Rafael pointed has nothing to do with mybatis spring >> >> and mapperscannerconfigurer. It is a migrations problem (I do not know >> >> if that was solved, I do not use migrations) >> >> >> >> In your case. Are you using more than one datasource? If you are not >> >> then remove the line: >> >> >> >> <property name="sqlSessionFactoryBeanName" >> >> > value="bmsSqlSessionFactory"/> >> >> >> >> On 14 mar, 19:14, Adam Gordon <[hidden email]> wrote: >> >> > Sure. The error is that it cannot resolve the port number. Here's >> >> > the >> >> > relevant stuff - note that I have multiple datasources but they are >> >> > configured similarly. I would have loved to see an example of both >> >> > the >> >> > SqlSessionFactoryBean config AND the MapperScannerConfigurer, but all >> >> > I >> >> > could find was this: >> >> > >> >> > http://www.mybatis.org/spring/apidocs/reference/org/mybatis/spring/ma.... >> >> > Here's the relevant code/config: >> >> > >> >> > *Error* >> >> > org.mybatis.spring.MyBatisSystemException: nested exception is >> >> > org.apache.ibatis.exceptions.PersistenceException: >> >> > ### Error querying database. Cause: >> >> > org.springframework.jdbc.CannotGetJdbcConnectionException: Could not >> >> > get >> >> > JDBC Connection; nested exception is java.sql.SQLException: Invalid >> >> > number >> >> > format for port number >> >> > ### The error may exist in >> >> > com/twc/mystro/mbo/mboui/bms/persistence/bm/ProviderMapper.xml >> >> > ### The error may involve >> >> > >> >> > >> >> > com.twc.mystro.mbo.mboui.bms.persistence.bm.ProviderMapper.getProviderList >> >> > ### The error occurred while executing a query >> >> > ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: >> >> > Could >> >> > not get JDBC Connection; nested exception is java.sql.SQLException: >> >> > Invalid >> >> > number format for port number >> >> > >> >> > *MapperScanner config* >> >> > <bean id="bmsMapperScannerConfigurer" >> >> > class="org.mybatis.spring.mapper.MapperScannerConfigurer"> >> >> > <property name="basePackage" value="com.foo.bms.persistence"/> >> >> > <property name="sqlSessionFactoryBeanName" >> >> > value="bmsSqlSessionFactory"/> >> >> > <property name="annotationClass" >> >> > value="com.foo.bms.persistence.BmsDatabase"/> >> >> > </bean> >> >> > >> >> > *SqlSessionFactory config* >> >> > <bean id="bmsSqlSessionFactory" name="bmsSqlSessionFactory" >> >> > class="org.mybatis.spring.SqlSessionFactoryBean"> >> >> > <property name="dataSource" ref="bmsDataSource"/> >> >> > <property name="configLocation" >> >> > value="classpath:mybatis-config.xml"/> >> >> > <property name="typeAliasesPackage" value="com.foo.bms.model, >> >> > com.foo.alert.model"/> >> >> > </bean> >> >> > >> >> > *Database config* >> >> > <context:property-placeholder >> >> > location="classpath:com/foo/bms/persistence/jdbc.properties"/> >> >> > >> >> > <!-- the bms database data source --> >> >> > <bean id="bmsDataSource" class="oracle.jdbc.pool.OracleDataSource" >> >> > destroy-method="close"> >> >> > <property name="URL" >> >> > >> >> > value="jdbc:oracle:thin:@//${bmsdb.host}:${jdbc.port}/${bmsdb.dbName}"/> >> >> > <property name="user" value="${bmsdb.username}"/> >> >> > <property name="password" value="${bmsdb.password}"/> >> >> > <property name="connectionCachingEnabled" value="true"/> >> >> > <property name="connectionCacheProperties"> >> >> > <props merge="default"> >> >> > <prop key="MinLimit">1</prop> >> >> > <prop key="MaxLimit">10</prop> >> >> > <prop key="ConnectionWaitTimeout">30</prop> >> >> > </props> >> >> > </property> >> >> > </bean> >> >> > >> >> > Thanks, >> >> > >> >> > --adam >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > On Wednesday, March 14, 2012 11:30:26 AM UTC-6, Eduardo wrote: >> >> > >> >> > > Adam, could you please post your config and the error? >> >> > >> >> > > El día 14 de marzo de 2012 18:27, Adam Gordon escribió: >> >> > > > Here it is: >> >> > > > http://code.google.com/p/mybatis/issues/detail?id=414 >> >> > >> >> > > > Not sure how this was supposed to be fixed however, because it's >> >> > > > not >> >> > > working >> >> > > > for me - could be my bean names are not right. >> >> > >> >> > > > --adam >> >> > >> >> > > > On Thursday, January 5, 2012 6:39:01 AM UTC-7, Rafael Ponte >> >> > > > wrote: >> >> > >> >> > > >> Some solution for this issue? >> >> > >> >> > > >> On Wed, Jun 15, 2011 at 6:27 PM, Rafael Ponte <> wrote: >> >> > >> >> > > >>> Hi people, >> >> > >> >> > > >>> I'm getting an error on Mybatis Migrations when I have a >> >> > > >>> properties >> >> > > file >> >> > > >>> like this: >> >> > >> >> > > >>>> database=mydb >> >> > > >>>> url=jdbc:jtds:sqlserver://localhost:1433/${database} >> >> > >> >> > > >>> All migrations commands seem not to support property evaluation >> >> > > >>> in >> >> > > >>> my >> >> > > >>> properties file. Is this supposed to work that way? >> >> > >> >> > > >>> -- >> >> > > >>> Rafael Ponte >> >> > > >>>http://www.rponte.com.br >> >> > >> >> > > >> -- >> >> > > >> Rafael Ponte >> >> > > >>http://www.triadworks.com.br |
|
Issue 544 has been created. The sample project is attached. Note that I have Oracle data sources defined/configured. Thanks, --adam
On Wednesday, March 14, 2012 1:32:45 PM UTC-6, Eduardo wrote: Yes please. |
| Powered by Nabble | Edit this page |
