• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Did not find bean NoSuchBeanDefinitionException

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
        Hello!

 





But have got NoSuchBeanDefinitionException: No bean named 'newsController' is defined

 
-2019-07-04-22.51.08.png
[Thumbnail for -2019-07-04-22.51.08.png]
 
Ranch Hand
Posts: 46
Eclipse IDE Slackware Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try "com.model.NewsController" as the class attribute of the bean rather than just "NewsController".
 
Rancher
Posts: 4116
47
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NewsController is not in a package, and so is in the default package.
That causes problems with lots of frameworks.
 
Andrey Dmitriev
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
   Try "com.model.NewsController"

   But without success...
 
Yalvin Duha
Ranch Hand
Posts: 46
Eclipse IDE Slackware Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Andrey Dmitriev wrote:    Try "com.model.NewsController"

   But without success...



The screenshot got me confused. I thought your controller was under src/main/java/com/model.

Create a new package under src/main/java/ and call it, "com.controller". Then move your NewsController in to that package.

Finally, change your newsController to:

   <bean id="newsController"
         class="com.controller.NewsController"/>
 
Andrey Dmitriev
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
     Yalvin Duha,
     I have done as you recommended
     
      But with same result....
-2019-07-09-21.51.35.png
[Thumbnail for -2019-07-09-21.51.35.png]
 
Dave Tolls
Rancher
Posts: 4116
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the xml look like now, and what is the full exception, preferably with the stack trace?
 
Andrey Dmitriev
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 ok

 
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Maybe, try to put your Spring_Config.xml under resource/META_INF/config folder.
After you compile it, make sure under target/classes/META-INFO/config folder has your Spring_Config.xml

I guess the reason why your bean is not found because the Spring_config.xml is not in the target/classes/META-INFO folder.
 
Himai Minh
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Maybe, try to open your Spring_Config.xml file, and see if there is a pop up message telling your to add this config file to the application context. If so, click on it and see.
Then, clean your project and compile it.
I guess your current problem is that the bean is not registered in the application context.
 
Himai Minh
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, do you see a pop up message like the first JPG when you open your Spring_Config.xml?
If so, click on the "Configure application context" link.
Then, you will see a checkbox next to the file path. Click on it , just like my second JPG.
popupwarning.JPG
[Thumbnail for popupwarning.JPG]
checkOnThefile.JPG
[Thumbnail for checkOnThefile.JPG]
 
Andrey Dmitriev
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
   Thank, guys!

   The problem solved.

   The problem was that... I did not marked package "resources" (in which spring-config consisted) as "Resources Root"!

   So, problem was not in code.

   

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!