gpt4 book ai didi

tomcat - Tomcat 6 和 OpenEJB 3.1.4 中的 EJB 2.0 Jar

转载 作者:行者123 更新时间:2023-11-28 23:07:05 25 4
gpt4 key购买 nike

I have a simple EJBJar ,Say myHelloEjb.jar
Having 1.HelloBean.java
2.HelloObject.java
3.HelloHome.java



I put the the jar in Tomcat's lib folder and in Tomcat's examples directory I have a jsp openejb.jsp.Code Snippet :

InitialContext initCtx = new InitialContext();

Object object = initCtx.lookup("java:comp/env/ejb/Hello");
HelloHome helloHome = (HelloHome)
javax.rmi.PortableRemoteObject.narrow(object, HelloHome.class);
HelloObject bean = helloHome.create();

And added web.xml in examples web-inf folder as :

<ejb-local-ref>
<ejb-ref-name>ejb/Hello</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>org.acme.HelloHome</local-home>
<local>org.acme.HelloHome</local>
</ejb-local-ref>


When i am calling http://localhost:8080/examples/openejb.jsp
getting :

Aug 1, 2011 6:05:08 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
javax.naming.NamingException: ejb-ref deploymentId is null
at org.apache.openejb.tomcat.common.EjbFactory.buildJndiName(EjbFactory.java:64)
at org.apache.openejb.tomcat.common.AbstractObjectFactory.getObjectInstance(AbstractObjectFactory.java:43)
at org.apache.openejb.tomcat.common.EjbFactory.getObjectInstance(EjbFactory.java:50)
at org.apache.naming.factory.EjbFactory.getObjectInstance(EjbFactory.java:161)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.apache.jsp.openejb_jsp._jspService(openejb_jsp.java:70)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


and in openejb.log,getting :

Deployed Application(path=D:\apache-tomcat-6.0.32\webapps\docs)
2011-08-01 18:06:38,445 - INFO - Configuring enterprise application: D:\apache-tomcat-6.0.32\webapps\examples
2011-08-01 18:06:38,821 - WARN - Unresolved ejb reference "ejb/Hello" in bean "D:\apache-tomcat-6.0.32\webapps\examples". Will attempt resolution again at runtime.
2011-08-01 18:06:38,821 - INFO - Enterprise application "D:\apache-tomcat-6.0.32\webapps\examples" loaded.
2011-08-01 18:06:38,821 - INFO - Assembling app: D:\apache-tomcat-6.0.32\webapps\examples

Could anybody put some light where did i make mistake ? :(

最佳答案

将 myHelloEjb.jar 放在示例 webapp 的 WEB-INF/lib/目录中,它应该可以工作。

关于tomcat - Tomcat 6 和 OpenEJB 3.1.4 中的 EJB 2.0 Jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6898649/

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