Spring Annotation-based controllers not working if it is inside jar file
Asked Answered
C

2

13

I've some annotation-based controller inside a sub module. These modules are deployed as jar files.

The annotation-based controllers from the jar file is not getting loaded to the spring configuration.

I'm manually exporting the jar file using the export utility in eclipse.

Did any one faced this problem?

Cini answered 7/8, 2009 at 2:57 Comment(0)
C
32

When you export the jar file using the export utility in eclipse there is a option called Add directory entries. Check this option and export the jar file, this will solve the problem.

Cini answered 7/8, 2009 at 2:59 Comment(2)
The thread Auto-wiring annotations in classes from dependent jars also points out for Ant tasks that the jar task should have filesonly set to false (which is the default).Advisable
Wow, this answer concludes a days-long hair-pulling debugging event trying to get spring to work. As a spring newbie, I couldn't figure out why spring couldn't find the beans in jars on the fricken classpath. It could find the same in raw classes, but the moment you put it in a jar, it was like the jar didn't exist. Of course I had completely replicated and enhanced the spring code to find out why it wasn't, and eventually and painfully eliminated every other variable imaginable, so this answer is much appreciated along with the understanding that spring searches via directory entries :)Upbraiding
T
0

Just add base-package to <context:component-scan /> in the root-context.xml file. That's all I needed in my case.

Taskwork answered 12/11, 2021 at 3:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.