It's not a secret anymore!
The moose likes Other Application Frameworks and the fly likes error in a simple hibernate application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "error in a simple hibernate application" Watch "error in a simple hibernate application" New topic

error in a simple hibernate application

surima jain

Joined: Jan 01, 2009
Posts: 2
i'm completely new to spring framework.i've developed a simple web application in spring.Putting the source code here.

package com.infotech.springtest;

import org.springframework.beans.factory.*;
import org.springframework.beans.factory.xml.*;

public class HelloClient {

public static void main(String[] args) throws Exception{
System.out.println("please Wait.");
Resource res= new FileSystemResource("hello.xml");
System.out.println("Resource OK");
BeanFactory factory=new XmlBeanFactory(res);
System.out.println("BeanFactory OK.");
Hello bean1=(Hello)factory.getBean("Hello");
String s1=bean1.sayhello("3i-infotech");
catch(Exception e)


package com.infotech.springtest;

public interface Hello {
public String sayhello(String a);

package com.infotech.springtest;

* @author 50956
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
public class HelloImpl implements Hello{
private String greeting;
public HelloImpl()
public HelloImpl(String s)

public String sayhello(String a) {
// TODO Auto-generated method stub
return greeting+a;

* @param greeting The greeting to set.
public void setGreeting(String greeting) {
this.greeting = greeting;


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "D:\spring-beans.dtd">
<bean id="Hello" class="com.infotech.springtest.HelloImpl">
<property name="greeting">
<value>Hello World</value>

Upon running i'm getting the output as

please Wait.
Resource OK
Jan 2, 2009 11:56:14 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader
INFO: Loading XML bean definitions from file [C:\KastleUniversalLending_SuiteRAD\SpringTest\hello.xml]
surima jain

Joined: Jan 01, 2009
Posts: 2
SOrry for the incorrect subject line...
it is a spring application only
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Why not put something into the Exception handler because just catching and doing nothing is not a good idea. You are not seeing any exceptions, and will never know. The exception stacktrace will probably tell you everything.

Also, I recommend using ApplicationContext instead of BeanFactory, because that is the way things are now being done in Spring. The old way was with just a BeanFactory, but that is really pre Spring 2.0 days and we are already at Spring 2.5.6 and soon to be Spring 3.0


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

surima jain wrote:SOrry for the incorrect subject line...
it is a spring application only

You can fix it easily. Just click the button on your post.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: error in a simple hibernate application
It's not a secret anymore!