使用带有Wildfly 8的mail-service.xml在服务器启动时发送Mail - IllegalStateException

时间:2015-07-08 08:38:26

标签: java xml jboss wildfly-8 mail-server

我正在尝试在Wildfly 8中使用mail-service.xml。它必须在服务器启动时发送邮件。当我启动Wildfly时出现此错误。我的文件位于deployments文件夹中。

这是错误:

    2015-07-08 10:20:22,884 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."mail-service.xml".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."mail-service.xml".PARSE: JBAS018733: Failed to process phase PARSE of deployment "mail-service.xml"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_45]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_45]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS017224: Failed to parse service xml ["/C:/foo/wildfly-8.2.0.Final/bin/content/mail-service.xml"]
    at org.jboss.as.service.ServiceDeploymentParsingProcessor.deploy(ServiceDeploymentParsingProcessor.java:102)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
    ... 5 more
Caused by: java.lang.IllegalStateException: Current state START_ELEMENT is not among the statesCHARACTERS, COMMENT, CDATA, SPACE, ENTITY_REFERENCE, DTD valid for getText() 
    at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.getText(Unknown Source) [rt.jar:1.8.0_45]
    at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.getText(XMLExtendedStreamReaderImpl.java:275)
    at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.unexpectedContent(JBossServiceXmlDescriptorParser.java:638)
    at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.parseAttribute(JBossServiceXmlDescriptorParser.java:386)
    at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.parseMBean(JBossServiceXmlDescriptorParser.java:268)
    at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.readElement(JBossServiceXmlDescriptorParser.java:192)
    at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.readElement(JBossServiceXmlDescriptorParser.java:48)
    at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
    at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)
    at org.jboss.as.service.ServiceDeploymentParsingProcessor.deploy(ServiceDeploymentParsingProcessor.java:95)
    ... 6 more

这是我的mail-service.xml:

<?xml version="1.0" encoding="UTF-8"?>
    <server>
      <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail">
        <attribute name="JNDIName">java:/Mail</attribute>
        <attribute name="User">user</attribute>
        <attribute name="Password">password</attribute>
        <attribute name="Configuration">
           <!-- Test -->
           <configuration>
              <!-- Change to your mail server prototocol -->
              <property name="mail.store.protocol" value="pop3"/>
              <property name="mail.transport.protocol" value="smtp"/>

              <!-- Change to the user who will receive mail  -->
              <property name="mail.user" value="user"/>

              <!-- Change to the mail server  -->
              <property name="mail.pop3.host" value="foo.pop3"/>

              <!-- Change to the SMTP gateway server -->
              <property name="mail.smtp.host" value="foo.smtp"/>

              <!-- Change to the address mail will be from  -->
              <property name="mail.from" value="foo@foo.com"/>

              <!-- Enable debugging output from the javamail classes -->
              <property name="mail.debug" value="false"/>
           </configuration>
        </attribute>
      </mbean>

    </server>

我已经检查了我的XML,但找不到任何XML错误。

1 个答案:

答案 0 :(得分:0)

我不知道如何使用像JBoss 5/6中的mail-service.xml文件那样做(或者甚至可以做到),但你可以通过在JBoss 7中注册资源来做到这一点以两种不同的方式:

  • 在$ {wildfly-home} / standalone / configuration中编辑standalone.xml:check this link
  • 在localhost:9990 / console中使用管理控制台:检查this linkthis other

此致