I have started my migration of spring version from 4.3.29.RELEASE to 5.3.29 I have fixed some of the issues with servlet and AbstractClientHttpRequest files but I was facing some issue with .binding files, I see they were loading as part of application context after migrating the spring version to 5.3.19 , with the older version of Spring 4.3.29.RELEASE I was able to bring up my application with out any issues. Now with 5.3.19 when I start my application I am getting below issue.
[org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ActionMgmtDAO': Unsatisfied dependency expressed through field 'testEditorService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testEditorService': Unsatisfied dependency expressed through field 'testnMessagePublisher'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testnMessagePublisher' defined in class path resource [config/test-queue-config.xml]: Cannot resolve reference to bean 'jmsTemplate' while setting bean property 'jmsTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsTemplate' defined in class path resource [config/test-queue-config.xml]: Cannot resolve reference to bean 'connectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactory' defined in class path resource [config/test-queue-config.xml]: Cannot resolve reference to bean 'testConnectionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testConnectionFactory' defined in class path resource [config/test-queue-config.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [UM_QMGR_QCF] is not bound in this Context. Unable to find [UM_QMGR_QCF].
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'umConnectionFactory' defined in class path resource [config/um-queue-config.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [UM_QMGR_QCF] is not bound in this Context. Unable to find [UM_QMGR_QCF].
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'trentonToTestQueue' defined in class path resource [config/um-queue-config.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [TEST.QUEUE] is not bound in this Context. Unable to find [TEST.QUEUE].
My Sample .binding file is below , I am using IBM MQ.
TEST_QMGR_QCF/RefAddr/1/Type=XXX
TEST_QMGR_QCF/RefAddr/2/Content=XXXX
TEST_QMGR_QCF/RefAddr/3/Content=TEST.TEST.TLS
TEST_QMGR_QCF/RefAddr/4/Content=true
TEST_QMGR_QCF/RefAddr/5/Content=0
TEST_QMGR_QCF/RefAddr/9/Type=TCM
TEST_QMGR_QCF/RefAddr/91/Type=TM
Version of the the IBM Mq jar files used are.
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-amqp</artifactId>
<version>1.7.10.RELEASE</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.allclient</artifactId>
<version>9.2.2.0</version>
</dependency>
I have com.sun.jndi.fscontext.RefFSContextFactory entry to to load my .binding files in my beans.xml like below.
<bean id="jndiTemplate" >
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory</prop>
<prop key="java.naming.provider.url">file:///C:/Local</prop>
</props>
</property>
</bean>
<bean id="umConnectionFactory" >
<property name="jndiTemplate" ref="jndiTemplate" />
<property name="jndiName" value="TEST_QMGR_QCF"/>
</bean>
This is where I see with older version of Spring I was able to load the .bindings but with upgrade unable to load.
CodePudding user response:
The best that I can do is to try to point you in the right direction. The .bindings
file uses the com.sun.jndi.fscontext.RefFSContextFactory
to provide a JNDI like lookup that is initialized from your .bindings
file.
You can find some references here IBM and Sun.
Note that the jar files fscontext.jar
and providerutil.jar
are provided with the IBM MQ distribution in the /opt/mqm/java/lib
directory. These are the Sun jars needed for the file system context. These files are not, however, provided by the com.ibm.mq.allclient
maven artifact.
These jars must have been provided in your older version. You can find them in Maven Central:
<groupId>com.sun.messaging.mq</groupId>
<artifactId>fscontext</artifactId>
<packaging>jar</packaging>
<version>4.6-b01</version>
Note that the two jars seem to have been merged into the one jar in this artifact. Ensure that these Sun classes are in your current project.
Then, you'll need to find where you are doing something like (from the Sun link):
// Create the environment for constructing the initial JNDI
// naming context.
Hashtable env = new Hashtable();
// Store the environment attributes that tell JNDI which initial context
// factory to use and where to find the provider.//
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL, "file:///C:/imq_admin_objects");
// Create the initial context.
Context ctx = new InitialContext(env);
// Look up the connection factory object in the JNDI object store.
String CF_LOOKUP_NAME = "MyConnectionFactory";
ConnectionFactory myFactory = (ConnectionFactory) ctx.lookup
(CF_LOOKUP_NAME);
in your code. Note that the .bindings
file name is expected, and that the location specified is a directory where the .bindings
file is located.
CodePudding user response:
I have com.sun.jndi.fscontext.RefFSContextFactory entry to to load my .binding files in my beans.xml like below.
<bean id="jndiTemplate" >
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory</prop>
<prop key="java.naming.provider.url">file:///C:/Local</prop>
</props>
</property>
</bean>
<bean id="umConnectionFactory" >
<property name="jndiTemplate" ref="jndiTemplate" />
<property name="jndiName" value="TEST_QMGR_QCF"/>
</bean>
This is where I see with older version of Spring I was able to load the .bindings but with upgrade unable to load.