• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Bean definition found but not found

 
Ranch Hand
Posts: 68
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure whether this is the right section for my question because I am not sure what is happening.

I have a project using Spring that gives some very confusing output. When I run the project in NetBeans with Maven it outputs

Which sound like it has read and understood my bean definitions in spring-config.xml.

The next line then has me somewhat confused

Suddenly it cannot find spring-config.xml, but it has just read the file without problems.

Looking at the complete stacktrace indicates that it is the second of these two lines that cause the exception, and I suspect that it is the first the loads the file without problems.


Can anybody explain to me what is happening here?
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Philip Grove wrote:

Which sound like it has read and understood my bean definitions in spring-config.xml.


No.. Spring is just telling you that, it is trying to load the xml bean definitions from the file, which you have specified as it's present in classpath..
In the next line, it tells you that it can't read the file, because its not present..
Nothing confusing here, its pretty straight forward..
Where you have placed your spring-config.xml file... ?
 
Philip Grove
Ranch Hand
Posts: 68
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The spring-config.xml has been placed by NetBeans in the folder containing the source of main package. It's in the folder src/main/java/dk/evorg/game under the project folder.
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
then you should be giving new ClassPathResource("dk/evorg/game/spring-config.xml"); If you just give spring-config.xml, it expects to be in the default package.
 
Philip Grove
Ranch Hand
Posts: 68
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That results in exactly the same error message.
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you just take that xml file and put in the default package and check?
 
Philip Grove
Ranch Hand
Posts: 68
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The same file in the default package works just fine. It just might stay in the default folder because it makes sense to me that a configuration file is located in src/main/resources.
 
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

Philip Grove wrote:The same file in the default package works just fine. It just might stay in the default folder because it makes sense to me that a configuration file is located in src/main/resources.



Yes, I agree it makes more sense. I always put my config files in the root of the classpath, and maven copies anything in the resources directory to the classpath.

Mark
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am having the same issue.

This is my first spring

INFO - Loading XML bean definitions from class path resource [carDemo-beans.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [carDemo-beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [carDemo-beans.xml] cannot be opened because it does not exist.


I see the above message in console. But I have initially created carDemo-beans.xml, placed in the package com/vehicles. Since I ws getting the above msg I have added the beans xml file to class path
by using add to build path option. After doing this, xml file was present at the referenced libraries section. Still I get the same error.

Regards
Larsen
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic