如何解决WMQ java.lang.ClassNotFoundException:com.ibm.mq.jms.MQConnectionFactory错误?

时间:2017-10-31 01:07:38

标签: maven queue mule

在将接口部署到Cloud Hub时出现以下错误,在我的本地计算机应用程序中已成功部署。

我需要从WMQ轮询数据。这个错误似乎与此有关。我的界面是基于maven的界面。

我添加了所有WMQ必需的jar来构建路径

Build path Jar files

我的POM文件如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.katalystm</groupId>
    <artifactId>apl-integration</artifactId>
    <version>1.0.0-PRE</version>
    <packaging>mule</packaging>
    <name>Mule apl-integration Application</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <mule.version>3.8.5</mule.version>
        <mule.tools.version>1.1</mule.tools.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.mule.tools.maven</groupId>
                <artifactId>mule-app-maven-plugin</artifactId>
                <version>${mule.tools.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <copyToAppsDirectory>true</copyToAppsDirectory>
                <inclusions>
                        <inclusion>
                            <groupId>org.mule.modules</groupId>
                            <artifactId>mule-module-objectstore</artifactId>
                        </inclusion>
                    <inclusion>
                            <groupId>com.mulesoft.muleesb.transports</groupId>
                            <artifactId>mule-transport-sap</artifactId>
                        </inclusion>
                    </inclusions>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2.1</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>project</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>add-resource</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>src/main/app/</directory>
                                </resource>
                                <resource>
                                    <directory>mappings/</directory>
                                </resource>
                            <resource>
                                    <directory>src/main/api/</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <!-- Mule Dependencies -->
    <dependencies>
        <!-- Xml configuration -->
        <dependency>
            <groupId>com.mulesoft.muleesb</groupId>
            <artifactId>mule-core-ee</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Xml configuration -->
        <dependency>
            <groupId>com.mulesoft.muleesb.modules</groupId>
            <artifactId>mule-module-spring-config-ee</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Mule Transports -->
        <dependency>
            <groupId>org.mule.transports</groupId>
            <artifactId>mule-transport-file</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.transports</groupId>
            <artifactId>mule-transport-http</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.muleesb.transports</groupId>
            <artifactId>mule-transport-jdbc-ee</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.muleesb.transports</groupId>
            <artifactId>mule-transport-jms-ee</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.transports</groupId>
            <artifactId>mule-transport-vm</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Mule Modules -->
        <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-scripting</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-xml</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- for testing -->
        <dependency>
            <groupId>org.mule.tests</groupId>
            <artifactId>mule-tests-functional</artifactId>
            <version>${mule.version}</version>
            <scope>test</scope>
        </dependency>
    <dependency>
            <groupId>com.mulesoft.muleesb.transports</groupId>
            <artifactId>mule-transport-wmq-ee</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
    <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-spring-config</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sap.conn.jco</groupId>
            <artifactId>sapjco3</artifactId>
            <version>3.0.14</version>
        </dependency>
        <dependency>
            <groupId>com.sap.conn.idoc</groupId>
            <artifactId>sapidoc3</artifactId>
            <version>3.0.12</version>
        </dependency>
        <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-objectstore</artifactId>
            <version>2.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.muleesb.transports</groupId>
            <artifactId>mule-transport-sap</artifactId>
            <version>3.1.1</version>
        </dependency>
    </dependencies>

    <repositories>
         <repository>
        <id>Central</id>
        <name>Central</name>
        <url>http://repo1.maven.org/maven2/</url>
        <layout>default</layout>
    </repository>
    <repository>
        <id>codehaus-mule-repo</id>
        <name>codehaus-mule-repo</name>
        <url>https://repository-master.mulesoft.org/nexus/content/groups/public/</url>
        <layout>default</layout>
    </repository>
    <repository>
        <id>mulesoft-releases</id>
        <name>MuleSoft Releases Repository</name>
        <url>http://repository.mulesoft.org/releases/</url>
        <layout>default</layout>
    </repository>  
    <repository>
        <id>mulesoft-snapshots</id>
        <name>MuleSoft Snapshots Repository</name>
        <url>http://repository.mulesoft.org/snapshots/</url>
        <layout>default</layout>
    </repository> 
    <repository>
            <id>mule-ee-releases</id>
            <name>MuleEE Releases Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/releases-ee/</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>mulesoft-release</id>
            <name>mulesoft release repository</name>
            <layout>default</layout>
            <url>http://repository.mulesoft.org/releases/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

</project>

部署到云时获取PFB错误消息。

null
java.lang.ClassNotFoundException: com.ibm.mq.jms.MQConnectionFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at org.mule.module.launcher.FineGrainedControlClassLoader.findClass(FineGrainedControlClassLoader.java:181)
    at org.mule.module.launcher.MuleApplicationClassLoader.findClass(MuleApplicationClassLoader.java:138)
    at org.mule.module.launcher.FineGrainedControlClassLoader.loadClass(FineGrainedControlClassLoader.java:117)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.mulesoft.mule.transport.wmq.WebSphereMQConnector.<clinit>(WebSphereMQConnector.java:39)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.commons.lang.ClassUtils.getClass(ClassUtils.java:629)
    at org.apache.commons.lang.ClassUtils.getClass(ClassUtils.java:677)
    at org.apache.commons.lang.ClassUtils.getClass(ClassUtils.java:660)
    at org.mule.config.spring.parsers.assembly.DefaultBeanAssembler.methodExists(DefaultBeanAssembler.java:564)
    at org.mule.config.spring.parsers.assembly.DefaultBeanAssembler.bestGuessName(DefaultBeanAssembler.java:533)
    at org.mule.config.spring.parsers.assembly.DefaultBeanAssembler.extendBean(DefaultBeanAssembler.java:112)
    at org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser.processProperty(AbstractMuleBeanDefinitionParser.java:211)
    at org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser.doParse(AbstractMuleBeanDefinitionParser.java:422)
    at org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser.parseInternal(AbstractMuleBeanDefinitionParser.java:297)
    at org.mule.config.spring.parsers.generic.MuleOrphanDefinitionParser.parseInternal(MuleOrphanDefinitionParser.java:38)
    at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:61)

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

您已将所有相关的JAR添加到本地环境(您的IDE构建路径),但所述JAR未与您的应用程序打包在一起,因此在部署时无法在CloudHub上使用并导致您的错误。正如CloudHub documentation所述,您需要确保将第三方JAR放入应用包的/lib文件夹中。

我建议您将所有必需的JAR添加为Maven <dependency>,这样您的JAR将被Maven包含在您的Mule应用程序归档文件/lib中(然后您可以从IDE中删除它们) classpath,它们将自动添加到M2_REPO / ...下。例如mqjms

<dependency>
    <groupId>com.ibm</groupId>
    <artifactId>com.ibm.mqjms</artifactId>
    <version>5.3.07</version>
</dependency>

棘手的部分是大多数JAR(IBM库)都是专有的,并且在Public Maven存储库中不可用。您可能需要:

您也可以手动添加或使用其他方式添加它们,重要的是在CloudHub上部署时,这些JAR位于应用/lib文件夹中。