I think I have found the reason of this problem and a workaround. I'll start 
with my stacktrace, my bundles have other ids

org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name
'org.springframework.beans.factory.config.MethodInvokingFactoryBean#0' defined 
in URL
[bundle://240.0:0/META-INF/spring/wmqbridge.xml]: Invocation of init method 
failed; nested exception is
java.lang.ClassNotFoundException: com.ibm.mq.MQEnvironment not found from 
bundle [wmqbridge.xml]
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:618)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)[124:org.apache.servicemix.bundles.spring-context:3.2.11.RELEASE_1]
    at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)[128:org.springframework.osgi.core:1.2.1]
    at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)[128:org.springframework.osgi.core:1.2.1]
    at
org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[128:org.springframework.osgi.core:1.2.1]
    at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[128:org.springframework.osgi.core:1.2.1]
    at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)[129:org.springframework.osgi.extender:1.2.1]
    at java.lang.Thread.run(Thread.java:745)[:1.7.0_80]
Caused by: java.lang.ClassNotFoundException: com.ibm.mq.MQEnvironment not found 
from bundle [wmqbridge.xml]
    at
org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:103)[128:org.springframework.osgi.core:1.2.1]
    at
org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)[128:org.springframework.osgi.core:1.2.1]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_80]
    at
org.springframework.util.ClassUtils.forName(ClassUtils.java:265)[120:org.apache.servicemix.bundles.spring-core:3.2.11.RELEASE_1]
    at
org.springframework.beans.factory.config.MethodInvokingFactoryBean.resolveClassName(MethodInvokingFactoryBean.java:123)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    at
org.springframework.util.MethodInvoker.prepare(MethodInvoker.java:153)[120:org.apache.servicemix.bundles.spring-core:3.2.11.RELEASE_1]
    at
org.springframework.beans.factory.config.MethodInvokingFactoryBean.afterPropertiesSet(MethodInvokingFactoryBean.java:149)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)[122:org.apache.servicemix.bundles.spring-beans:3.2.11.RELEASE_1]
    ... 14 more
Caused by: java.lang.ClassNotFoundException: com.ibm.mq.MQEnvironment not found 
by com.ibm.msg.client.osgi.wmq [234]
    at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)[org.apache.felix.framework-4.2.1.jar:]
    at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)[org.apache.felix.framework-4.2.1.jar:]
    at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)[org.apache.felix.framework-4.2.1.jar:]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_80]
    at
org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1374)[org.apache.felix.framework-4.2.1.jar:]
    at
org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1553)[org.apache.felix.framework-4.2.1.jar:]
    at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1484)[org.apache.felix.framework-4.2.1.jar:]
    at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)[org.apache.felix.framework-4.2.1.jar:]
    at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)[org.apache.felix.framework-4.2.1.jar:]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_80]
    at 
org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1844)[org.apache.felix.framework-4.2.1.jar:]
    at 
org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:937)[org.apache.felix.framework-4.2.1.jar:]
    at
org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)[128:org.springframework.osgi.core:1.2.1]

And output form list

234 | Active   |  80 | 7.5.0.1                            | WMQ provider 
Plug-in                     
235 | Active   |  80 | 7.5.0.1                            | WebSphere MQ 
classes for Java Plug-in    
236 | Active   |  80 | 7.5.0.1                            | Common Services 
J2SE Plug-in             
237 | Active   |  80 | 7.5.0.1                            | JMS client Plug-in  
                     
238 | Active   |  80 | 7.5.0.1                            | NLS Plug-in, 
Fragments: 242              
239 | Active   |  80 | 7.5.0.1                            | JMS prereq Plug-in  
                     
240 | Failure  |  80 | 0.0.0                              | wmqbridge.xml       
                     
241 | Active   |  80 | 7.5.0.1                            | WMQ prereq Plug-in  
                     
242 | Resolved |  80 | 7.5.0.1                            | WMQ NLS Plug-in, 
Hosts: 238              
243 | Active   |  80 | 7.5.0.1                            | DirectIP Plug-in

The bundle 234 cannot find the class com.ibm.mq.MQEnvironment. Indeed, the 
package com.ibm.mq is exported by 2 bundles:

com.ibm.mq                                                                      
                       |
0.0.0                              | 235 | com.ibm.mq.osgi.java                 
                     
com.ibm.mq                                                                      
                       |
0.0.0                              | 234 | com.ibm.msg.client.osgi.wmq

Let's try to find the class MQEnvironment

karaf@root>classes 234 | grep MQEnvironment
com/ibm/msg/client/wmq/v6/base/internal/MQEnvironment.class
com/ibm/msg/client/wmq/v6/base/internal/MQEnvironmentPropertiesHashtable.class
karaf@root>classes 235 | grep MQEnvironment
com/ibm/mq/MQEnvironment$1.class
com/ibm/mq/MQEnvironment$PrivilegedActionImpl.class
com/ibm/mq/MQEnvironment.class
com/ibm/mq/MQEnvironmentPropertiesHashtable.class

We have a package split. The class com.ibm.mq.MQEnvironment can be found only 
in the bundle 235, but the bundle 234 has
been resolved first, so Karaf uses the package com.ibm.mq from bundle 234 which 
doesn't contain this class.

234 | Active   |  80 | 7.5.0.1                            | WMQ provider 
Plug-in                     
235 | Active   |  80 | 7.5.0.1                            | WebSphere MQ 
classes for Java Plug-in

I have tested the same in ServiceMix 5.4.0 and there the bundle containing this 
class is resolved first, so you were
lucky and you didn't have this problem.

[ 211] [Active     ] [            ] [       ] [   80] WebSphere MQ classes for 
Java Plug-in (7.5.0.1)
[ 212] [Active     ] [            ] [       ] [   80] WMQ provider Plug-in 
(7.5.0.1)

You must force the bundle "WebSphere MQ classes for Java Plug-in" to be 
installed before "WMQ provider Plug-in". If you
had a feature containing these bundles (instead deploying them directly to 
deploy directory) you could use start-level.
I tried to change the start level for bundles installed in deploy and it didn't 
help.

My workaround:

  * deploy first all WMQ libraries but not the 
com.ibm.msg.client.osgi.wmq_7.5.0.1.jar (you should remove the data
    directory when you don't start with fresh ServiceMix)
  * start ServiceMix if not started yet --> the deployed libraries including 
WebSphere MQ classes for Java Plug-in will
    be resolved first
  * deploy the com.ibm.msg.client.osgi.wmq_7.5.0.1.jar (WMQ provider Plug-in)
  * deploy your xml file

It helped me. Perhaps someone more experienced in Karaf/OSGi has another 
solution how to force the correct resolve order.

Regards
Krzysztof 



On 15.07.2015 23:35, Krzysztof Sobkowiak wrote:
> sorry, my mistake
>
>
> exports | grep com.ibm.mq
> imports | grep com.ibm.mq
>
>
>
> On 15.07.2015 23:29, catshout wrote:
>> Thanks a lot for your support, Krzysztof.
>>
>> The first both commands, export and import, return nothing.
>>
>> Than ..
>>
>>
>>
>>
>>
>>
>>
>> Finally, you may try this out. It's a fresh SM 6.0.0 instance, only with the
>> WMQ OSGi jars and the wmqbridge.xml I've provided above. These could be find
>> at http://www-01.ibm.com/support/docview.wss?uid=swg24032744 for free.
>>
>>
>>
>> --
>> View this message in context: 
>> http://servicemix.396122.n5.nabble.com/WMQ-JMS-Provider-OSGi-classes-cause-an-error-since-SM-6-0-0-tp5722815p5722819.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.

-- 
Krzysztof Sobkowiak (@ksobkowiak)

JEE & OSS Architect, Integration Architect
Apache Software Foundation Member
Apache ServiceMix <http://servicemix.apache.org/> Committer & PMC
Senior Solution Architect @ Capgemini SSC <http://www.pl.capgemini-sdm.com/en/>

Reply via email to