bsautner
bsautner

Reputation: 4802

jetty spring "No resource at X" ResourceAnnotationHandler

I have a java webapp that works just fine, but today I tried to start using spring for dependency injection. The app should run on Jetty Server but i'm stuck on this problem.

When I try to use any servlets that contain a spring dependency, I get this error:

java.lang.IllegalStateException: No resource at valueService
    at org.eclipse.jetty.annotations.ResourceAnnotationHandler.handleMethod(ResourceAnnotationHandler.java:345)
    at org.eclipse.jetty.annotations.ResourceAnnotationHandler.doHandle(ResourceAnnotationHandler.java:66)
    at org.eclipse.jetty.annotations.AnnotationIntrospector$AbstractIntrospectableAnnotationHandler.handle(ResourceAnnotationHandler.java:345)

valueService is the name of the first dependency in the HttpServlet annotated with spring like this:

@Resource(name="valueService")
protected ValueService valueService;

which is defined in my application context as:

<bean id="valueService" class="com.nimbits.server.transaction.value.service.ValueServiceImpl" />

So, jetty is open source, so when I look at the code in jetty server ResourceAnnotationHandler.java:345 it's doing this:

else if (!Util.isEnvEntryType(paramType))
               {

                        //if this is an env-entry type resource and there is no value bound for it, it isn't
                        //an error, it just means that perhaps the code will use a default value instead
                        // JavaEE Spec. sec 5.4.1.3
                        throw new IllegalStateException("No resource at "+(mappedName==null?name:mappedName));
                    }

so there is my error. Question: any jetty experts know why jetty is processing my spring annotation and throwing this exception. Is there a way to satisfy it? Or stop it?

Thanks, really stuck.

Ben

Upvotes: 1

Views: 309

Answers (1)

bsautner
bsautner

Reputation: 4802

@Resource(name="valueService")
protected ValueService valueService; 

made jetty unhappy

switching to:

@Autowired
protected ValueService valueService; 

resolved it

Upvotes: 1

Related Questions