java - Failure running spring application : NoSuchBeanDefinitionException -


i have trouble running java spring application : main component fr.sgcib.cva.accounting.computation inside accounting.jar.

i trying command :

java -cp spring/*:./*:spring-core-3.1.1.release.jar:spring-context-3.1.1.release.jar:spring-beans-3.1.1.release.jar:log4j-1.2.16.jar:commons-lang3-3.1.jar:commons-logging-1.1.1.jar:spring-asm-3.1.1.release.jar:spring-expression-3.1.1.release.jar:.:accounting.jar fr.sgcib.cva.accounting.computation 3 

the applicationcontext.xml file located in spring/, , looks :

<?xml version="1.0" encoding="utf-8"?>  <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:security="http://www.springframework.org/schema/security" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"  xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd     http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">    <import resource="classpath:spring/persistence.xml"/>  <context:annotation-config /> <context:component-scan base-package="fr.aaa.accounting, com.bbb.access"/>   <util:properties id="jdbcprops" location="jdbc.properties" />     <bean id="propertyconfigurer"     class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">     <property name="locations">         <list>          <value>classpath:configuration.properties</value>          <value>classpath:jdbc.properties</value>         </list>     </property> </bean> 

the main class computation.java :

package fr.aaa.accounting;  @component public class computation { static logger logger = logger.getlogger(computation.class);  @autowired runs runs;  public computation() { }  public run initialize(long runid) {     run run = runs.getrun(runid);     return run; }  public runs getruns() {     return runs; }  public void setruns(runs runs) {     this.runs = runs; }  /**  * @param args  */ public static void main(string[] args) {     long runid = long.parselong(args[0]);     logger.info("running run_id " + runid);      applicationcontext context = new classpathxmlapplicationcontext("classpath*:applicationcontext.xml");     computation computer = context.getbean(computation.class);     /* etc. */ 

}

the console output when running above command :

10:44:41,745 info main fr.aaa.accounting.computation:299 - running run_id 3 10:44:41,872 info main org.springframework.context.support.classpathxmlapplicationcontext:495 - refreshing org.springframework.context.support.classpathxmlapplicationcontext@e0b6f5: startup date [mon mar 10 10:44:41 cet 2014]; root of context hierarchy 10:44:41,979 info main org.springframework.beans.factory.support.defaultlistablebeanfactory:557 - pre-instantiating singletons in org.springframework.beans.factory.support.defaultlistablebeanfactory@ee22f7: defining beans []; root of factory hierarchy exception in thread "main" org.springframework.beans.factory.nosuchbeandefinitionexception: no unique bean of type [fr.aaa.accounting.computation] defined: expected single bean found 0:     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.getbean(defaultlistablebeanfactory.java:271)     @ org.springframework.context.support.abstractapplicationcontext.getbean(abstractapplicationcontext.java:1101)     @ fr.aaa.accounting.computation.main(computation.java:302) 

why can't jvm find bean ?

change line:

 applicationcontext context = new classpathxmlapplicationcontext("classpath*:applicationcontext.xml); 

to this:

  ("classpath:applicationcontext.xml)  // without star 

when using start creating empty application context when file not found.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -