简体   繁体   English

无法使用其他应用程序上下文重新初始化

[英]Cannot reinitialize with different application context

I am using Mule with Spring Integration to implement sending SMS function , below is spring xml configuration : 我正在使用Mule with Spring Integration来实现发送短信功能,下面是spring xml配置:

    <?xml version="1.0" encoding="UTF-8"?>

<mule 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.7.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:int-http="http://www.springframework.org/schema/integration/http"
    xmlns:context="http://www.springframework.org/schema/context"
    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.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd">
<spring:beans>

    <context:component-scan base-package="com.scholes.sf.message" />

    <oxm:jaxb2-marshaller id="sfRequestMarshaller">
        <oxm:class-to-be-bound name="com.scholes.sf.message.bean.SFSendSMSRequest" />
        <oxm:class-to-be-bound name="com.scholes.sf.message.bean.SFVerifySMSRequest" />
    </oxm:jaxb2-marshaller>

    <!-- send SMS -->
    <int:channel id="sendOobSmsResponseJsonChannel" />

    <int:channel id="sendOobSmsResponseObjectChannelOOB" />

    <int:channel id="sendOobSmsResponseObjectChannelSF" />

    <int:channel id="sendOobSmsRequestChannel" />

    <int:channel id="sendOobSmsResponseXmlChannel" />
    <int:channel id="verifyOobSmsResponseXmlChannel" />

    <int:channel id="verifyOobSmsRequestChannel" />

    <int:channel id="verifyOobSmsResponseObjectChannelSF" />

    <int:channel id="verifyOobSmsResponseObjectChannelOOB" />

    <int:channel id="verifyOobSmsResponseJsonChannel" />

    <int:object-to-json-transformer
        input-channel="sendOobSmsResponseObjectChannelOOB" output-channel="sendOobSmsResponseJsonChannel">
    </int:object-to-json-transformer>

    <int:transformer input-channel="sendOobSmsResponseObjectChannelSF"
        output-channel="sendOobSmsResponseObjectChannelOOB" ref="oobSendSMSTransformer" />

    <int:transformer input-channel="sendOobSmsResponseXmlChannel"
        output-channel="sendOobSmsResponseObjectChannelSF" ref="sfSendResponseUnmarshaller" />

    <int:transformer input-channel="sendOobSmsRequestChannel"
        output-channel="sendOobSmsResponseXmlChannel" ref="sfSendSmsTransformer" />
    <spring:bean id="sfSendSmsTransformer" class="com.scholes.sf.message.transformer.SFSendSMSTransformer" />

    <int:channel id="sendOobSmsResponseObjectChannel" />

    <spring:bean id="sfSendResponseUnmarshaller"
        class="org.springframework.integration.xml.transformer.UnmarshallingTransformer">
        <spring:constructor-arg>
            <oxm:jaxb2-marshaller id="sfSendRequestMarshaller">
                <oxm:class-to-be-bound name="com.scholes.sf.message.bean.SFSendSMSResponse" />
            </oxm:jaxb2-marshaller>
        </spring:constructor-arg>
    </spring:bean>

    <spring:bean id="oobSendSMSTransformer" class="com.scholes.sf.message.transformer.OOBSendSMSTransformer" /> 

    <!-- verify SMS -->
    <int:transformer input-channel="verifyOobSmsRequestChannel"
        output-channel="verifyOobSmsResponseXmlChannel" ref="sfVerifySmsTransformer" />
    <spring:bean id="sfVerifySmsTransformer" class="com.scholes.sf.message.transformer.SFVerifySMSTransformer" />

    <int:channel id="verifyOobSmsResponseObjectChannel" />

    <spring:bean id="sfVerifyResponseUnmarshaller"
        class="org.springframework.integration.xml.transformer.UnmarshallingTransformer">
        <spring:constructor-arg>
            <oxm:jaxb2-marshaller id="sfVerifyRequestMarshaller">
                <oxm:class-to-be-bound name="com.scholes.sf.message.bean.SFVerifySMSResponse" />
            </oxm:jaxb2-marshaller>
        </spring:constructor-arg>
    </spring:bean>

    <int:transformer input-channel="verifyOobSmsResponseXmlChannel"
        output-channel="verifyOobSmsResponseObjectChannelSF" ref="sfVerifyResponseUnmarshaller" />

    <int:transformer input-channel="verifyOobSmsResponseObjectChannelSF"
        output-channel="verifyOobSmsResponseObjectChannelOOB" ref="oobVerifySMSTransformer" />
    <spring:bean id="oobVerifySMSTransformer" class="com.scholes.sf.message.transformer.OOBVerifySMSTransformer" />

    <int:object-to-json-transformer
        input-channel="verifyOobSmsResponseObjectChannelOOB" output-channel="verifyOobSmsResponseJsonChannel">
    </int:object-to-json-transformer>

    <context:property-placeholder location="sms/oob-config.properties"/>



    </spring:beans>
</mule>

It seems try to initialize a second spring-integration context , so getting below error: 似乎尝试初始化第二个spring-integration上下文,因此出现以下错误:

WARN 2016-03-22 17:21:37,388 [main] org.mule.config.spring.MuleArtifactContext: Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'integrationRequestMappingHandlerMapping': Initialization of bean failed; WARN 2016-03-22 17:21:37,388 [main] org.mule.config.spring.MuleArtifactContext:上下文初始化期间遇到异常-取消刷新尝试org.springframework.beans.factory.BeanCreationException:创建名称为'integrationRequestMappingHandlerMapping的bean时出错':bean的初始化失败; nested exception is org.springframework.context.ApplicationContextException: Cannot reinitialize with different application context: current one is [org.mule.config.spring.MuleDomainContext@1825085: startup date [Tue Mar 22 17:21:29 CST 2016]; 嵌套的异常是org.springframework.context.ApplicationContextException:无法使用不同的应用程序上下文重新初始化:当前一个是[org.mule.config.spring.MuleDomainContext@1825085:启动日期[Cue Mar 22 17:21:29 CST 2016]; root of context hierarchy], passed-in one is [org.mule.config.spring.MuleArtifactContext@14f3da4: startup date [Tue Mar 22 17:21:33 CST 2016]; 上下文层次结构的根],传入的是[org.mule.config.spring.MuleArtifactContext@14f3da4:启动日期[2016年3月22日星期二17:21:33 CST]; parent: org.mule.config.spring.MuleDomainContext@1825085] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFacto 父:org.mule.config.spring.MuleDomainContext@1825085]在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)〜[弹簧豆-4.1.6.RELEASE.jar:4.1 .6.RELEASE] org.springframework上的org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)〜[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE] .beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:303)〜[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry .getSingleton(DefaultSingletonBeanRegistry.java:230)〜[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) 〜[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFacto ry.java:194) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753) ~[mule-module-spring-config-3.7.2.jar:4.1.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:108) ~[mule-module-spring-config-3.7.2.jar:3.7.2] ry.java:194)~ [spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE] org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)~ [mule -module-spring-config-3.7.2.jar:4.1.6.RELEASE]在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)〜[spring-context-4.1.6.RELEASE。 jar:4.1.6.RELEASE]在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)〜[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]在org。 mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:108)〜[mule-module-spring-config-3.7.2.jar:3.7.2]

Any masters can help analyze this issue ? 任何大师都可以帮助分析这个问题? If I don't include this xml , then will be fine . 如果我不包含这个xml,那就可以了。 How to make SI and Spring work together ? 如何让SI和Spring一起工作?

So this is the root cause 所以这是根本原因

Cannot reinitialize with different application context: current one is
[org.mule.config.spring.MuleDomainContext@1825085: 
startup date [Tue Mar 22 17:21:29 CST 2016]; root of context hierarchy], 
passed-in one is [org.mule.config.spring.MuleArtifactContext@14f3da4: 
startup date [Tue Mar 22 17:21:33 CST 2016]; 
parent: org.mule.config.spring.MuleDomainContext@1825085] at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)

Check your XML namespaces. 检查您的XML名称空间。 Maybe you just copy pasted it wrongly and then your context got clashed. 也许您只是复制错误地粘贴了它,然后您的上下文发生了冲突。

Also check your integrationRequestMappingHandlerMapping bean definition. 还要检查您的integrationRequestMappingHandlerMapping bean定义。 It happens that it's initialized by different context. 碰巧它是由不同的上下文初始化的。 Please attach it's definition. 请附上它的定义。

That happened since you were mixing the mule spring config with SI which some of its components are not recognize. 发生这种情况是因为您将m子弹簧配置与SI混合使用,而SI的某些组件无法识别。 Can you try separating the SI config and then import it to mule config? 您可以尝试分离SI配置,然后将其导入到Mule配置吗? Like below: 如下所示:

<?xml version="1.0" encoding="UTF-8"?>
  <mule xmlns=http://www.mulesoft.org/schema/mule/c... ....>
     <spring:beans>
        <spring:import resource="si-config.xml" />
     </spring:beans>

Also, please check if you are using the correct version of Spring Integration by comparing the spring framework version used by EE 3.7.2 and SI you used. 另外,请通过比较EE 3.7.2和所使用的SI所使用的spring框架版本来检查您是否使用了正确的Spring Integration版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在不同的“上下文”中启动应用程序 - Launch an application in a different “context” 按主页键按钮,然后重新初始化应用程序 - press home key button and reinitialize the application IllegalStateException:无法初始化上下文,因为已经存在根应用程序上下文 - IllegalStateException: Cannot initialize context because there is already a root application context present AJAX调用不同的应用程序上下文(Java + Tomcat) - AJAX call on a different application context (Java + Tomcat) Spring:为什么“root”应用程序上下文和“servlet”应用程序上下文是由不同的各方创建的? - Spring: Why “root” application context and “servlet” application context are created by different parties? Spring servletcontext无法在根应用程序上下文中访问bean - Spring servletcontext cannot access bean in root application context 将百万美元集成到spring boot项目时,Application Context不能为null - Application Context cannot be null when intergrate thymeleaf into spring boot project Spring,多模块应用程序上下文,B依赖于A但看不到bean - Spring, Multi module application context, B depends on A but cannot see bean 无法使用maven过滤应用程序上下文从eclipse运行服务器 - Cannot run server from eclipse with maven filtering application context 无法加载来自其他maven模块的应用程序上下文 - Application context from other maven module cannot be loaded
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM