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 6641387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:48:18+00:00 2026-05-25T23:48:18+00:00

I am having some trouble with setting up my Spring environment properly. In my

  • 0

I am having some trouble with setting up my Spring environment properly. In my applicationContext.xml I have:

...
<context:annotation-config />
<context:component-scan base-package="com.company.server" />

<import resource="databaseConfig.xml" />

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:config.properties</value>
        </list>
    </property>
</bean>

and in my databaseConfig:

<tx:annotation-driven />

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass">
        <value>${jdbc.driver.className}</value>
    </property>
    <property name="jdbcUrl">
        <value>${jdbc.url}</value>
    </property>
    <property name="user">
        <value>${jdbc.username}</value>
    </property>
    <property name="password">
        <value>${jdbc.password}</value>
    </property>
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource">
        <ref bean="dataSource" />
    </property>
    <property name="packagesToScan" value="org.adit.spring.hibernate.entity" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${jdbc.hibernate.dialect}</prop>
            <prop key="hibernate.hbm2ddl.auto">create</prop>
            <prop key="hibernate.show_sql">false</prop>
        </props>
    </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>

Now my problem starts. If you look at the following class:

@Service
public class ViewContactsServiceImpl extends RemoteServiceServlet implements ViewContactsService {

    private ContactDao contactDao;

    @Autowired
    public void setContactDao(ContactDao contactDao) {
        this.contactDao = contactDao;
    }

    @Override
    public ArrayList<Contact> getAllContacts() {
        return contactDao.getAllContacts();
    }
}

During application startup everything is fine. Spring does not complain that it cannot create the bean or that it cannot inject the property. However, whenever I try to access the contactDao field, it is null.

Thanks!


UPDATE

I should also mention my ContactDaoImpl.java is defined as:

@Repository("contactDao")
@Transactional
public class ContactDaoImpl implements ContactDao { ... }

UPDATE 2

NB. This is a GWT application.

ViewContactServiceImpl.java:

package com.company.server.service.viewcontacts;

ViewContactsService.java:

package com.company.client.viewcontacts;

ContactDaoImpl.java

package com.company.server.contact;

ContactDao.java

package com.company.server.contact;
  • 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-25T23:48:18+00:00Added an answer on May 25, 2026 at 11:48 pm

    I thins ViewContactsServiceImpl is being instantiated by GWT (guessing based on RemoteServiceServlet) – so it is not spring managed bean.

    You need to invoked auto-wire manually by overriding and implementing the init method. Similar to the code shown below (from this article). As explained in that article create an AbstractRemoteServlet that all your GWTService can extend.

    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        WebApplicationContext ctx = WebApplicationContextUtils
                .getRequiredWebApplicationContext(config.getServletContext());
        AutowireCapableBeanFactory beanFactory = ctx
                .getAutowireCapableBeanFactory();
        beanFactory.autowireBean(this);
    }
    

    Look at GWT-SL library for another approach to exposing spring managed beans as GWT remote services.

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

Sidebar

Related Questions

I am having trouble setting up jpa mappings for some entities. I have a
I am having some trouble setting up my environment in Eclipse for ImageMagick via
I'm having some trouble setting the ExecutionTimeout element in my applications web.config. My page
I'm having some trouble setting up a htaccess file. Currently I have 15 domains
I am having some trouble setting the DJANGO_SETTINGS_MODULE for my Django project. I have
Im having some trouble writing a getstring function, this is what I have so
I am having some trouble with the Google Maps API . I have an
I'm having some trouble with setting the where clause of the following query: CriteriaBuilder
I'm having some trouble uploading images to my server via RestSharp. I have a
I am having some trouble setting up FancyBox, I am somewhat new to jQuery.

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.