0

我正在尝试使用 apache camel 从基于 spring mvc 的 Web 应用程序发送电子邮件。但是我猜我的tomcat没有起床是因为一些错误的配置。

你能帮我么?

**camel-config.xml**

    <?xml version="1.0" encoding="UTF-8"?>
        <beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:camel="http://camel.apache.org/schema/spring"
            xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
                                http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

            <camelContext xmlns="http://camel.apache.org/schema/spring">
               <contextScan>com.aaa.bbb.ccc.service</contextScan>
            </camelContext>
        </beans>


@Service
public class NotificationService 
{
    @Produce(uri = "smtp://mysmtp.company.com")
    private ProducerTemplate template;

    public void send(String from,String to,String cc,String bcc,String subject,String body) 
    {
         template.sendBodyAndHeaders(body,Requirement_Specific_Code);
    }
}

Spring Jar: version 3.1.0
Camel: camel-core-2.10.3.jar 
       camel-mail-2.10.3.jar 
       camel-mina-2.10.3.jar 
       camel-spring-2.10.3.jar

**:Issue:** Once i run tomcat i am having below error.

 2013-05-21 19:08:05,581 ERROR org.springframework.web.context.ContextLoader  - Context initialization failed 
 org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [camel-config.xml]
Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 2 in XML document from ServletContext resource [/WEB-INF/camel-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://camel.apache.org/schema/spring/camel-spring.xsd; lineNumber: 2; columnNumber: 225; TargetNamespace.1: Expecting namespace 'http://camel.apache.org/schema/spring', but the target namespace of the schema document is 'http://activemq.apache.org/camel/schema/spring'.
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)

我不明白我错在哪里。

谁能帮帮我?

4

2 回答 2

0

你确定你的camel-contex.xml样子像你发的吗?错误说:

Expecting namespace 'http://camel.apache.org/schema/spring', but the target namespace of the schema document is 'http://activemq.apache.org/camel/schema/spring'

因此,您在某处使用了错误的 XML 命名空间http://activemq.apache.org/camel/schema/spring。在哪里?

于 2013-05-21T14:56:45.457 回答
0

有很多问题,我一一发现并按顺序解决。但是,对于其他人的帮助,我得出结论。

问题/解决方案: 1) Ant 目标中存在一些冲突,未部署 camel-config.xml。在问题中提供 xml 不太正确。正确如下。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:camel="http://camel.apache.org/schema/spring"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
                        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.10.3.xsd">
    <camelContext xmlns="http://camel.apache.org/schema/spring">
       <contextScan/>
    </camelContext>
</beans>

2)我修改(添加/更新/删除)jar,如下所示。

  • 骆驼核心-2.11.0
  • 骆驼邮件2.11.0
  • 骆驼米娜 2.11.0
  • 骆驼弹簧2.11.0
  • mina-core-1.1.7
  • 邮件 1.4.5
  • mina-core-2.0.0-M3
  • slf4j-api-1.7.5
  • slf4j-log4j12-1.7.5

如果您的 jar 与上述不符,您可能会收到如下错误。

  • org.apache.mina.core.buffer.IOBuffer 类不可用(mina-core-2.0.0-M3)
  • ByteArray 类不可用。
  • 无法自动创建 smtp。

感谢大家的支持,希望这些信息对以后的某些人有所帮助。

于 2013-05-22T06:10:33.757 回答