• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

No bean named 'JDBCDAOImpl' is defined - Exception

 
Ranch Hand
Posts: 460
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ranchers,

I faces with one issue:

I created one app using NetBeans 8.2 to learn Spring DataAccess.

My  spring.xml



My main class is:

}


My users1 class is:





and my JDBCDAOImp class is:





When I try to run my project surprise:

Aug 30, 2017 2:01:32 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@443b7951: startup date [Wed Aug 30 14:01:32 EEST 2017]; root of context hierarchy
Aug 30, 2017 2:01:32 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring.xml]
Aug 30, 2017 2:01:32 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2a5ca609: defining beans [dataSource]; root of factory hierarchy
Aug 30, 2017 2:01:33 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: org.apache.derby.jdbc.ClientDriver
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'JDBCDAOImpl' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:570)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1114)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:279)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1121)
at readfromdatabasespring.ReadFromDatabaseSpring.main(ReadFromDatabaseSpring.java:24)
BUILD SUCCESSFUL (total time: 1 second)


Can someone help me?

I am using Spring Framework 3.2.7.

Thanks a lot,





 
Dana Ucaed
Ranch Hand
Posts: 460
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I modified my spring.xml so:



ans surprise:

my exception is:

java.lang.NullPointerException
at readfromdatabasespring.JDBCDAOImpl.getUser(JDBCDAOImpl.java:40)
at readfromdatabasespring.ReadFromDatabaseSpring.main(ReadFromDatabaseSpring.java:27)
java.lang.NullPointerException
at readfromdatabasespring.JDBCDAOImpl.getUser(JDBCDAOImpl.java:59)
at readfromdatabasespring.ReadFromDatabaseSpring.main(ReadFromDatabaseSpring.java:27)

means that my dataSource from my xml is not recognized.

 
Ranch Hand
Posts: 441
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now, you are getting NullPointerException. Run the following query on DB:

SELECT ID, NAME, Email FROM APP.USERS1 where ID = ?

for given ID and check if there are any rows returned?
 
Dana Ucaed
Ranch Hand
Posts: 460
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I resolved.

My issue was from Spring.xml.

This is corect file.





reply
    Bookmark Topic Watch Topic
  • New Topic