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 ? :(
0
A
답변
1
예제 webapp의 WEB-INF/lib/디렉토리에 myHelloEjb.jar를 넣으십시오.
0
당신이 쓴 :
<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>
아니오?
+0
안녕하십니까. 여기에 오신 것을 환영합니다. 이유를 설명하는 것이 좋습니다. 방법뿐만 아니라 솔루션을 사용하십시오. 그것은 당신의 대답을 더 가치있게 만들 것이며 당신이 그것을 어떻게하는지 더 잘 이해할 수 있도록 독자를 돕습니다. 또한 FAQ (http://stackoverflow.com/faq)를 살펴 보시기 바랍니다. – ForceMagic
덕분에 다윗,하지만 난 여전히 다음과 같은 예외가 점점 오전 : – Max
감사 데이비드을,하지만 난 여전히 점점 오전 : 서블릿 : 2011년 8월 3일 오후 2시 8분 39초 org.apache.catalina.core.StandardWrapperValve는 심각한를 호출합니다. 서블릿 JSP 대한 서비스()는 예외가 발생했습니다 javax.naming.NamingException : EJB-REF deploymentId는 org.apache에서 org.apache.openejb.tomcat.common.EjbFactory.buildJndiName (EjbFactory.java:64)에서 \t \t 널 .openejb.cn. ache.naming.factory.EjbFactory.getObjectInstance (EjbFactory.java:161) – Max
아직 이해할 수 있습니다. --- >> ejb-ref deploymentId가 null입니다. – Max