问题
I have a Spring JMS project managed with Maven. When I run the project via Eclipse everything goes well, but when I launch it from the executable jar file I got the following error :
INFO - Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@12911b4f:
defining beans
[jmsBridgeServer,messageFrameStreamReader,outgoingMessageEventListener,serverLifecycleEventListener,jmsQueueConnectionFactory,jndiTemplate,jmsQueueTemplate,jmsDestinationResolver,jmsSender,meridianMessageConverter,dataSource,transactionManager,sqlMapClient,messageInDao,messageOutDao,jparametrageDao,sequenceDao,deltaBankMessageService,parametrageService,org.springframework.jms.listener.DefaultMessageListenerContainer102#0,org.springframework.jms.listener.DefaultMessageListenerContainer102#1,deltaMessageListener,incomingMessageEventListener,org.springframework.beans.factory.config.PropertyOverrideConfigurer#0,fglConnector,connectionFactory,rmiRegistry,exporter,attributeSource,assembler,namingStrategy,serverConnector];
root of factory hierarchy 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]: Cannot resolve reference to bean
'jmsQueueConnectionFactory' while setting bean property
'connectionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'jmsQueueConnectionFactory' defined in class
path resource [jmsConnectionFactory.xml]: Invocation of init method
failed; nested exception is javax.naming.NamingException: unexpected
exception [Root exception is java.lang.NullPointerException];
remaining name 'WMQConnectionFactory' 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.<init>(ClassPathXmlApplicationContext.java:139)
at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(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]: Cannot resolve reference to bean
'jmsQueueConnectionFactory' while setting bean property
'connectionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'jmsQueueConnectionFactory' defined in class
path resource [jmsConnectionFactory.xml]: Invocation of init method
failed; nested exception is javax.naming.NamingException: unexpected
exception [Root exception is java.lang.NullPointerException];
remaining name 'WMQConnectionFactory' 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]: Cannot resolve reference to bean
'jmsQueueConnectionFactory' while setting bean property
'connectionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'jmsQueueConnectionFactory' defined in class
path resource [jmsConnectionFactory.xml]: Invocation of init method
failed; nested exception is javax.naming.NamingException: unexpected
exception [Root exception is java.lang.NullPointerException];
remaining name 'WMQConnectionFactory' 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]: Cannot resolve reference to bean
'jmsQueueConnectionFactory' while setting bean property
'connectionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'jmsQueueConnectionFactory' defined in class
path resource [jmsConnectionFactory.xml]: Invocation of init method
failed; nested exception is javax.naming.NamingException: unexpected
exception [Root exception is java.lang.NullPointerException];
remaining name 'WMQConnectionFactory' 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)
... 45 more Caused by:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'jmsQueueConnectionFactory' defined in class
path resource [jmsConnectionFactory.xml]: Invocation of init method
failed; nested exception is javax.naming.NamingException: unexpected
exception [Root exception is java.lang.NullPointerException];
remaining name 'WMQConnectionFactory' at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
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)
... 58 more Caused by: javax.naming.NamingException: unexpected
exception [Root exception is java.lang.NullPointerException];
remaining name 'WMQConnectionFactory' at
com.sun.jndi.fscontext.FSContext.generateNamingException(FSContext.java:806)
at com.sun.jndi.fscontext.RefFSContext.lookup(RefFSContext.java:149)
at com.sun.jndi.fscontext.FSContext.lookup(FSContext.java:127) at
javax.naming.InitialContext.lookup(InitialContext.java:411) at
org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
at
org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:88)
at
org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:153)
at
org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
at
org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at
org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
at
org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:200)
at
org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:186)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 68 more Caused by: java.lang.NullPointerException at
com.ibm.msg.client.jms.internal.JmsFactoryFactoryImpl.getInstance(JmsFactoryFactoryImpl.java:170)
at
com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.setProviderFactory(JmsConnectionFactoryImpl.java:167)
at
com.ibm.mq.jms.MQConnectionFactory.<init>(MQConnectionFactory.java:271)
at
com.ibm.mq.jms.MQQueueConnectionFactory.<init>(MQQueueConnectionFactory.java:72)
at
com.ibm.mq.jms.MQQueueConnectionFactoryFactory.getObjectInstance(MQQueueConnectionFactoryFactory.java:69)
at
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at com.sun.jndi.fscontext.RefFSContext.lookup(RefFSContext.java:146)
... 80 more
Here it is the pom dependencies:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>2.5.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>2.5.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>2.5.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>2.5.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>2.5.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>com.ibm.mq</artifactId>
<version>8.0</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>com.ibm.mqjms</artifactId>
<version>8.0</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>com.ibm.mq.jmqi</artifactId>
<version>8.0</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>com.ibm.disthub2</artifactId>
<version>DH610-GOLD</version>
</dependency>
<dependency>
<groupId>com.sun.jndi</groupId>
<artifactId>jndi</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>com.sun.jndi</groupId>
<artifactId>fscontext</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.sun.jndi</groupId>
<artifactId>providerutil</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.ibatis</groupId>
<artifactId>ibatis</artifactId>
<version>2.3.4.726</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.0.1B</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/config/</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources/</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>datasource.xml</exclude>
<!-- <exclude>jmsConnectionFactory.xml</exclude> -->
<exclude>server.xml</exclude>
<exclude>mq_setup.sql</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.delta.jms.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>com.delta.jms.server.bootstrap.Startup</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
来源:https://stackoverflow.com/questions/42623745/javax-naming-namingexception-unexpected-exception-root-exception-is-java-lang