JBoss 6 - 在战争包装中部署ejb [英] JBoss 6 - Deploy ejb in war packaging

查看:128
本文介绍了JBoss 6 - 在战争包装中部署ejb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用新的EJB3.1功能,其中可以部署在.war文件中打包的EJB。

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

我正在使用Maven 2.2.1来打包EJB模块,然后将ejb jar放入war模块中(作为依赖项)。最后的战争包含一个没有内容的简单web.xml,以及lib目录中的ejb jar库。但是,尽管正确部署了应用程序,但容器无法识别带注释的ejb(@Stateless)。我没有ejb-jar.xml描述符(我认为它在EJB3中是可选的)。

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).

如果我自己部署ejb jar(通过在部署中删除它) JBoss中的目录)它部署了一个指定的jndi名称。

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?

推荐答案

我发现了这个问题。我的web.xml是2.4版本:

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">

但是,对于要在war包中部署的EJB,它至少需要3.0:

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">

这主要是因为我使用J2EE Maven原型创建了我的war模块。

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

这篇关于JBoss 6 - 在战争包装中部署ejb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆