Could not initialize com.ibm.mq.MQEnvironment

I've upgraded my maven dependencies for IBM MQ from these(version: 6.0.2.5):

<dependency>
    <groupId>com.ibm</groupId>
    <artifactId>mq</artifactId>
    <version>${ibm-mq-version}</version>
</dependency>
<dependency>
    <groupId>com.ibm</groupId>
    <artifactId>mqjms</artifactId>
    <version>${ibm-mq-version}</version>
</dependency>
<dependency>
    <groupId>com.ibm.disthub2</groupId>
    <artifactId>dhbcore</artifactId>
    <version>DH610-Gold</version>
</dependency>
<dependency>
    <groupId>com.ibm</groupId>
    <artifactId>mqetclient</artifactId>
    <version>${ibm-mq-version}</version>
</dependency>

To that(version: 7.5.0.5):

<dependency>
    <groupId>com.ibm</groupId>
    <artifactId>mq-jms-all</artifactId>
    <version>${ibm-mq-version}</version>
</dependency>

Now, everytime I try to run my project, I get the following error:

nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.ibm.mq.MQEnvironment

The maven-dependency is imported correctly and is also visible in Eclipse in the maven-dependencies-tab. Also i see the com.ibm.mq.jar in the classpath.

I've googled a lot and the only real solution, which worked for some people was, to add the connector.jar. But I'm already using the jar:

<dependency>
    <groupId>javax.resource</groupId>
    <artifactId>connector</artifactId>
    <version>${connector-version}</version>
</dependency>

Am I missing something?

Answers


IBM MQ from these(version: 6.0.2.5):

To that(version: 7.5.0.5):

IBM moved the MQException to the 'com.ibm.mq.jmqi.jar' file.

As per the the MQ Knowledge Center, you need the following jar files for MQ JMS programming:

  • com.ibm.mq.commonservices.jar
  • com.ibm.mq.headers.jar
  • com.ibm.mq.pcf.jar
  • com.ibm.mq.jmqi.jar
  • connector.jar
  • jms.jar
  • dhbcore.jar
  • rmm.jar
  • jndi.jar
  • ldap.jar
  • fscontext.jar
  • providerutil.jar
  • CL3Export.jar
  • CL3Nonexport.jar

Exactly the same problem and this fixed it

<dependency>
    <groupId>javax.resource</groupId>
    <artifactId>connector</artifactId>
    <version>${connector-version}</version>
</dependency>

These are my dependencies.

<dependency>
            <groupId>com.ibm.mq</groupId>
            <artifactId>com.ibm.mq.commonservices</artifactId>
            <version>7.0.1.4</version>
        </dependency>
        <dependency>
  <groupId>com.ibm.mq</groupId>
  <artifactId>com.ibm.mq.headers</artifactId>
  <version>7.0.1.4</version>
</dependency>
        <dependency>
  <groupId>com.ibm.mq</groupId>
  <artifactId>com.ibm.mq.jmqi</artifactId>
  <version>7.0.1.4</version>
</dependency>
        <dependency>
            <groupId>com.ibm.mq</groupId>
            <artifactId>com.ibm.mq.jms.Nojndi</artifactId>
            <version>7.0.1.4</version>
        </dependency>
        <dependency>
            <groupId>com.ibm.mq</groupId>
            <artifactId>com.ibm.mqjms</artifactId>
            <version>7.0.1.4</version>
        </dependency>
        <dependency>
            <groupId>com.ibm.mq</groupId>
            <artifactId>com.ibm.mq.soap</artifactId>
            <version>7.0.1.4</version>
        </dependency>
        <dependency>
  <groupId>com.ibm.mq</groupId>
  <artifactId>com.ibm.mq</artifactId>
  <version>7.0.1.4</version>
</dependency>       

        <dependency>
  <groupId>com.ibm.mq</groupId>
  <artifactId>com.ibm.mq.headers</artifactId>
  <version>7.0.1.4</version>
</dependency>
        <dependency>
  <groupId>com.ibm.mq</groupId>
  <artifactId>com.ibm.mq.pcf</artifactId>
  <version>7.0.1.4</version>
</dependency>
        <dependency>
  <groupId>javax.resource</groupId>
  <artifactId>connector</artifactId>
  <version>1.5</version>
</dependency>
        <dependency>
            <groupId>com.ibm</groupId>
            <artifactId>com.ibm.dhbcore</artifactId>
            <version>7.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.ibm.mq</groupId>
            <artifactId>CL3Nonexport</artifactId>
            <version>${webspheremq.version}</version>
        </dependency>
        <dependency>
            <groupId>com.ibm</groupId>
            <artifactId>com.ibm.mqetclient</artifactId>
            <version>7.0.1</version>
        </dependency>

For Eclipse (Dynamic Web Project (Servlet)) you need copy files:

com.ibm.mq.commomservices.jar
com.ibm.mq.defaultconfig.jar
com.ibm.mq.headers.jar
com.ibm.mq.jar
com.ibm.mq.jmqi.jar
com.ibm.mq.jms.Nojndi.jar
com.ibm.mq.pcf.jar
com.ibm.mqetclient.jar
com.ibm.mqjms.jar
connector.jar
dhbcode.jar
fscontext.jar
jms.jar

to /WebContext/WEB-INF/lib, then add them into Project (Project -> Properties -> Java Build Path -> Add External JARs). After all, go through these steps:

  • close project
  • close Eclipse
  • open Eclipse
  • open project.

Good Luck!


Need Your Help

PHP How can I set a default path to cookies

php session cookies

I'd like to know if there's anyway I can set default path to cookies, so I doesn't need to specify it on setcookie function call, I tried on php.ini file, but it's not working as I supposed.

CQ/AEM where are functions like 'cq5forms_showMgs()' defined?

javascript aem web-component sling

I noticed that CQ occasionally uses these javascript cq5forms functions and variables. I'm wondering where they are defined and how they work.