Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Declaring a simple bean in Spring

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to do the example in the Spring in Action 3ed book on p.33 section 2.1.2. I can't get the sample code to output "JUGGLING 3 BEANBAGS".

The book says on p.34 a quarter of the way down, "To give Duke a try, you can load the Spring application context using the following code: "

ApplicationContext ctx = new ClassPathXmlApplicationContext("com/springinaction/springidol/spring-idol.xml");
Performer performer = (Performer) ctx.getBean("duke");
performer.perform();

I added the code snippet above to the main method that I created inside of the Juggler.class. I got an error message. Can someone tell me what I'm doing wrong here? Thank you.


Here is the spring-idol.xml configuration file that is given to us:



Here is the parent class Performer:



Here is the child class Juggler:




Here is the error message:

cd C:\Users\MSC\Documents\sia3code\springidol; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.7.0_40" "\"C:\\Program Files\\NetBeans 7.3.1\\java\\maven\\bin\\mvn.bat\"" "-Dexec.args=-classpath %classpath com.springinaction.springidol.Test" "-Dexec.executable=C:\\Program Files\\Java\\jdk1.7.0_40\\bin\\java.exe" process-classes org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
Scanning for projects...

Some problems were encountered while building the effective model for com.springinaction:springidol:jar:3.0.0
'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ com.springinaction:example-code:3.0.0, C:\Users\MSC\Documents\sia3code\pom.xml, line 23, column 15

It is highly recommended to fix these problems because they threaten the stability of your build.

For this reason, future Maven versions might no longer support building such malformed projects.


------------------------------------------------------------------------
Building Spring in Action Spring Idol 3.0.0
------------------------------------------------------------------------

[resources:resources]
[debug] execute contextualize
Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
Copying 2 resources

[compiler:compile]
File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
Compiling 1 source file to C:\Users\MSC\Documents\sia3code\springidol\target\classes

[exec:exec]
Error: Could not find or load main class com.springinaction.springidol.Test
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.700s
Finished at: Mon Sep 16 17:55:40 EDT 2013
Final Memory: 11M/108M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project springidol: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have your main method in the juggler class, you will have to tell maven to execute the juggler class not the test class
 
Brian Storenson
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help. I did a clean build, and now I have more error messages relating to maven. I will read up on that. The example was an older version of maven, and my netbeans ide has maven 3.0.5
 
reply
    Bookmark Topic Watch Topic
  • New Topic