Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6055135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:13:51+00:00 2026-05-23T08:13:51+00:00

Please look at the files below and tell me why the Dao will not

  • 0

Please look at the files below and tell me why the Dao will not autowire. It autowires correctly when the same setter is put in a controller. I put it in this class and it does not work.

Business Class

@Component
public class AuthenticateUser {

    @Autowired
    private SecurityDAO securityDAO;

    public void setSecurityDAO(SecurityDAO securityDAO) {
        this.securityDAO = securityDAO;
    }

    protected void execute() {          
        User authenticatedUser = securityDAO.login(get_userName(),
                                                   get_password());     
    }
}

application-context.xml

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    <bean id="myDataSource" 
    class="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
      <property name="driverClassName">
        <value>com.mysql.jdbc.Driver</value>
      </property>
      <property name="url">
        <value>jdbc:mysql://localhost/dbname</value>
      </property>
      <property name="username">
        <value>un</value>
      </property>
      <property name="password">
        <value>pw</value>
      </property>
      <!-- Disable the second-level cache  -->
        <!-- Echo all executed SQL to stdout -->
    </bean>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="myDataSource" /> 
        <property name="annotatedClasses">
            <list>
            <value>com.projectname.model.SecurityInfo</value>
            <value>com.projectname.model.User</value>
            <value>com.projectname.model.Post</value>
            <value>com.projectname.model.Article</value>
            <value>com.projectname.model.Address</value>
            </list>
        </property> 
        <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
        </property>
    </bean>


    <bean id="mySecurityInfoDAO" class="com.projectname.dao.SecurityDAOImpl">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

    </beans>

spring-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:annotation-config />
<context:component-scan
    base-package="com.projectname" />
<bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/WEB-INF/views/" />
    <property name="suffix" value=".jsp" />
</bean>

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basenames">
        <value>/WEB-INF/messages/messages</value>
    </property>
    <property name="cacheSeconds" value="60" />
    <property name="defaultEncoding" value="UTF-8" />
</bean>
</beans>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:13:54+00:00Added an answer on May 23, 2026 at 8:13 am

    Let my guess: AuthenticatedUser is a Domain Entity?

    Spring can only handle Spring Beans, and can only inject in Spring Beans.

    If you have a class that is instantiated in a Pojo way by new (or loaded form the database by Hibernate/JPA,…) it does not become a Spring Bean.

    But you can make even this Pojos become Spring Beans. You need 3 things:

    • add @Configurable to the Entity
    • turn on Spring Configurable support:
    • enable AspectJ (AspectJ not Spring AOP) – compiletime or loadtime weaving. — If you use compiletime weaving you need to use an AspectJ Compiler

    @See:

    • Spring Reference: Chapter 7.8.1 Using AspectJ to dependency inject domain objects with Spring
    • Using Spring’s @Configurable in three easy steps
    • Spring, Aspects, @Configurable and Compile Time Weaving using maven
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please look at the two examples below: irb(#<ActionView::Base:0x2863d58>):030:0> paintings_path => /some-nice-alias-path irb(#<ActionView::Base:0x2863d58>):029:0> self.controller_name.to_s +
Please look at the below code snippet and let me know how the out
Please look at this fiddle: http://jsfiddle.net/dyv88/16/ On IE7, if I put width: 100% on
Please look through code below: // A.class File file = new File(blah.txt); FileWriter fileWriter
please look at the simple php webpage code below how can modify my code
Please look at the image below. Right now I am doing this with a
Please look at the code below. void func() { for(;;) { var item =
Please help me to understand the following issue. Look at the code example below:
Please look the following query: SELECT ID, START, END FROM TABLEA the result is:
please look at this example of drop down checkbox list im working on.. http://jsfiddle.net/Yojik/VJHVK/143/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.