Results 1 to 9 of 9

Thread: Please Help in Migration from old spring to new 3.1

  1. #1

    Default Please Help in Migration from old spring to new 3.1

    Hello,

    I have developed a Flex-spring-mybatis-Firebird application couple of years ago with 3.0 and is working fine.
    Few weeks ago I have started developing another application on same platform but this time I decided to use new spring 3.1.

    so I installed STS 2.8.1, got latest libs like apache-commons, Joda datetime, dozer, myBatis 3.0.6, mybatis spring and Spring 3.1, sec 3.1, spring-flex 1.5. Created jsp pages for general info and as flex container. copied config files from old application and edited headers and contents suitable to 3.1 in STS till editor stops showing errors. Then I tried to deploy it on STS vfabric TC 2.6 till this time no java beans have been developed for application functionality since System Study phase is in progress, I am trying to test loading of web pages by in memory authentication and check authorizations for web pages only, services are not yet developed. My application is not getting started and TC server throws exception. The config file under consideration is as follows.

    <?xml version="1.0" encoding="UTF-8"?>

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:flex="http://www.springframework.org/schema/flex"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:security="http://www.springframework.org/schema/security"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/flex http://www.springframework.org/schem...g-flex-1.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schem...ng-aop-3.1.xsd
    http://www.springframework.org/schema/security http://www.springframework.org/schem...curity-3.1.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.1.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schem...ing-tx-3.1.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

    <!-- ================= START Database Configuration ================= -->

    <contextroperty-placeholder location="WEB-INF/spring/appl-myBatis-Reference.properties"/>

    <!-- .................................................. .................. Earlier it was as follows it also fails
    <bean class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="locations" value="WEB-INF/spring/appl-myBatis-Reference.properties"/>
    </bean>
    .................................................. .................. -->


    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driverClassName}"/>
    <property name="url" value="${jdbc.url}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>

    <!-- connection Pool Parameters -->
    <property name="maxActive" value="${pool.maxActive}"/>
    <property name="maxIdle" value="${pool.maxIdle}"/>
    <property name="minIdle" value="${pool.minIdle}"/>
    <property name="initialSize" value="${pool.initialSize}"/>
    <property name="maxWait" value="${pool.maxWait}"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource"><ref local="dataSource"/></property>
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />

    <bean class="org.mybatis.spring.mapper.MapperScannerConf igurer">
    <property name="basePackage" value="${mapper.ClassPackages}" />
    </bean>

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mapperLocations" value="${mapper.XmlLocations}" />
    </bean>

    </beans>

    the appl-myBatis-Reference.properties contains

    #
    # JDBC Connection Parameters
    #
    jdbc.driverClassName=org.firebirdsql.jdbc.FBDriver
    jdbc.url=jdbc:firebirdsql:localhost/3050:/FB_DEV/FB_DATA/Data/Tej-EIS_FB21.FDB
    jdbc.username=SYSDBA
    jdbc.password=masterkey

    pool.maxActive=-1
    pool.maxIdle=10
    pool.minIdle=2
    pool.initialSize=10
    pool.maxWait=30000

    mapper.XmlConfig=${Tej-EIS.root}WEB-INF/classes/com/tej_EIS/mbFirebird/sqlSessionFactoryConfigTables.xml
    mapper.XmlLocations=classpath*:com/tej_EIS/mbFirebird/sqlMaps/**/*.xml
    mapper.ClassPackages=com.tej_EIS.mbMappers.table


    The TC server throws exception that place holder "mapper.ClassPackages" not found.


    Can somebody help me in this ?

    Thanks and warm regards.

    Raja

  2. #2
    Join Date
    Jan 2006
    Location
    Seattle, Washington
    Posts
    467

    Default

    Well, it's obviously not finding the properties file. You might be better off installing the properties file in WEB-INF/classes, like in "WEB-INF/classes/spring/appl-myBatis-Reference.properties", and then changing your "location" value to "classpath:spring/appl-myBatis-Reference.properties".

  3. #3

    Default

    Thanks dkarr,

    with your suggestion previous error has gone but still it is throwing exception as follows.
    hope you could throw some light on this.

    But I wonder my previous config was able to load properties from web-inf/spring/*
    is there any change in spring 3.1 ?

    Thanks and warm regards.

    Raja

    Dec 22, 2011 9:04:04 AM com.springsource.tcserver.security.PropertyDecoder <init>
    INFO: tc Runtime property decoder using memory-based key
    Dec 22, 2011 9:04:04 AM com.springsource.tcserver.security.PropertyDecoder <init>
    INFO: tcServer Runtime property decoder has been initialized in 718 ms
    Dec 22, 2011 9:04:07 AM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["http-bio-8080"]
    Dec 22, 2011 9:04:07 AM com.springsource.tcserver.serviceability.rmi.JmxSo cketListener ini
    t
    INFO: Started up JMX registry on 127.0.0.1:6969 in 307 ms
    Dec 22, 2011 9:04:07 AM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 3375 ms
    Dec 22, 2011 9:04:07 AM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Catalina
    Dec 22, 2011 9:04:07 AM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: VMware vFabric tc Runtime 2.6.1.RELEASE/7.0.20.B.RELEASE
    Dec 22, 2011 9:04:07 AM org.apache.catalina.startup.HostConfig deployDescriptor
    INFO: Deploying configuration descriptor Tej-EIS-31.xml from /home/rsp/springsource/vfabri
    c-tc-server-developer-2.6.1.RELEASE/vFabric_TC_2-6_Plain/conf/Catalina/localhost
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/st...rmittedTaglibs is alr
    eady defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already d
    efined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
    Dec 22, 2011 9:04:09 AM org.apache.catalina.core.ApplicationContext log
    INFO: Set web app root system property: 'Tej-EIS.root' = [/home/rsp/Backup/Appl/Web_Dev/Ja
    va_WorkSpace/Tej-EIS-3.1/WebContent/]
    Dec 22, 2011 9:04:09 AM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing log4j from [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/We
    bContent/WEB-INF/spring/log4j-Setting.xml]
    Dec 22, 2011 9:04:09 AM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    Dec 22, 2011 9:04:10 AM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.spri
    ngframework.web.context.ContextLoaderListener
    java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlBeanDefin itionReader
    .setEnvironment(Lorg/springframework/core/env/EnvironmentV
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(X
    mlWebApplicationContext.java:87)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanF
    actory(AbstractRefreshableApplicationContext.java: 131)
    at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(
    AbstractApplicationContext.java:522)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplica
    tionContext.java:436)
    at org.springframework.web.context.ContextLoader.conf igureAndRefreshWebApplicationContext
    (ContextLoader.java:384)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.
    java:283)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoader
    Listener.java:111)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:4723)
    at org.apache.catalina.core.StandardContext$1.call(St andardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(St andardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.jav a:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    Dec 22, 2011 9:04:10 AM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error listenerStart
    Dec 22, 2011 9:04:15 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
    INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [5
    ,099] milliseconds.
    Dec 22, 2011 9:04:15 AM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Context [/Tej-EIS-31] startup failed due to previous errors
    Dec 22, 2011 9:04:15 AM org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext
    Dec 22, 2011 9:04:15 AM org.apache.catalina.core.StandardContext listenerStop
    SEVERE: Exception sending context destroyed event to listener instance of class org.spring
    framework.web.context.ContextLoaderListener
    java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'ref
    resh' before accessing beans via the ApplicationContext
    at org.springframework.context.support.AbstractRefres hableApplicationContext.getBeanFacto
    ry(AbstractRefreshableApplicationContext.java:172)
    at org.springframework.context.support.AbstractApplic ationContext.destroyBeans(AbstractAp
    plicationContext.java:1066)
    at org.springframework.context.support.AbstractApplic ationContext.doClose(AbstractApplica
    tionContext.java:1040)
    at org.springframework.context.support.AbstractApplic ationContext.close(AbstractApplicati
    onContext.java:988)
    at org.springframework.web.context.ContextLoader.clos eWebApplicationContext(ContextLoader
    .java:541)
    at org.springframework.web.context.ContextLoaderListe ner.contextDestroyed(ContextLoaderLi
    stener.java:142)
    at org.apache.catalina.core.StandardContext.listenerS top(StandardContext.java:4763)
    at org.apache.catalina.core.StandardContext$4.run(Sta ndardContext.java:5473)
    at java.lang.Thread.run(Thread.java:662)
    Dec 22, 2011 9:04:15 AM org.apache.catalina.core.ApplicationContext log
    INFO: Shutting down log4j
    Dec 22, 2011 9:04:15 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThread
    s
    SEVERE: The web application [/Tej-EIS-31] appears to have started a thread named [FileWatc
    hdog] but has failed to stop it. This is very likely to create a memory leak.
    Dec 22, 2011 9:04:15 AM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory ROOT
    Dec 22, 2011 9:04:15 AM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory manager
    Dec 22, 2011 9:04:15 AM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler ["http-bio-8080"]
    Dec 22, 2011 9:04:15 AM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 8252 ms

  4. #4

    Default

    Sorry friends,

    I figured out why this was happening, a springframework-bean.jar from ver 3.0 was in lib folder I deleted it and the original error popped back.
    I have modified the xml as below and also attaching debug log. Still its not able to locate the properties file.

    Please help me out

    Thanks and warm regards.

    raja

    The Log

    12:34:07 898 INFO Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appl-security-Config.xml]
    12:34:08 562 DEBUG Loaded 33 bean definitions from location pattern [/WEB-INF/spring/appl-security-Config.xml]
    12:34:08 562 INFO Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appl-services-Config.xml]
    12:34:08 810 DEBUG Loaded 5 bean definitions from location pattern [/WEB-INF/spring/appl-services-Config.xml]
    12:34:08 810 INFO Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appl-myBatis-Spring-Config.xml]
    12:34:08 956 DEBUG Loaded 8 bean definitions from location pattern [/WEB-INF/spring/appl-myBatis-Spring-Config.xml]
    12:34:09 070 DEBUG Creating shared instance of singleton bean 'myBatisMapperScanner'
    12:34:09 070 DEBUG Creating instance of bean 'myBatisMapperScanner'
    12:34:09 116 DEBUG Eagerly caching bean 'myBatisMapperScanner' to allow for resolving potential circular references
    12:34:09 199 DEBUG Invoking afterPropertiesSet() on bean with name 'myBatisMapperScanner'
    12:34:09 200 DEBUG Finished creating instance of bean 'myBatisMapperScanner'
    12:34:09 212 DEBUG Initializing new StandardEnvironment
    12:34:09 213 DEBUG Adding [systemProperties] PropertySource with lowest search precedence
    12:34:09 213 DEBUG Adding [systemEnvironment] PropertySource with lowest search precedence
    12:34:09 213 DEBUG Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
    12:34:09 233 DEBUG Searching for key 'mapper.ClassPackages' in [systemProperties]
    12:34:09 233 DEBUG Searching for key 'mapper.ClassPackages' in [systemEnvironment]
    12:34:09 234 DEBUG Could not find key 'mapper.ClassPackages' in any property source. Returning [null]
    12:34:09 235 ERROR Context initialization failed
    java.lang.IllegalArgumentException: Could not resolve placeholder 'mapper.ClassPackages'
    at org.springframework.util.PropertyPlaceholderHelper .parseStringValue(PropertyPlaceholderHelper.java:1 73)
    at org.springframework.util.PropertyPlaceholderHelper .replacePlaceholders(PropertyPlaceholderHelper.jav a:125)
    at org.springframework.core.env.AbstractPropertyResol ver.doResolvePlaceholders(AbstractPropertyResolver .java:151)
    at org.springframework.core.env.AbstractPropertyResol ver.resolveRequiredPlaceholders(AbstractPropertyRe solver.java:142)
    at org.springframework.core.env.AbstractEnvironment.r esolveRequiredPlaceholders(AbstractEnvironment.jav a:402)
    it continues still further

    appl-myBatis-Spring-Config.xml
    <?xml version="1.0" encoding="UTF-8"?>

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:flex="http://www.springframework.org/schema/flex"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:security="http://www.springframework.org/schema/security"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/flex http://www.springframework.org/schem...g-flex-1.5.xsd
    http://www.springframework.org/schema/security http://www.springframework.org/schem...curity-3.1.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.1.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schem...ing-tx-3.1.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

    <!-- .................................................. .................. I tried all these without success
    <contextroperty-placeholder location="classpathroperties.appl-myBatis-Reference.properties"/>
    <bean class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location" value="classpathroperties/appl-myBatis-Reference.properties"/>
    </bean>
    .................................................. .................. -->
    <bean id="myBatisProperties" class="org.springframework.context.support.Propert ySourcesPlaceholderConfigurer">
    <property name="location" value="classpathroperties/appl-myBatis-Reference.properties"/>
    </bean>


    <!-- Datasource for Database using Connectivity Parameters -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driverClassName}"/>
    <property name="url" value="${jdbc.url}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>

    <!-- connection Pool Parameters -->
    <property name="maxActive" value="${pool.maxActive}"/>
    <property name="maxIdle" value="${pool.maxIdle}"/>
    <property name="minIdle" value="${pool.minIdle}"/>
    <property name="initialSize" value="${pool.initialSize}"/>
    <property name="maxWait" value="${pool.maxWait}"/>
    </bean>

    <!-- Define Transaction Manager -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource"><ref local="dataSource"/></property>
    </bean>

    <!-- Define How Transaction Manager is Used -->
    <tx:annotation-driven transaction-manager="transactionManager" />

    <bean id="myBatisMapperScanner" class="org.mybatis.spring.mapper.MapperScannerConf igurer">
    <property name="basePackage" value="${mapper.ClassPackages}" />
    </bean>

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mapperLocations" value="${mapper.XmlLocations}" />
    </bean>

    </beans>

  5. #5
    Join Date
    Jan 2006
    Location
    Seattle, Washington
    Posts
    467

    Default

    Does your deployment package have the exact element path of "WEB-INF/classes/properties/appl-myBatis-Reference.properties"?

  6. #6

    Default

    Thanks dkarr,

    I figured out what is happening. First I modified the appl-myBatis-Spring-Config.xml as below

    <bean id="myBatisProperties" class="org.springframework.context.support.Propert ySourcesPlaceholderConfigurer">
    <property name="location" value="classpathroperties/appl-myBatis-Reference.properties"/>
    </bean>

    <!-- Datasource for Database using Connectivity Parameters -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driverClassName}"/>
    <property name="url" value="${jdbc.url}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>

    <!-- connection Pool Parameters -->
    <property name="maxActive" value="${pool.maxActive}"/>
    <property name="maxIdle" value="${pool.maxIdle}"/>
    <property name="minIdle" value="${pool.minIdle}"/>
    <property name="initialSize" value="${pool.initialSize}"/>
    <property name="maxWait" value="${pool.maxWait}"/>
    </bean>

    <!-- Define Transaction Manager -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource"><ref local="dataSource"/></property>
    </bean>

    <!-- Define How Transaction Manager is Used -->
    <tx:annotation-driven transaction-manager="transactionManager" />

    <bean id="myBatisMapperScanner" class="org.mybatis.spring.mapper.MapperScannerConf igurer">
    <property name="basePackage" value="com.tej_EIS.mbMappers" />
    (The actual value instead of place holder)
    </bean>

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mapperLocations" value="${myBatis.XmlLocations}" />
    </bean>

    Then studied the debug log as below

    08:40:18 231 INFO Root WebApplicationContext: initialization started
    08:40:18 528 INFO Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appl-security-Config.xml]
    08:40:19 360 DEBUG Loaded 33 bean definitions from location pattern [/WEB-INF/spring/appl-security-Config.xml]

    08:40:19 360 INFO Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appl-services-Config.xml]
    08:40:19 533 DEBUG Loaded 5 bean definitions from location pattern [/WEB-INF/spring/appl-services-Config.xml]

    08:40:19 533 INFO Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appl-myBatis-Spring-Config.xml]
    08:40:19 608 DEBUG Loaded 8 bean definitions from location pattern [/WEB-INF/spring/appl-myBatis-Spring-Config.xml]

    So all main config xmls metioned in web.xml are being processed

    08:40:19 753 DEBUG Creating shared instance of singleton bean 'myBatisMapperScanner'
    08:40:19 870 DEBUG Finished creating instance of bean 'myBatisMapperScanner'
    08:40:19 889 DEBUG Looking for matching resources in directory tree [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers]
    08:40:19 889 DEBUG Searching directory [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers] for files matching pattern [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers/**/*.class]
    08:40:19 892 DEBUG Searching directory [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers/table] for files matching pattern [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers/**/*.class]
    08:40:19 895 DEBUG Resolved location pattern [classpath*:com/tej_EIS/mbMappers/**/*.class] to resources [file [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers/table/SystemUserRecMapper.class]]

    08:40:19 938 DEBUG Creating shared instance of singleton bean 'myBatisProperties'
    08:40:19 938 DEBUG Creating instance of bean 'myBatisProperties'
    08:40:19 944 DEBUG Eagerly caching bean 'myBatisProperties' to allow for resolving potential circular references
    08:40:19 955 DEBUG Finished creating instance of bean 'myBatisProperties'
    08:40:19 956 DEBUG Adding [environmentProperties] PropertySource with lowest search precedence
    08:40:19 956 INFO Loading properties file from class path resource [properties/appl-myBatis-Reference.properties]
    08:40:19 957 DEBUG Adding [localProperties] PropertySource with lowest search precedence

    And This is where things are going wrong. I was expecting that bean 'myBatisProperties' will be created before bean 'myBatisMapperScanner' but its getting created after it. so naturally placeholder ${myBatis.ClassPackages} was not available for bean 'myBatisMapperScanner'. Hence onward it was able to resolve placeholders like 'jdbc.driverClassName', 'jdbc.url' etc. etc. and application runs flawlessly.

    08:40:19 967 DEBUG Found key 'jdbc.driverClassName' in [localProperties] with type [String] and value 'org.firebirdsql.jdbc.FBDriver'
    08:40:19 974 DEBUG Found key 'jdbc.url' in [localProperties] with type [String] and value 'jdbc:firebirdsql:localhost/3050:/FB_DEV/FB_DATA/Data/Tej-EIS_FB21.FDB'
    08:40:19 977 DEBUG Found key 'jdbc.username' in [localProperties] with type [String] and value 'SYSDBA'
    08:40:19 979 DEBUG Found key 'jdbc.password' in [localProperties] with type [String] and value 'masterkey'
    08:40:19 981 DEBUG Found key 'pool.maxActive' in [localProperties] with type [String] and value '-1'
    08:40:19 984 DEBUG Found key 'pool.maxIdle' in [localProperties] with type [String] and value '10'
    08:40:19 985 DEBUG Found key 'pool.minIdle' in [localProperties] with type [String] and value '2'
    08:40:19 987 DEBUG Found key 'pool.initialSize' in [localProperties] with type [String] and value '10'
    08:40:19 989 DEBUG Found key 'pool.maxWait' in [localProperties] with type [String] and value '30000'
    08:40:19 991 DEBUG Found key 'myBatis.XmlLocations' in [localProperties] with type [String] and value 'classpath*:com/tej_EIS/mbFirebird/sqlMaps/**/*.xml'

    Now I am searching documentation to find out how can I force spring to create beans in desired order. If you know it offhand please tell me how can I force spring to create bean 'myBatisProperties' before bean 'myBatisMapperScanner', so that I can continue using the properties file for all parameters.

    Thanks and warm regards

    Raja

  7. #7

    Default

    dkarr,

    I figured out how to control creation order of beans and tested it but spring is behaving differently than expected.

    I modified the bean definition as follows

    <bean id="myBatisProperties" class="org.springframework.context.support.Propert ySourcesPlaceholderConfigurer">
    <property name="location" value="/WEB-INF/spring/appl-myBatis-Reference.properties"/>
    <property name="localOverride" value="true"/>
    </bean>

    <bean id="myBatisMapperScanner" class="org.mybatis.spring.mapper.MapperScannerConf igurer" depends-on="myBatisProperties">
    <property name="basePackage" value="com.tej_EIS.mbMappers" />
    </bean>

    it worked fine, bean "myBatisProperties" was created before bean "myBatisMapperScanner" as expected.
    Also means that location /WEB-INF/spring/appl-myBatis-Reference.properties is accessible and it can pickup properties from it.
    No problems at all.

    Now I modified bean "myBatisMapperScanner" as follows

    <bean id="myBatisMapperScanner" class="org.mybatis.spring.mapper.MapperScannerConf igurer" depends-on="myBatisProperties">
    <property name="basePackage" value="${myBatis.ClassPackages}" />
    </bean>

    The trouble started once again the debug log is as follows

    12:19:02 931 INFO Root WebApplicationContext: initialization started

    12:19:04 725 DEBUG Loaded 8 bean definitions from location pattern [/WEB-INF/spring/appl-myBatis-Spring-Config.xml]

    12:19:04 895 DEBUG Creating shared instance of singleton bean 'myBatisProperties'
    12:19:04 896 DEBUG Creating instance of bean 'myBatisProperties'
    12:19:04 989 DEBUG Eagerly caching bean 'myBatisProperties' to allow for resolving potential circular references

    12:19:05 074 DEBUG Initializing new StandardEnvironment
    12:19:05 074 DEBUG Adding [systemProperties] PropertySource with lowest search precedence
    12:19:05 074 DEBUG Adding [systemEnvironment] PropertySource with lowest search precedence
    12:19:05 074 DEBUG Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
    12:19:05 083 DEBUG Finished creating instance of bean 'myBatisProperties'

    12:19:05 084 DEBUG Creating shared instance of singleton bean 'myBatisMapperScanner'
    12:19:05 084 DEBUG Creating instance of bean 'myBatisMapperScanner'
    12:19:05 084 DEBUG Eagerly caching bean 'myBatisMapperScanner' to allow for resolving potential circular references
    12:19:05 092 DEBUG Invoking afterPropertiesSet() on bean with name 'myBatisMapperScanner'
    12:19:05 092 DEBUG Finished creating instance of bean 'myBatisMapperScanner'
    12:19:05 101 DEBUG Initializing new StandardEnvironment
    12:19:05 101 DEBUG Adding [systemProperties] PropertySource with lowest search precedence
    12:19:05 101 DEBUG Adding [systemEnvironment] PropertySource with lowest search precedence
    12:19:05 101 DEBUG Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
    12:19:05 111 DEBUG Searching for key 'myBatis.ClassPackages' in [systemProperties]
    12:19:05 112 DEBUG Searching for key 'myBatis.ClassPackages' in [systemEnvironment]
    12:19:05 112 DEBUG Could not find key 'myBatis.ClassPackages' in any property source. Returning [null]
    12:19:05 113 ERROR Context initialization failed
    java.lang.IllegalArgumentException: Could not resolve placeholder 'myBatis.ClassPackages'
    at org.springframework.util.PropertyPlaceholderHelper .parseStringValue(PropertyPlaceholderHelper.java:1 73)

    here [localproperties] is not being searched as it does for other beans. It seems that [localproperties] are not added
    to search process. So I modify bean 'myBatisMapperScanner' as follows

    <bean id="myBatisMapperScanner" class="org.mybatis.spring.mapper.MapperScannerConf igurer" depends-on="myBatisProperties">
    <property name="basePackage" value="com.tej_EIS.mbMappers" />
    </bean>

    You can see that bean 'myBatisProperties' is cached after initializing bean 'myBatisMapperScanner' and
    [localproperties] are added to search so the beans initializing after bean 'myBatisMapperScanner'
    the [localproperties] are searched on first priority and all keys are found. Please refer below.

    12:50:24 560 INFO Root WebApplicationContext: initialization started

    12:50:27 648 DEBUG Eagerly caching bean 'myBatisProperties' to allow for resolving potential circular references
    12:50:28 041 DEBUG Finished creating instance of bean 'myBatisProperties'

    12:50:28 045 DEBUG Creating shared instance of singleton bean 'myBatisMapperScanner'
    12:50:28 045 DEBUG Creating instance of bean 'myBatisMapperScanner'
    12:50:28 046 DEBUG Eagerly caching bean 'myBatisMapperScanner' to allow for resolving potential circular references
    12:50:28 098 DEBUG Invoking afterPropertiesSet() on bean with name 'myBatisMapperScanner'
    12:50:28 098 DEBUG Finished creating instance of bean 'myBatisMapperScanner'
    12:50:28 147 DEBUG Initializing new StandardEnvironment
    12:50:28 148 DEBUG Adding [systemProperties] PropertySource with lowest search precedence
    12:50:28 148 DEBUG Adding [systemEnvironment] PropertySource with lowest search precedence
    12:50:28 148 DEBUG Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
    12:50:28 201 DEBUG Looking for matching resources in directory tree [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers]
    12:50:28 201 DEBUG Searching directory [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers] for files matching pattern [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers/**/*.class]
    12:50:28 204 DEBUG Searching directory [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers/table] for files matching pattern [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers/**/*.class]
    12:50:28 233 DEBUG Resolved location pattern [classpath*:com/tej_EIS/mbMappers/**/*.class] to resources [file [/home/rsp/Backup/Appl/Web_Dev/Java_WorkSpace/Tej-EIS-3.1/WebContent/WEB-INF/classes/com/tej_EIS/mbMappers/table/SystemUserRecMapper.class]]

    12:50:28 394 DEBUG Returning cached instance of singleton bean 'myBatisProperties'
    12:50:28 394 DEBUG Adding [environmentProperties] PropertySource with lowest search precedence
    12:50:28 395 INFO Loading properties file from ServletContext resource [/WEB-INF/spring/appl-myBatis-Reference.properties]
    12:50:28 395 DEBUG Adding [localProperties] PropertySource with highest search precedence

    12:50:28 403 DEBUG Searching for key 'jdbc.driverClassName' in [localProperties]
    12:50:28 404 DEBUG Found key 'jdbc.driverClassName' in [localProperties] with type [String] and value 'org.firebirdsql.jdbc.FBDriver'

    with few other experiments I have reached to conclusion that the [localProperties] are added to search only after
    creating any bean after 'myBatisProperties' and properties are not available to initiazation of that bean but beans
    following next, the [localProperties] are available.

    Can you tell me what is happening and if possible solution to this. Timebeing, I am continuing my work with the
    lame solution of defining fixed value in bean 'myBatisMapperScanner', with which application is running.

    Thanks and warm regards

    Raja.

  8. #8
    Join Date
    Jul 2010
    Posts
    14

  9. #9

    Default

    Thanks mac1929,

    The limping solution as mentioned above is working but As suggested in your link,
    I am going for 1.1 and 3.1 versions soon. hope they have fixed the issue completely.

    Thanks once again and warm regards.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •