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

  • Home
  • SEARCH
  • 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 8655173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:57:49+00:00 2026-06-12T14:57:49+00:00

I am using Spring , i am not using JSF , using ajax etc.

  • 0

I am using Spring, i am not using JSF, using ajax etc.

I have a service

@Service(value="mailService")
public class MailService{
//an autowired dao, etc here
}

I have a bean, i want this bean have one MailService.

//Here i have tried so far individually @Service, @Component, @Controller
public class EmailAgent{

private MailService mailService;



    public MailService getMailService() {
        return mailService;
    }

    @Autowired
    public void setMailService(MailService mailService) {
        this.mailService = mailService;
    }

}

I have below in applicationContext.xml

<context:component-scan base-package="mypack.containing.emailagent.path.too" />
<context:annotation-config/>

mailService in EmailAgent is null on calling one EmailAgent method.

I request some advise, and i want to understand why i do not get any exception during server starting up, like, “i could not autowire mailService”. Awhile ago i was using JSF and i was be able to see such warning while server start up.

PROBLEM IS SPECIFIED, HOW TO SOLVE

i was generating ea with EmailAgent ea=new EmailAgent();
It is my sillyness but,
when i try to get one context like:

ClassPathXmlApplicationContext cont=new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
                  mailService=()cont.getBean("mailService");

i am faced with the problem non unique cache etc, problems about generating one more context.
So how can i “get” context, preventing “generating” one more?

SOLVED

I added

<bean class="email.EmailService" id="emailService"> 
  <dwr:remote javascript="emailService"> 
    <dwr:include method="sendMail"/>
    <dwr:include method="readAllMails"/>
    <dwr:include method="removeMailsById"/> 
  </dwr:remote> 
</bean> 

to dwr.xml and deleted annotation from emailService about dwr.

dwr s and spring s annotations were really conflicting as i can see.

Thanks to @NimChimpsky for idea on detecting the problem.

  • 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-06-12T14:57:50+00:00Added an answer on June 12, 2026 at 2:57 pm

    You don’t need another context, unless you are integration testing.

    Where is emailagent being used ? Just inject it as normal there. As you do with mailservice.

    You can annotate it with Component or Service, both are appropriate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Form is not giving value on controller for sql.date i am using spring and
I am preparing a registration page using JSF/Spring webflow&mvc application. I have added two
I am using jsf and spring together in web application. I have configured datasource
i am using hibernate validation (4.2.0 Final) with JSF 2 and Spring and here's
I'm using Glassfish 3.1.1 and JSF 2.0: I have the following code: public String
I'm using Spring to handle security in my JSF application. I have a login
I am using Spring managed JSF beans, now do i have to use annotation
Do anyone know a way to make: com.mchange.v2.c3p0.management.ManagementCoordinator=com.mchange.v2.c3p0.management.NullManagementCoordinator using Spring and not a c3p0.properties
I am using JSF 2.0, tomahawk, and some f:ajax thing in my development. I
I'm doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate

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.