Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes BEA/Weblogic and the fly likes Spring Framework configuration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Spring Framework configuration" Watch "Spring Framework configuration" New topic

Spring Framework configuration

Ashok Haluvarthi

Joined: Jul 04, 2002
Posts: 13
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"?>

<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 id="db1" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref local="dataSource"/>

<bean id="db" class="">
<property name="dataSource">
<ref local="dataSource"/>

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



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.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 {
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 []; 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
I agree. Here's the link:
subject: Spring Framework configuration
It's not a secret anymore!