0

So I am having a problem that I know is something stupid that I am forgetting to do. I've used Spring before but using the XML method. But for this I have to use the annotations, the JSR 330 annotations (I have this dependency in my pom.xml).

What I have so far is:

ExampleService.java

package com.example.service.workflow;

@Named
public class ExampleService
{
    @Inject
    private StartService startService;

    ...
}

StartService.java

package com.example.service.workflow;

@Named
public class StartService
{
    ...
    public SvcStatus execute(...)
    {
        ...
    }
}

and then I have this in my sprint-context.xml:

<context:component-scan base-package="com.example.service.workflow" />

However, when I run my program, I am getting a NullPointerException on the startService object, when I try to call the execute() method.

It is not set in stone that I use the JSR 330 annotations. I know that the problem is probably around my use of the @Named annotation, but I have also tried different permutations of @Component, @Service and @Controller.

Using Spring version 4.2.3. Using modules spring-beans and spring-context, and spring-core. I've also tried with all of the spring modules included.

MeanwhileInHell
  • 6,780
  • 17
  • 57
  • 106

0 Answers0