java - using @Controller, @Service, and @Inject in Spring MVC -


i had working controller had 1 service, shown below.

@controller public class filecontroller  {    private fileservice   fileservice;       // service injected spring     /**     * constructor initializes file service.     * @param fileservice     service used retrieve list of files     */    @inject    public filecontroller(fileservice fileservice)    {       this.fileservice = fileservice;    }     ... } 

similarly, had service, had working , in use in controller.

@controller public class searchcontroller  {    private searchservice searchservice;       // service injected  spring     /**     * constructor initializes search service.     * @param searchservice     service used search items     */    @inject    public searchcontroller(searchservice searchservice)    {       this.searchservice = searchservice;    }     ... } 

both services , controllers working fine.

then, during development, turned out filecontroller needed search service well, , modified filecontroller shown below.

@controller public class filescontroller {    // data members    private fileservice   fileservice;       // service injected spring    private searchservice searchservice;     // service injected spring     /**     * constructor initializes file service.     * @param fileservice     service used retrieve list of files     * @param searchservice   service used retrieve list of items.     */    @inject    public filescontroller(fileservice fileservice, searchservice searchservice)    {       this.fileservice   = fileservice;       this.searchservice = searchservice;    }    ... } 

this compiles fine , deploys fine, when access view uses filecontroller, blows spring error:

org.springframework.beans.factory.beancreationexception: error creating bean name 'org.springframework.web.servlet.mvc.annotation.defaultannotationhandlermapping#0': initialization of bean failed; nested exception org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'filescontroller' defined in file [c:\rw_apps\tomcat\6.0.43-2\webapps\webquery\web-inf\classes\com\rockwell_collins\webquery\controller\filescontroller.class]: unsatisfied dependency expressed through constructor argument index 1 of type [com.rockwell_collins.webquery.service.searchservice]: : error creating bean name 'searchservice' defined in file [c:\rw_apps\tomcat\6.0.43-2\webapps\webquery\web-inf\classes\com\rockwell_collins\webquery\service\searchservice.class]: instantiation of bean failed; nested exception java.lang.exceptionininitializererror; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'searchservice' defined in file [c:\rw_apps\tomcat\6.0.43-2\webapps\webquery\web-inf\classes\com\rockwell_collins\webquery\service\searchservice.class]: instantiation of bean failed; nested exception java.lang.exceptionininitializererror

is spring able inject 1 service controller? i've tried specifying "default-autowire" in spring xml file , tried every possible value it, nothing works.

how searchservice looks like? have static block there?

exceptionininitializererror 'signals unexpected exception has occurred in static initializer'


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -