• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Spring: Hello World Does Not Work

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Major Java Greenhorn here with Spring...

I'm following this Hello World guide to Spring to the letter:

http://www.developer.com/java/ejb/article.php/10931_3496416_2/A-Spring-Jump-Start.htm

However when I launch the main.java in Eclipse, it keeps on saying my Configuration File's id="greetingService" cannot find the class com.springinaction.chapter01.hello.

I made sure all the .java files were packaged within the com.springinaction.chapter01.hello too!

I not only installed the Eclipse Spring IDE, but I also have the spring.js and commons-logging.jar JAR files in my build path...

What am I doing wrong?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have no way of knowing, since you provided none of your code or configuration.
 
Perry Terrance
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I made sure that spring.JAR and commons-logging.JAR are in the Build-Path...

In main.java






In GreetingService.java




In GreetingServiceImpl





And finally in the Spring Configuration XML


hello2.xml





Pushed RUN on main.java in Eclipse - no go...
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compare:with:
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Spring forum.

Mark
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm no Spring expert but the most likely problem is your location of your config file. Given what you have, the program will look for it in the root folder of the project if running directly from the IDE. If you are in doubt type in the full path like "C:\...." or whatever.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Compare:with:



I this the problem is what David mentioned.

Since the package name is com.springinaction.chapter01.hello.GreetingServiceImpl and the class name is GreetingServiceImpl the config should look like


and not

 
Perry Terrance
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a screen of what the file structure looks like for this project file. I tried - what you said, but it still doesn't work - "can't find constructor."
-30CA716FDA683BE9.jpg
[Thumbnail for -30CA716FDA683BE9.jpg]
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't define a default constructor--the error message is correct.
 
Perry Terrance
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I guess my question now is - how do I run this thing?

I push Run on main.java and this the following message:

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Define a default constructor.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Personally, I think your package naming is a little redundant, too, and counter to Java conventions (packages are all lower-case).
 
Perry Terrance
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I got to figure out how to do a default constructor through a Spring Framework - interesting...
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, if you're not doing constructor injection, your beans need to be instantiable without parameters.
 
Perry Terrance
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aha! Fixed it!

Just added another constructor blurb in GreetingServiceImpl.java


Got Buenos Dias! message! Thanks everyone!
 
crispy bacon. crispy tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic