Tomcat 6 和 EJB 2.0 Jar OpenEJB 3.1.4
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 myHelloEjb.jar 放入示例 webapp 的 WEB-INF/lib/ 目录中,它应该可以工作。
Put the myHelloEjb.jar in the WEB-INF/lib/ directory of the examples webapp and it should work.
您写道:
看起来您的问题可能是(可能是)这个:
而不是这个:
不?
You wrote:
Looks like your problem might be (might have been) this:
instead of this:
No?