spring - Component Scan not finding @Component's in a JAR in Tomcat webapp -


i filed bug in spring bugsystem ( https://jira.springsource.org/browse/spr-8551 ), still unsure if missing something

i tracked down problem <context:component-scan/> statement. given 2 following classes in same jar in web-inf/lib of web application (the jar file has directory structure):

test/thebean.java:

package test; @component public class thebean{ } 

test/beansearcher.java:

package test; public class beansearcher{    public void init(){      annotationconfigapplicationcontext ctx = new annotationconfigapplicationcontext();      ctx.scan("test");      ctx.refresh();      thebean b=  ctx.getbean(thebean.class);      // value of b?    } } 

if run new beansearcher().init() in junit test case or other type of standalone application, b getting assigned instance of thebean, if run it, say, in jsp, ctx.getbean() returning null.

so, doing wrong or not taking account, bug...?

edit 8/8/2011: seems work tried simplify problem, still, when try make work, in initialization of opencms, fails. trying differences between working versions , 1 doesn't work. (classloader, ubication of relevant classes in different jars or directly in web-inf/classes, calls via reflection, etc.)

as wrote in comment, solution given answer here: spring annotation-based controllers not working if inside jar file

when export jar file using export utility in eclipse there option called add directory entries.


Comments

Popular posts from this blog

jQuery Ajax Render Fragments OR Whole Page -

javascript - Iterate over array and calculate average values of array-parts -

java - Simple Command Line calculator -