Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring Camel电子邮件配置问题_Java_Spring_Spring Mvc_Apache Camel - Fatal编程技术网

Java Spring Camel电子邮件配置问题

Java Spring Camel电子邮件配置问题,java,spring,spring-mvc,apache-camel,Java,Spring,Spring Mvc,Apache Camel,我正在尝试使用ApacheCamel从基于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:/

我正在尝试使用ApacheCamel从基于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)
**camel-config.xml**
com.aaa.bbb.ccc.service
@服务
公共类通知服务
{
@生产(uri=”smtp://mysmtp.company.com")
私有产品模板;
public void send(字符串发件人、字符串收件人、字符串抄送、字符串密件抄送、字符串主题、字符串正文)
{
模板。发送正文和标题(正文、要求和特定代码);
}
}
SpringJar: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
**:问题:**运行tomcat后,出现以下错误。
2013-05-21 19:08:05581错误org.springframework.web.context.ContextLoader-上下文初始化失败
org.springframework.beans.factory.parsing异常:配置问题:无法从相对位置[camel config.xml]导入bean定义
有问题的资源:ServletContext资源[/WEB-INF/applicationContext.xml];嵌套异常为org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:ServletContext资源[/WEB-INF/camel config.xml]的xml文档中的第2行无效;嵌套异常为org.xml.sax.saxpasseeption;系统ID:http://camel.apache.org/schema/spring/camel-spring.xsd; 行号:2;栏目号:225;TargetNamespace.1:应为命名空间'http://camel.apache.org/schema/spring“,但架构文档的目标命名空间为”http://activemq.apache.org/camel/schema/spring'.
位于org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
位于org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
位于org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
我不明白我错在哪里


有人能帮我吗?

你确定你的
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
。在哪里

有很多问题,我一个接一个地找到了,也按顺序解决了。然而,在其他人的帮助下,我以bried作为结束语

问题/解决办法: 1) 未部署camel-config.xml的Ant目标中存在一些冲突。在问题中提供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
  • camel-mail-2.11.0
  • 骆驼-mina-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

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

您确定您列出的骆驼罐是您的类路径中唯一的吗?Spring似乎试图用另一个jar中可能存在的旧版本的XSD验证xml。共有55个罐子,包括骆驼罐。我不应该问,但如果我发布了这55个jar的列表,是否有可能提出任何想法?是的,我已经在我所有的xml文件中进行了验证。我没有在你猜对的地方用过。事实上,我和我的蚂蚁目标有一点冲突,这实际上并没有反映出变化。现在我已经更正了camel-confix.xml,错误为:嵌套异常为org.springframework.beans.FatalBeanException:命名空间的NamespaceHandler类[org.apache.camel.spring.handler.CamelNamespaceHandler]无效[:处理程序类文件或依赖类有问题;嵌套的异常是java.lang.NoSuchMethodError:org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;我找到了NoSuchMethod的解析,这是jar的不匹配,现在解决了。