Spring Camel电子邮件配置问题

时间:2013-05-21 14:01:34

标签: java spring spring-mvc apache-camel

我正在尝试使用apache camel从我的基于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)

我不知道我错在哪里。

有人可以帮帮我吗?

2 个答案:

答案 0 :(得分: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。哪里?

答案 1 :(得分: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
  • 米纳核-1.1.7
  • 邮件1.4.5
  • 米纳核-2.0.0-M3
  • SLF4J-API-1.7.5
  • SLF4J-log4j12-1.7.5

如果您的罐子不符合上述要求,则可能会出现以下错误。

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

感谢大家的支持,并希望这些信息将来会对某些人有所帮助。