0

I have businesskeys.properties file which keeps codes like 910000=terminalAliveCommand etc. My application sends message to pos device and receives message from pos device. In xml I defined bean for this terminalAliveCommand:

<bean id="terminalAliveCommand" class="sinaps.domain.TerminalAliveCommand" scope="prototype">
        <property name="sinapsDao" ref="sinapsDAO" />
    </bean>



   org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '910000' is defined 
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:527) 
        at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1068) 
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274) 
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
        at org.springframework.beans.factory.config.ServiceLocatorFactoryBean$ServiceLocatorInvocationHandler.invokeServiceLocatorMethod(ServiceLocatorFactoryBean.java:368) 
        at org.springframework.beans.factory.config.ServiceLocatorFactoryBean$ServiceLocatorInvocationHandler.invoke(ServiceLocatorFactoryBean.java:357) 
        at $Proxy12.getBusinessCommand(Unknown Source) 
        at sinaps.dispatching.SpaceProcessor.run(SpaceProcessor.java:21) 
        at sinaps.dispatching.SpaceProcessor$$FastClassByCGLIB$$5b80d863.invoke(<generated>) 
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191) 
        at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688) 
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
        at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50) 
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
        at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50) 
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) 
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
        at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621) 
        at 
sinaps.dispatching.SpaceProcessor$$EnhancerByCGLIB$$74ad957a.run(<generated>) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
        at java.lang.Thread.run(Thread.java:662)

I have spaceProcessor class which processes the request process by business code :

import org.apache.commons.lang.exception.ExceptionUtils;
import org.jpos.iso.ISOException;
import org.jpos.util.LogEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import sinaps.domain.exceptions.BusinessException;
import sinaps.util.StringUtil;

@SuppressWarnings("rawtypes")
public class SpaceProcessor extends ProcessorSupport {

    private static final Logger LOGGER = LoggerFactory.getLogger(SpaceProcessor.class);

    @SuppressWarnings("unchecked")
    @Override
    public void run() {
        //LogEvent event = new LogEvent(this, "POSPROCESSEVENT");
        try {
            responseSpace.out(responseQueue, servicelocator.getBusinessCommand(msg.getString(3)).doCommand(msg));

        } catch (BusinessException e) {
            LOGGER.error(e.getMessage());
            LOGGER.error(ExceptionUtils.getStackTrace(e));
            try {
                msg.setResponseMTI();
                msg.set(39, (StringUtil.nullToEmpty(e.getResponseCode()).length() > 2 ? e.getResponseCode().substring(0, 2) : e.getResponseCode()));
            } catch (ISOException e1) {
                LOGGER.error(e1.getMessage());
                e1.printStackTrace();
            }
            responseSpace.out(responseQueue, msg);
        }

    }
}

Does anybody have an idea why I am getting this error?

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
kraskixxx
  • 89
  • 8
  • What configuration are you using to load properties? – geoand Mar 24 '14 at 12:43
  • 1
    Actually we don't see code, where you convert `910000` to the `terminalAliveCommand` from `businesskeys.properties` before your `servicelocator` tries to get real object from application context – Artem Bilan Mar 24 '14 at 12:46
  • What is ```servicelocator```? Seems that the problem lies in ```servicelocator.getBusinessCommand(msg.getString(3))```. I am guessing: this method loads bean from context using code (in your example 91000) where it should first get bean name corresponding to this code from your properties file. – Maciej Walkowiak Mar 24 '14 at 12:49
  • public interface SinapsServiceLocator { BusinessCommand getBusinessCommand(String businessCommandKey); } – kraskixxx Mar 24 '14 at 12:54

0 Answers0