• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

error in a simple hibernate application

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i'm completely new to spring framework.i've developed a simple web application in spring.Putting the source code here.


HelloCLient.java
----------------

package com.infotech.springtest;

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

public class HelloClient {

public static void main(String[] args) throws Exception{
try
{
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");
System.out.println(s1);
}
catch(Exception e)
{

}
}
}

Hello.java
-----------

package com.infotech.springtest;

public interface Hello {
public String sayhello(String a);
}
HelloImp.java
--------------

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)
{
this.greeting=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;
}
}

hello.xml
----------

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



Upon running HelloClient.java 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
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SOrry for the incorrect subject line...
it is a spring application only
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Mark
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Not looking good. I think this might be the end. Wait! Is that a tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic