骡子:队列管理器为空

Mule : Queuemanager is null

我已经创建了一个 java webproject,我正在尝试将 Mule 嵌入其中。 所有必需的依赖项都已添加到 pom.xml 中,web.xml 中的片段是:

<display-name>Mule App</display-name>

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<context-param>
    <param-name>org.mule.config</param-name>
    <param-value>
         WEB-INF\mule-config.xml
    </param-value>
</context-param>

<listener>
    <listener-class>org.mule.config.builders.MuleXmlBuilderContextListener</listener-class>
</listener>

该项目已配置为在 Tomcat 7 上部署。 当 运行 项目出现此异常时:

SEVERE: Exception sending context initialized event to listener instance of class org.mule.config.builders.MuleXmlBuilderContextListener
org.mule.api.MuleRuntimeException: The required object/property "queueManager" is null
    at org.mule.DefaultMuleContext.start(DefaultMuleContext.java:272)
    at org.mule.config.builders.MuleXmlBuilderContextListener.initialize(MuleXmlBuilderContextListener.java:96)
    at org.mule.config.builders.MuleXmlBuilderContextListener.contextInitialized(MuleXmlBuilderContextListener.java:70)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5524)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

我已经尝试通过 Java 使用 SpringXmlConfigurationBuilder 完成此操作,然后创建 muleContext 并在尝试 muleContext.start() 时抛出相同的异常。 None 种方法有效。

这个 mule-config.xml 在 Anypoint studio 中工作(它只是一个基本的)。我是 Mule 的新手,所以不知道如何将东西添加到队列管理器中。

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="9900" doc:name="HTTP Listener Configuration" />
    <flow name="myFirstMuleFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP" />
        <logger message="Hello I logged" level="INFO" doc:name="Logger" />
        <set-payload value="Payload set" doc:name="Set Payload" />
    </flow>
</mule>

我做这一切是因为如果我在 tomcat 上部署这个项目,它会打开另一个端口,因为使用了 http 侦听器。我想要的是能够在 tomcat 上部署一个项目,并且所有内容都在同一个 tomcat 端口上执行。

pom.xml 看起来像:

<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.muleConnector.csi</groupId>
<artifactId>mule</artifactId>
<packaging>war</packaging>
<version>0.0.1-Alpha</version>

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

<dependencies>
    <dependency>
        <groupId>mule-embedded</groupId>
        <artifactId>mule-embedded</artifactId>
        <scope>system</scope>
        <version>3.6.1</version>
        <systemPath>${basedir}\src\main\webapp\WEB-INF\lib\mule-embedded.jar</systemPath>
    </dependency>

    <dependency>
        <groupId>net.sourceforge.jtds</groupId>
        <artifactId>jtds</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId> org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.13</version>
    </dependency>

    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.2.2</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.1.5.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.0.4.RELEASE</version>
    </dependency>


    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>

    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.1</version>
    </dependency>
    <dependency>
        <groupId>javax.resource</groupId>
        <artifactId>javax.resource-api</artifactId>
        <version>1.7</version>
    </dependency>

    <dependency>
        <groupId>com.eaio.uuid</groupId>
        <artifactId>uuid</artifactId>
        <version>3.2</version>
    </dependency>
    <dependency>
        <groupId>commons-cli</groupId>
        <artifactId>commons-cli</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>18.0</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.10</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>3.2.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.grizzly</groupId>
        <artifactId>grizzly-http-server</artifactId>
        <version>2.3.19</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>


    <finalName>mule</finalName>
</build>

您不需要手动定义队列管理器:Mule 默认配置了一个名为 _muleQueueManager 的队列管理器,位于:https://github.com/mulesoft/mule/blob/mule-3.6.1/modules/spring-config/src/main/resources/minimal-mule-config.xml#L37

默认也会加载minimal-mule-config.xmlhttps://github.com/mulesoft/mule/blob/mule-3.6.1/modules/spring-config/src/main/java/org/mule/config/spring/SpringXmlConfigurationBuilder.java#L78

所以这里还有其他东西在起作用,它会阻止加载您的 Mule 配置。

实际上,这里很可能是这个奇怪的反斜杠:

WEB-INF\mule-config.xml

这实际上应该是:

WEB-INF/mule-config.xml

编辑:此外,这种依赖性很可能是问题的原因:

<dependency>
    <groupId>mule-embedded</groupId>
    <artifactId>mule-embedded</artifactId>
    <scope>system</scope>
    <version>3.6.1</version>
    <systemPath>${basedir}\src\main\webapp\WEB-INF\lib\mule-embedded.jar</systemPath>
</dependency>

您可以删除它,删除您在 ${basedir}\src\main\webapp\WEB-INF\lib 中的任何 JAR,而是使用对 mule-coremule-module-spring-config 以及您所依赖的任何额外模块和传输的单独依赖项。

编辑 2 我很快拼凑了一个示例,展示了如何 运行 网络应用程序中的 Mule:https://github.com/ddossot/mule-webapp-example