1

我有一个小问题,但在任何地方都找不到答案 - 当使用 mule jar 将 mule 应用程序(war)部署到 tomcat 中时,我看到以下消息:

SEVERE: Exception sending context initialized event to listener instance of class org.mule.config.builders.MuleXmlBuilderContextListener
java.lang.ClassCastException: Notification class must be of type: org.mule.api.context.notification.ServerNotification. Offending class is: org.mule.context.notification.MuleContextNotification
    at org.mule.lifecycle.NotificationLifecycleObject.(NotificationLifecycleObject.java:49)
    at org.mule.lifecycle.phases.MuleContextStopPhase.(MuleContextStopPhase.java:66)
    at org.mule.lifecycle.phases.MuleContextStopPhase.(MuleContextStopPhase.java:56)
    at org.mule.lifecycle.RegistryBrokerLifecycleManager.registerPhases(RegistryBrokerLifecycleManager.java:43)
    at org.mule.lifecycle.RegistryLifecycleManager.(RegistryLifecycleManager.java:57)
    at org.mule.lifecycle.RegistryBrokerLifecycleManager.(RegistryBrokerLifecycleManager.java:33)
    at org.mule.registry.AbstractRegistryBroker.(AbstractRegistryBroker.java:37)
    at org.mule.registry.DefaultRegistryBroker.(DefaultRegistryBroker.java:27)
    at org.mule.DefaultMuleContext.createRegistryBroker(DefaultMuleContext.java:176)
    at org.mule.DefaultMuleContext.(DefaultMuleContext.java:167)
    at org.mule.context.DefaultMuleContextBuilder.buildMuleContext(DefaultMuleContextBuilder.java:97)
    at org.mule.context.DefaultMuleContextFactory.buildMuleContext(DefaultMuleContextFactory.java:215)
    at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:201)
    at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:100)
    at org.mule.config.builders.MuleXmlBuilderContextListener.createMuleContext(MuleXmlBuilderContextListener.java:169)
    at org.mule.config.builders.MuleXmlBuilderContextListener.initialize(MuleXmlBuilderContextListener.java:98)
    at org.mule.config.builders.MuleXmlBuilderContextListener.contextInitialized(MuleXmlBuilderContextListener.java:74)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:962)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1603)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
2013-08-11 23:11:43 org.apache.catalina.core.ApplicationContext log

这很糟糕,因为 org.mule.context.notification.MuleContextNotification 正在扩展 org.mule.api.context.notification.ServerNotification。我在这里想念什么?

我的 web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

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

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

    <servlet>
        <servlet-name>muleServlet</servlet-name>
        <servlet-class>org.mule.transport.servlet.MuleReceiverServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>muleServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>

</web-app>     
4

1 回答 1

1

好的,我找到了解决方案:

1 - 首先最好在 WEB-INF\classes logging.properties 文件中有:

org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler

这样所有正确的错误都会显示在控制台上,很可能会有 ClassNotFoundException。

2 - 通过 maven 依赖项将所需的 lib 导入您的应用程序(对我来说,我必须使用提供的范围,因为 jar 已经在 tomcat lib 目录中) - 在我的情况下,它是 mule-module-tomcat-3.4.0.jar

最后我的项目的 pom.xml 看起来像这样:

...
<properties>
  <spring.version>3.2.3.RELEASE</spring.version>
  <mule.version>3.4.0</mule.version>
</properties>

<dependencies>
  <dependency>
      <groupId>org.mule</groupId>
      <artifactId>mule-core</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>org.mule.modules</groupId>
      <artifactId>mule-module-tomcat</artifactId>
      <version>${mule.version}</version>
      <scope>provided</scope>
  </dependency>

  <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring.version}</version>
      <scope>provided</scope>
  </dependency> 
</dependencies>

问题解决了:D

于 2013-08-13T12:04:04.983 回答