Spring / Java can not find the main method


I try to write a simple Spring 3 console application. I Cant get this application to run, i always get the error, that there is no main method. My system is an Ubuntu 12.04 with openjdk-7 installed, and the sts 2.9.2-release. A simple hello world runs without any problems Edit:(i tested a other project to prove a simple hello world would run).

The Project is managed over maven and i got no errors so far.

I try to reproduce an exsample of a book as follow:


import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

import org.springframework.core.io.FileSystemResource;

public class XmlConfigWithBeanFactory {

public static void main(String[] args) {
    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader rdr = new XmlBeanDefinitionReader(factory);
    rdr.loadBeanDefinitions(new FileSystemResource(
    Oracle oracle = (Oracle) factory.getBean("oracle");


public interface Oracle {

    public String defineMeaningOfLife();


public class BookwormOracle implements Oracle {

    public String defineMeaningOfLife() {
        return "Encyclopedias are a waste of money - use the Internet";



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
<!-- oracle bean used for a few examples -->
<bean id="oracle" name="wiseworm" class="BookwormOracle"/>

If you want i can also post the maven pom.xml, but i think there is no error all packages are loaded and linked.

I am happy for any hint google and other pages cant help me. Here is a other example what i am trying to do : http://www.devdaily.com/blog/post/java/load-spring-application-context-file-java-swing-application

And even this post Java can't find method main did not help me

Do i have to start this application as Java Application or AspectJ/JavaApplication. Is it not possible to start a console application that way from eclipse ? Do i need to publish my files to a server ( "add to server" but this isnt working too)?

Whats confused me most is, that i see the main method :) and it is the same syntax as any hello world application.

Thanks so far...

I used all the java files and XML files and made it run in my system. It's working perfectly after fixing two errors, Next time when you post the question please do post the exception or the error message which you get.

I got two error's when I ran the project

First Error:

which was related to not having "commons-logging" jar file.

I downloaded the jar file and placed it under the build path.

You can find the solution here. You also need to change your pom.xml

Which will be now,

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

Second Error:

The xmlBeanFactory.xml was refering to a different Spring version. I changed to Spring-2.5.jar and updated my build path.

That's it, now the project runs.