You don't need to create a web\WEB-INF folder to use Spring. Look at using a GenericApplicationContext and a XmlBeanDefinitionReader. Look at the BeanFactory interface in the Spring documentation

-Richard

[EMAIL PROTECTED] wrote:

Hi,

I want to convert my iBATIS DAO to Spring DAO. My Java project is not web project. But its application running using class that has main() method. So in order to use Spring DAO, I had to specially create web\WEB-INF folder and add web.xml file, spring.xml file to it.

_web.xml has below content:_

<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd";>
<web-app>
    <description>web.xml file for OTM Web Application</description>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring.xml</param-value>
    </context-param>
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
<listener> <listener-class>org.nexweb.otm.spring.listeners.SpringInit</listener-class>
    </listener>
</web-app>

_spring.xml has below content:_

<?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="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:jdbc.properties"/>
    </bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
       <property name="driverClassName" value="${jdbc.driverClassName}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
    </bean>
    <bean id="sqlMapClient"
          class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
        <property name="configLocation">
<value>classpath:org/nexweb/otm/ibatis/config/SqlMapConfig.xml</value>
        </property>
        <property name="useTransactionAwareDataSource">
            <value>true</value>
        </property>
        <property name="dataSource">
            <ref bean="dataSource"/>
        </property>
    </bean>
    <bean id="sqlMapClientTemplate"
          class="org.springframework.orm.ibatis.SqlMapClientTemplate">
        <property name="sqlMapClient">
            <ref bean="sqlMapClient"/>
        </property>
</bean> <bean id="glogDao" class="org.nexweb.otm.ibatis.dao.sqlmaps.GLogXMLSqlMapDAO">
        <property name="sqlMapClient">
            <ref bean="sqlMapClient"/>
        </property>
    </bean>
<bean id="xmlService" class="org.nexweb.otm.ibatis.services.XmlService">
        <constructor-arg index="0" ref="glogDao"/>
    </bean>
</beans>


I also added SpringInit.java file as shown in http://opensource.atlassian.com/confluence/oss/display/IBATIS/Converting+iBATIS+DAO+to+Spring+DAO.

*Now, when I invoke SpringInit.getApplicationContext() method, its returning me 'null'. The application is not calling contextInitialized() when I run it thru the main() method call.*

*What should I do to set WebApplicationContext springContext ?*

Thanks
Jasmin

*******************************************************************************
*ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
Our domain name is changing.  Please take note of the sender's
e-Mail address and make changes to your personal address list,
if needed.  Both domains will continue to work, only for a limited
time.
******************************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or agency to whom they are addressed.
If you have received this email in error please notify the Navy
Exchange Service Command e-mail administrator. This footnote
also confirms that this email message has been scanned for the
presence of computer viruses.

Thank You! ********************************************************************************


Reply via email to