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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:34:48+00:00 2026-06-13T04:34:48+00:00

I am working on application which contains few sub modules. On one of these

  • 0

I am working on application which contains few sub modules. On one of these modules I have service with header like this:

@Transactional
@Service("mySimpleService")
public class MySimpleServiceImpl implements MySimpleService {}

On the another module I have a controller in which I would like to use one of the MySimpleService method. So I have something similar to this:

@Controller
public class EasyController {    

    @Autowired
    private MySimpleService mySimpleService;

    @RequestMapping("/webpage.htm")
    public ModelAndView webpage(@RequestParam,
                                @RequestParam,
                                HttpServletRequest request,
                                HttpServletResponse response) {
        ModelAndView mav = new ModelAndView(”webpage”);
        mav.addObject(”name”, mySimpleService.getObject());
        return mav;
    }
}

On the line mav.addObject(”name”, mySimpleService.getObject()); I am getting NullPointerException. I don’t know why. I am not getting error similar to Could not autowire field but only NullPointerException.

I have also created my own interceptor in this way to check some another ideas in my task:

public class CustomInterceptor extends HandlerInterceptorAdapter {

    @Autowired
    private MySimpleService mySimpleService;

    @Override
    public boolean preHandle(HttpServletRequest request, 
                             HttpServletResponse response,
                             Object handler)
                             throws Exception {         
        request.setAttribute("attr", mySimpleService.getAttribute());
        return true;
    }    
}

This interceptor is of course declared in dispatcher servlet. In my logs I can see NullPointerException at line: request.setAttribute("attr", mySimpleService.getAttribute());. So this is exactly problem with getting access to service from another application module.

How can I achieve this?

I have heard about ideas like building EJB with my service and share it using JNDI or using Maven – copy folder with my service to target module during building application. I have tried to do the second option but it isn’t working and I can’t check if the coping was successful. Is possible to check Maven based solution? Do you have another suggestions?

EDIT

This is component scaning from target module dispatcher servlet:

<context:component-scan base-package="my.package.target.module.controller" annotation-config="false"/>
  • 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-13T04:34:49+00:00Added an answer on June 13, 2026 at 4:34 am

    I think your problem is the annotation-config=”false”. The annotation-config feature is what turns on the @Autowired annotation. Without auto-wiring, your mySimpleService properties do not get injected and remain null. Then you get the NullPointerException.

    Try

    <context:component-scan base-package="my.package.target.module.controller" annotation-config="true"/>
    

    BTW – I have never used this exact configuration, since I don’t do scanning. I always use the separate element:

    <context:annotation-config />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am working on a application, which contains one switch. When we touch
I have created one application which contains several buttons to home page clicking on
I have a simple struct which contains GUI controls in an application I'm working
I'm working on a C# application that contains a lot of DataGridViews which are
I'm working on an application so i have write an dll which contain a
i am working on one application which requires the feature of adding the custom
We are working on an application which processes PDF documents. One of the features
I am working on an application which starts as a service but only if
i have written a small form application, which contains textbox only. I have enabled
I'm creating a Flex 4 application which contains different modules in it. The main

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.