aspose file tools*
The moose likes JBoss/WildFly and the fly likes Error creating bean with WebsphereMQ and jbossAS using the Spring framework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Error creating bean with WebsphereMQ and jbossAS using the Spring framework" Watch "Error creating bean with WebsphereMQ and jbossAS using the Spring framework" New topic
Author

Error creating bean with WebsphereMQ and jbossAS using the Spring framework

Martin Kelly
Greenhorn

Joined: Jan 09, 2011
Posts: 12

Hi Folks,
I’m hoping somebody can help me here.
I’m having trouble running WebsphereMQ with jbossAS using the Spring framework.
When I send a message and reference the Queue details with values from the .properties file, everything is fine and I receive the message. My problem lies in trying to reference the ConnectionFactory via jndi (as shown below).
I have a Spring configuration file referencing the jndi name.
I have coppied wmq.jmsra.rar from Websphere to my jboss deploy directory.
In the deploy directory, my –ds.xml files configure the destination and the ConnectionFactory thus:





The jndi binding appears to be successful when using jndi given the following server.log details:



But then I get an error creating a ConfigurableMessageListenerContainer bean.



There is a lot more content in the log file but it finishes:





My Spring configuration includes the following (The references to the .properties file are commented out) :



As I’m new to this level of programming, I don’t know if there are any more .xml configuration files I should be using.
I have tried several different ways of formatting the jndi reference in the Spring configuration, ie. jndi-name="java/NMQ_CF", jndi-name="java:/NMQ_CF", etc.
Another point I’m considering is that even though I have my –ds.xml and wmq.jmsra.rar files in C:/Servers/applications/deploy my .war file is deployed to c:/Servers/jboss_MWS_ESTSVC/jboss-as/server/production/deploy.

Help appreciated.
Thanks.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

What error do you get when you change the JNDI name to



in your Spring configuration file.

[My Blog] [JavaRanch Journal]
Martin Kelly
Greenhorn

Joined: Jan 09, 2011
Posts: 12

Using that format, the error goes as follows:

2012-08-03 14:51:11,959 INFO [STDOUT] (main) ERROR ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.myCo.util.ConfigurableMessageListenerContainer#1': Cannot resolve reference to bean 'nfnJSMSMSConsumerConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nfnJSMSMSConsumerConnectionFactory' defined in FileHandler@23[path=WEB-INF/classes/applicationContext/applicationContext-jms.xml context=file:/C:/Servers/jboss_MWS_ESTSVC/jboss-as/server/production/tmp/a1s403h-2as2x9-h5fbye1l-1-h5fc01vi-bq/MVN-notification-web-service-1.0.1-SNAPSHOT.war/ real=file:/C:/Servers/jboss_MWS_ESTSVC/jboss-as/server/production/tmp/a1s403h-2as2x9-h5fbye1l-1-h5fc01vi-bq/MVN-notification-web-service-1.0.1-SNAPSHOT.war/WEB-INF/classes/applicationContext/applicationContext-jms.xml]: Cannot resolve reference to bean 'nfnSMSJMSConnectionFactory' while setting bean property 'targetConnectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nfnSMSJMSConnectionFactory' defined in FileHandler@20630333[path=WEB-INF/classes/applicationContext/applicationContext-jms.xml context=file:/C:/Servers/jboss_MWS_ESTSVC/jboss-as/server/production/tmp/a1s403h-2as2x9-h5fbye1l-1-h5fc01vi-bq/MVN-notification-web-service-1.0.1-SNAPSHOT.war/ real=file:/C:/Servers/jboss_MWS_ESTSVC/jboss-as/server/production/tmp/a1s403h-2as2x9-h5fbye1l-1-h5fc01vi-bq/MVN-notification-web-service-1.0.1-SNAPSHOT.war/WEB-INF/classes/applicationContext/applicationContext-jms.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.ibm.mq.connector.outbound.ConnectionFactoryImpl' to required type 'javax.jms.ConnectionFactory' for property 'targetConnectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.ibm.mq.connector.outbound.ConnectionFactoryImpl] to required type [javax.jms.ConnectionFactory] for property 'targetConnectionFactory': no matching editors or conversion strategy found
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

Are you packaging any jar file(s) containing javax.jms.* classes within your application? If yes, remove such jars from the application being deployed.
Martin Kelly
Greenhorn

Joined: Jan 09, 2011
Posts: 12

That could be the problem alright, as there are a lot of Jar files in the application.
I'll be returning to the application after the weekend and will investigate.
Martin Kelly
Greenhorn

Joined: Jan 09, 2011
Posts: 12

Ok, so I've had a look through the repository and I see that there are many jms jars included directly in my repository, as well as in the following folders in the repository:



I'm reluctant to go removing so many jars from the repository all at once in case of breaking the build.

A similar thread at http://forum.springsource.org/showthread.php?34920-Problems-injecting-the-ConnectionFactory-and-Queue-into-DefaultMessageListenerContain
describes introducing a scope of "provided" for the jms jar in the POM.xml.
However including this has made no difference to my server log output.



Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

You shouldn't be removing it from the repository or build time configurations. All you have to ensure is that those jars don't get packaged as part of the final deployable (the .war file in this case) that you deploy to the server.
Martin Kelly
Greenhorn

Joined: Jan 09, 2011
Posts: 12

I've had a look at the dependency graph to see what elements were dependent on the various jars containing jms.*.
I've identified two elements that are dependent on these jars and then within these elements in the pom.xml I've added exclusion tags to exclude these dependent elements from being packaged.
These jars are javax.jms, com.ibm.mqjms, geronimo-jms_1.1_spec, spring-jms

One by one, as the exclusion tags were introduced, the coresponding element disappeared from the dependency graph, with the exception of mqjms, despite defining an exclusion tag for it.


With exclusions added for all mentioned jars, I recieve the following error


When I un-exclude javax.jms element, I get the same error..
When I un-exclude geronimo-jms element, I get the same error..
Like I said, even though exclusion tags are defined for ibm.mqjms and it still displays on the dependency graph, when these exclusion tags are removed, I still get the same error.

When I un-exclude spring-jms, the server starts without error however I am not receiving the messages I drop on the queue.



Still not getting to the bottom of this..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error creating bean with WebsphereMQ and jbossAS using the Spring framework