EJB 2.0 Jar в Tomcat 6 и OpenEJB 3.1.4 - PullRequest
       31

EJB 2.0 Jar в Tomcat 6 и OpenEJB 3.1.4

0 голосов
/ 01 августа 2011
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 ? :(

Ответы [ 2 ]

1 голос
/ 01 августа 2011

Поместите myHelloEjb.jar в каталог WEB-INF / lib / примера веб-приложения, и он должен работать.

0 голосов
/ 26 сентября 2011

Вы писали:

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

Нет

...