JBoss 6 - Deploy ejb in war packaging

拥有回忆 提交于 2019-12-19 04:09:41

问题


I am trying to use the new EJB3.1 feature where one can deploy an EJB packaged within a .war file.

I am using Maven 2.2.1 to package the EJB module and then dropping the ejb jar in a war module (as a dependency). The final war contains a simple web.xml with no content, and the ejb jar library in the lib directory. However, though the application is deployed correctly, the annotated ejb (@Stateless) is not recognized by the container. I have no ejb-jar.xml descriptor (which I believe is optional in EJB3).

If I deploy the ejb jar on its own (by dropping it in the deploy directory in JBoss) it is deployed an assigned a jndi name.

Am I missing something here?


回答1:


I found the problem on this one. My web.xml was 2.4 version:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
  version="2.4">

However, for EJBs to be deployed in war packages, it needs to be 3.0 at least:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
      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/web-app_3_0.xsd"
      version="3.0">

This was mainly due to the fact that I was creating my war module with a J2EE Maven archetype.



来源:https://stackoverflow.com/questions/5213174/jboss-6-deploy-ejb-in-war-packaging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!