1
votes

I have a Spring JMS project managed via maven, I encounter the following issue when the deployment of the jar file (java -jar jarname.jar):

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'outgoingMessageEventListener' defined in class path resource [deltaMessageListenerContainer.xml]: Cannot resolve reference to bean 'deltaBankMessageService' while setting bean property 'deltaBankMessageService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deltaBankMessageService' defined in class path resource [data-access.xml]: Cannot resolve reference to bean 'messageOutDao' while setting bean property 'messageOutDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageOutDao' defined in class path resource [data-access.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.delta.jms.message.persistence.ibatis.SqlMapMessageOutDao]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/ibatis/sqlmap/client/SqlMapExecutor at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308) at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:947) at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:701) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:377) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93) at com.delta.jms.server.bootstrap.Startup.main(Startup.java:26) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deltaBankMessageService' defined in class path resource [data-access.xml]: Cannot resolve reference to bean 'messageOutDao' while setting bean property 'messageOutDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageOutDao' defined in class path resource [data-access.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.delta.jms.message.persistence.ibatis.SqlMapMessageOutDao]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/ibatis/sqlmap/client/SqlMapExecutor at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) ... 19 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageOutDao' defined in class path resource [data-access.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.delta.jms.message.persistence.ibatis.SqlMapMessageOutDao]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/ibatis/sqlmap/client/SqlMapExecutor at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) ... 32 more Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.delta.jms.message.persistence.ibatis.SqlMapMessageOutDao]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/ibatis/sqlmap/client/SqlMapExecutor at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877) ... 43 more Caused by: java.lang.NoClassDefFoundError: com/ibatis/sqlmap/client/SqlMapExecutor at org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.(SqlMapClientDaoSupport.java:46) at com.delta.jms.message.persistence.ibatis.SqlMapMessageOutDao.(SqlMapMessageOutDao.java:23) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100) ... 45 more Caused by: java.lang.ClassNotFoundException: com.ibatis.sqlmap.client.SqlMapExecutor at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 52 more

Thank you.

Mac


Thank you Ronald. I have this new error now :

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'outgoingMessageEventListener' defined in class path resource [deltaMessageListenerContainer.xml]: Cannot resolve reference to bean 'deltaBankMessageService' while setting bean property 'deltaBankMessageService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deltaBankMessageService' defined in class path resource [data-access.xml]: Cannot resolve reference to bean 'jmsSender' while setting bean property 'jmsSender'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsSender' defined in class path resource [jmsConnectionFactory.xml]: Cannot resolve reference to bean 'jmsQueueTemplate' while setting bean property 'jmsTemplate102'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsQueueTemplate' defined in class path resource [jmsConnectionFactory.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/jms/JMSException at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308) at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:947) at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:701) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:377) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93) at com.delta.jms.server.bootstrap.Startup.main(Startup.java:26) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deltaBankMessageService' defined in class path resource [data-access.xml]: Cannot resolve reference to bean 'jmsSender' while setting bean property 'jmsSender'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsSender' defined in class path resource [jmsConnectionFactory.xml]: Cannot resolve reference to bean 'jmsQueueTemplate' while setting bean property 'jmsTemplate102'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsQueueTemplate' defined in class path resource [jmsConnectionFactory.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/jms/JMSException at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) ... 19 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsSender' defined in class path resource [jmsConnectionFactory.xml]: Cannot resolve reference to bean 'jmsQueueTemplate' while setting bean property 'jmsTemplate102'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsQueueTemplate' defined in class path resource [jmsConnectionFactory.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/jms/JMSException at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) ... 32 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsQueueTemplate' defined in class path resource [jmsConnectionFactory.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/jms/JMSException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) ... 45 more Caused by: java.lang.NoClassDefFoundError: javax/jms/JMSException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493) at java.lang.Class.getConstructor0(Class.java:2803) at java.lang.Class.getDeclaredConstructor(Class.java:2053) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877) ... 56 more Caused by: java.lang.ClassNotFoundException: javax.jms.JMSException at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 62 more

3

3 Answers

3
votes

Looks You are missing some dependency jars. When I get such errors I always do

  1. Search(Google) for the jar that contains the missing class, in your case com.ibatis.sqlmap.client.SqlMapExecutor

  2. add the jar into your maven pom.xml dependency

Notice also that, sometimes if you have two versions of the same jar somewhere in your class path might give you this issue. In this scnerio, you can turn on the verbose mode to see which version picked up during runtime

2
votes

Apparently you don't have com.ibatis.sqlmap.client.SqlMapExecutor on your classpath. You're using maven as your build tool, so check your POM for dependencies.

I do not know which depenceny you actually need, but it should be something like this:

<dependency>
    <groupId>org.apache.ibatis</groupId>
    <artifactId>ibatis-sqlmap</artifactId>
    <version>2.3.0</version>
</dependency>
0
votes

I want to thank you, Ronald and Yohannes, for your help! Actually, I did find the MAIN PROBLEM! I was making some dependencies in pom.xml as system and I put the absolute path of these jar files in tag. When I package the project as an executable jar file it doesn't take those dependencies inside! So to avoid that, I uploaded these specific jars into a Nexus server (I have already one) and I declare them as scope compile in pom.xml, that's all! I overcame these "dependencies" errors but I've got another kind of errors!