gpt4 book ai didi

java - ejb-jar.xml 环境条目枚举

转载 作者:行者123 更新时间:2023-12-01 14:59:44 27 4
gpt4 key购买 nike

这是我的 ejb-jar.xml:

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

<ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee"
version = "3.0"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">

<enterprise-beans>
<session>
<ejb-name>EmailEjb</ejb-name>
<env-entry>
<env-entry-name>java:app/env/smtp.host</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>smtp.mandrillapp.com</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>java:app/env/smtp.port</env-entry-name>
<env-entry-type>java.lang.Integer</env-entry-type>
<env-entry-value>587</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>java:app/env/smtp.transportStrategy</env-entry-name>
<env-entry-type>org.codemonkey.simplejavamail.TransportStrategy</env-entry-type>
<env-entry-value>SMTP_TLS</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>java:app/env/smtp.username</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>user@example.com</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>java:app/env/smtp.password</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>foobar</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
</ejb-jar>

部署后,我收到此异常:

org.xml.sax.SAXParseException; lineNumber: 23; columnNumber: 85; Deployment descriptor file WEB-INF/ejb-jar.xml in archive [localgp-web-1.0-SNAPSHOT]. cvc-enumeration-valid: Value 'org.codemonkey.simplejavamail.TransportStrategy' is not facet-valid with respect to enumeration '[java.lang.Boolean, java.lang.Byte, java.lang.Character, java.lang.String, java.lang.Short, java.lang.Integer, java.lang.Long, java.lang.Float, java.lang.Double]'. It must be a value from the enumeration.

这似乎表明,尽管 the documentation ,不允许使用枚举。或者是否发生了其他我可能错过的事情?

最佳答案

NetBeans 7.2.1(目前最新版本)为 EJB 规范 3.0 版生成 ejb-jar.xml,该规范不将枚举识别为 env-entry-type。将其更改为版本 3.1 可以解决问题并且资源可以正确注入(inject)。

<ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee" 
version = "3.1"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">

<!-- Stuff goes here. -->

</ejb-jar>

关于java - ejb-jar.xml 环境条目枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13843899/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com