Tomcat 6 和 EJB 2.0 Jar OpenEJB 3.1.4

发布于 2024-11-27 10:35:35 字数 3105 浏览 3 评论 0原文

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 ? :(
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 ? :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故笙诉离歌 2024-12-04 10:35:35

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

Put the myHelloEjb.jar in the WEB-INF/lib/ directory of the examples webapp and it should work.

墨离汐 2024-12-04 10:35:35

您写道:

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

看起来您的问题可能是(可能是)这个:

    <local>org.acme.HelloHome</local> 

而不是这个:

    <local>org.acme.Hello</local> 

不?

You wrote:

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

Looks like your problem might be (might have been) this:

    <local>org.acme.HelloHome</local> 

instead of this:

    <local>org.acme.Hello</local> 

No?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文