This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes spring inside eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "spring inside eclipse" Watch "spring inside eclipse" New topic
Author

spring inside eclipse

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Hi,
I have downloaded and installed eclipse.I want to work in spring framework.But i am very new to spring and eclipse too.I have installed the spring ide(spring-ide_updatesite_2.0.0_v200706271108.zip) inside the eclipse through update manager site.Then i have tried a sample program in the new spring project.First i had selected the interface and typed the GreetingService.java in src folder in the NewSpringProject.

Then i had typed the class file GreetingServiceImpl.java in src folder

After that I had selected an xml file and typed the following code

Finally i have typed the class file HelloApp.java
.
here I am getting the following errors:

BeanFactory cannot be resolved to a type
The import org.springframework cannot be resolved
XmlBeanFactory cannot be resolved to a type
.please guide me why i am getting the following errors and please anyone gude me how to work in spring initially.How to start a program basically in spring.

Thanks
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

In Eclipse, in your project settings, did you set the spring.jar library ? Right-click your project, select Properties... In Java Build Path/Library, you need to add spring.jar.

How to start a program basically in spring.

By using an IDE you are comfortable with !


[My Blog]
All roads lead to JavaRanch
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Thankyou.I have added the spring.jar. Now i am getting only one error.

The constructor XmlBeanFactory(FileInputStream) is undefined

Why is it so?

Is it tough working with an ide in initial stage?Then how should i start to work in spring.please do help me.I dont know anything about spring framework.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Why is it so?

Because if you look at Spring's API, you'll see that there is no such constructor in XmlBeanFactory. Maybe you wanted to write it like this :


It's ok to use an IDE if you're not going to wasted hours trying to figure out how to configure something Well, it's compiling now, so you should be ok.
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Hi,
Thanks for your reply.It is working fine.But when i give like this:

I am getting the following error:

May 3, 2008 12:48:58 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [hello.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [hello.xml]; nested exception is java.io.FileNotFoundException: class path resource [hello.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:349)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
at HelloApp.main(HelloApp.java:14)
Caused by: java.io.FileNotFoundException: class path resource [hello.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:142)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
... 4 more

Sp sunil
Greenhorn

Joined: Jan 20, 2010
Posts: 1
just change the location of hello.xml file

like currently i assume your file should me in root directory of the application but you have to put this file in src folder , in my case i got same error so i changed the location and it is working fine.

Please let us know if you have any issue further.
 
 
subject: spring inside eclipse
 
Similar Threads
error in a simple hibernate application
Spring: Hello World Does Not Work
Problem with "Spring in Action" Book First Example
Problem in Eclipse IDE
How to have multiple public classes in one file for spring?