You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
01:28:58,382 ERROR [stderr](ServerService Thread Pool -- 76) ERROR when parsing programovani/java/howto-spring-reading_properties_file.texy:
java.lang.IllegalArgumentException: Illegal group reference 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) java.lang.IllegalArgumentException: Illegal group reference 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.openjdkregex.Matcher.appendReplacement(Matcher.java:725) 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.modules.HtmlOutputModule.postProcess(HtmlOutputModule.java:158) 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.modules.HtmlOutputModule.access$100(HtmlOutputModule.java:29) 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.modules.HtmlOutputModule$1.onEvent(HtmlOutputModule.java:100) 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.modules.HtmlOutputModule$1.onEvent(HtmlOutputModule.java:96) 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.JTexy.invokeNormalHandlers(JTexy.java:350) 01:28:58,384 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.JTexy.stringToHtml(JTexy.java:308) 01:28:58,384 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.JTexy.process(JTexy.java:250) 01:28:58,384 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.JTexy.process(JTexy.java:210)
The text was updated successfully, but these errors were encountered:
How to read properties file in Spring Framework
***********************************************
I've had a problem with reading `.properties` file in Spring Framework.
I needed to inject it into the iBatis' `SqlMapConfig.xml`:
/--code xml .[brush:]
<!-- iBatis -->
<bean id="sqlMap" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="sqlMapClientProperties" value="file:conf/${profile}/nastaveni.properties" />
<property name="configLocation" value="ibatis-maps/SqlMapConfig2.xml"/>
</bean>
<alias alias="iBatis" name="sqlMap"/>
\--
But iBatis kept complaining that the properties defined in the file were not resolved.
Better said, it behaved like the actual value was the property name, thus the code
/--code xml .[brush:]
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${jdbc.driver}"/>
\--
gave me a `ClassNotFoundException` for the class `jdbc.driver`.
What actually happened was clear when I made a test bean with a property of type `java.lang.Properties`.
Spring takes the file path "file:conf/${profile}/nastaveni.properties" as a Properties string definition
and provides iBatis a `Properties` object with a single property: `file = conf/release/nastaveni.properties`.
The solution is to use the `SqlMapClientFactoryBean`:
/--code xml .[brush:]
<!-- iBatis -->
<bean id="sqlMap" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="sqlMapClientProperties">
<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="file:conf/${profile}/nastaveni.properties"/>
</bean>
</property>
<property name="configLocation" value="ibatis-maps/SqlMapConfig2.xml"/>
</bean>
\--
Of course, this is a trivial think, but not much well documented.
01:28:58,382 ERROR [stderr](ServerService Thread Pool -- 76) ERROR when parsing programovani/java/howto-spring-reading_properties_file.texy:
java.lang.IllegalArgumentException: Illegal group reference 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) java.lang.IllegalArgumentException: Illegal group reference 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.openjdkregex.Matcher.appendReplacement(Matcher.java:725) 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.modules.HtmlOutputModule.postProcess(HtmlOutputModule.java:158) 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.modules.HtmlOutputModule.access$100(HtmlOutputModule.java:29) 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.modules.HtmlOutputModule$1.onEvent(HtmlOutputModule.java:100) 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.modules.HtmlOutputModule$1.onEvent(HtmlOutputModule.java:96) 01:28:58,383 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.JTexy.invokeNormalHandlers(JTexy.java:350) 01:28:58,384 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.JTexy.stringToHtml(JTexy.java:308) 01:28:58,384 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.JTexy.process(JTexy.java:250) 01:28:58,384 ERROR [stderr](ServerService Thread Pool -- 76) at cz.dynawest.jtexy.JTexy.process(JTexy.java:210)
The text was updated successfully, but these errors were encountered: