java 无法在 WebLogic server 12c 中部署 EJB
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9875109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Not able to deploy EJB in WebLogic server 12c
提问by Rohit Elayathu
I have created a EJB, created a jar of it( containing required ejb-jar.xml and weblogic-ejb-jar.xml files).
我创建了一个 EJB,创建了一个它的 jar(包含所需的 ejb-jar.xml 和 weblogic-ejb-jar.xml 文件)。
when i add this jar to weblogic server 12c, using admin console, i get following issue-
当我使用管理控制台将此 jar 添加到 weblogic server 12c 时,出现以下问题-
Issues were encountered while parsing this deployment to determine module type. Assuming this is a library deployment.
Due to this my ejb is not shown in jndi tree view. So I am not able to do my jndi lookup. Please rectify my error.
因此,我的 ejb 未显示在 jndi 树视图中。所以我无法进行 jndi 查找。请纠正我的错误。
ejb-jar.xml-
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 id="ejb-jar_ID">
<display-name>ProductManager</display-name>
<enterprise-beans>
<session>
<ejb-name>Product</ejb-name>
<home>rohit.ProductHome</home>
<remote>rohit.ProductRemote</remote>
<ejb-class>rohit.ProductBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<ejb-client-jar>ProductManagerClient.jar</ejb-client-jar>
</ejb-jar>
weblogic-ejb-jar.xml-
weblogic-ejb-jar.xml-
<?xml version=“1.0? encoding=“UTF-8??>
<weblogic-ejb-jar
xmlns=“http://www.bea.com/ns/weblogic/90? xmlns:j2ee=“http://java.sun.com/xml/ns/j2ee” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd”>
<welogic-enterprise-bean>
<ejb-name>Product</ejb-name>
<jndi-name>Product</jndi-name>
<stateless-session-descriptor></stateless-session-descriptor>
</welogic-enterprise-bean>
</weblogic-ejb-jar>
回答by Arjan Tijms
Contrary to what you seem to be thinking, the ejb-jar.xml and weblogic-ejb-jar.xml files are not required. As primary deployment descriptors they are ancient artifacts from 2004.
与您的想法相反,不需要 ejb-jar.xml 和 weblogic-ejb-jar.xml 文件。作为主要部署描述符,它们是 2004 年的古老工件。
Your ProductHome
class should also be removed if you value your sanity. This is an EJB2 artifact that's completely and utterly unnecessary this time of age.
ProductHome
如果您重视自己的理智,您的课程也应该被删除。这是一个 EJB2 工件,在这个时代完全没有必要。
To get started with EJB, all you need is a POJO with an @Stateless
annotation:
要开始使用 EJB,您只需要一个带有@Stateless
注释的 POJO :
@Stateless
public class ProductBean {
// ...
}
Jar this up and deploy it. That's all. You don't have to explicitly name your bean (it will get a name) and you certainly don't have to declare its existence in some XML file.
将其打包并部署。就这样。您不必显式命名您的 bean(它将获得一个名称)并且您当然不必在某些 XML 文件中声明它的存在。
回答by Eva Troels
The ejb-jar.xml is mandatory when deploying an application as a jar file. The correct place to put it is in the META-INF in the jar.
将应用程序部署为 jar 文件时,ejb-jar.xml 是必需的。正确的放置位置是在罐子里的 META-INF 中。
Yes, annotations are definitely nice and easier to maintain. Try this by leaving the ejb-jar.xml minimal.
是的,注释绝对是好的并且更容易维护。通过将 ejb-jar.xml 保留最少来尝试此操作。
I always package my applications in EAR with the jars inside. In this case an application.xml file is needed.
我总是将我的应用程序与里面的罐子一起打包在 EAR 中。在这种情况下,需要一个 application.xml 文件。
It sounds like the container does not recognize the jar as an application. Check the position of the ejb-jar.xml or use EAR packaging.
听起来容器无法将 jar 识别为应用程序。检查ejb-jar.xml 的位置或使用EAR 包装。
回答by user3566274
Oracle recommends that even standalone EJBs be packed as an EAR file. The EJB descriptors should be inside the META-INF of the ejb-module. See this link for the EAR structure for more details. http://docs.oracle.com/cd/E24329_01/web.1211/e24368/splitcreate.htm#i1103260
Oracle 建议甚至将独立的 EJB 打包为 EAR 文件。EJB 描述符应该在 ejb 模块的 META-INF 内。有关 EAR 结构的更多详细信息,请参阅此链接。 http://docs.oracle.com/cd/E24329_01/web.1211/e24368/splitcreate.htm#i1103260