Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Spring Framework configuration

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Friend,
Currently I am trying to configure spring to my Weblogic 8.0 server.
I have done following steps.
Step 1) Coppied spring.jar to WEB-INF/lib folder.
Step 2) created applicationContext.xml in WEB-INF folder

<?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="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>oracle.jdbc.OracleDriver</value></property>
<property name="url"><value>jdbc racle:thin:@dtCON:1521:adf9idb</value></property>
<property name="username"><value>uid</value></property>
<property name="password"><value>pw</value></property>
</bean>

<bean id="db1" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref local="dataSource"/>
</property>
</bean>

<bean id="db" class="org.springframework.jdbc.core.support.JdbcDaoSupport">
<property name="dataSource">
<ref local="dataSource"/>
</property>
</bean>
</beans>

Step 3) same thing I have configured in Web.xml

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Step 4) wrote one simple example to access the table.

import java.util.List;
import javax.sql.DataSource;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.hibernate.HibernateTemplate;
public class ExecuteAStatement extends JdbcDaoSupport{


private JdbcTemplate jt;
private DataSource dataSource;

//public void setDataSource(DataSource ds){
// this.dataSource = ds;
//}

public List doExecute() throws DataAccessException {
System.out.print("Here");
List lit = getJdbcTemplate().queryForList("select * from tab");
System.out.print("Here" + lit.size());

}
}

here I an getting null object i.e. getJdbcTemplate() is null one thing and when I run this sample in server console it says

<Mar 2, 2006 4:41:14 PM GMT+05:30> <Warning> <HTTP> <BEA-101162>
<User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'db' defined in resource [/WEB-INF/applicationContext.xml] of S
ervletContext: Instantiation of bean failed; nested exception is org.springframework.beans.FatalBeanException: Could not instantiate class [org.springframework.jdbc.core.support.JdbcDaoSupport]; Is it an interface or an abstract class? Does it have a no-arg constructor?; nested exception is java.lan
g.InstantiationException: null.>
.

Please can u tell be where it is going wrong.

Thanks in advance
Ashok
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic