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?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531

2 Answers2

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.

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
  • 2
    The thread [Auto-wiring annotations in classes from dependent jars](http://stackoverflow.com/questions/4936295/auto-wiring-annotations-in-classes-from-dependent-jars) also points out for Ant tasks that the [jar task](http://ant.apache.org/manual/Tasks/jar.html) should have `filesonly` set to false (which is the default). – Scott D. Strader Jul 11 '12 at 13:30
  • 2
    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 :) – Jon Feb 16 '15 at 22:03
0

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

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57