我从http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch6.chapt.html#ch6.mdbejbjar.ex复制并粘贴了示例ejb-jar.xml和jboss.xml文件,当JBoss尝试部署它时,我收到以下错误:
ERROR [ScannerThread] deployment.MainDeployer (MainDeployer.java:943) - Could not create deployment: file:/...-ejb2.jar
org.jboss.deployment.DeploymentException: Error in ejb-jar.xml for Message Driven Bean TextMDB: expected one res-ref-name tag
at org.jboss.metadata.ApplicationMetaData.importEjbJarXml(ApplicationMetaData.java:403)
at org.jboss.metadata.XmlFileLoader.load(XmlFileLoader.java:151)
at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:506)
另外,我在Eclipse中注意到我使用的示例ejb-jar.xml文件不符合它的dtd。有没有更好的样本ejb2 mdb我可以看一下?
答案 0 :(得分:1)
为什么不修复部署描述符?试试这个ejb-jar.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>TextMDB</ejb-name>
<ejb-class>org.jboss.chap6.ex2.TextMDB</ejb-class>
<transaction-type>Container</transaction-type>
<acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
<resource-ref>
<res-ref-name>jms/QCF</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>
</enterprise-beans>
</ejb-jar>
答案 1 :(得分:1)
另一个错误的例子。将其更改为符合dtd可以解决问题。
自:
<res-ref-name>jms/QCF</res-ref-name>
<resource-ref>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
要:
<resource-ref>
<res-ref-name>jms/QCF</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>