Tomcat为什莫不能调用EJB?

03-08-17 lyojbuilder
我写了一个简单的session EJB,当客户调用它时返回一个Hello world.我用sun的deploytool都部署成功了,说明代码没有错误,但我又在同一台计器上运行Tomcat,我想在Tomcat中调用这个EJB,但Tomcat总说找不到Home接口?!这个在Tomcat上测试的jsp文件很简单:

///////////////////////invokeEJB.jsp////////////////////////////////

<%@page import="javax.ejb.*,javax.naming.*"%>

........... ......... ................. ............

try{

Context ctx=new InitialContext();

Object obj=ctx.lookup("java:comp/env/ejb/Hello");

HelloHome home=(HelloHome)PortableRemoteObject.narrow(obj,HelloHome.class);

Hello hello=home.create();

out.println(hello.getHello());

}catch(Exception e){

out.println(e.toString());

}

........... .......... ............ ......................

但是一执行,Tomcat就报错:

org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.

An error occured between lines: 7 and 17 in the jsp file: /ejb/invokeejb.jsp

Generated servlet error:

g:\j2sdkee1.3\repository\lyo\web\ejb\_0002fejb_0002finvokeejb_jsp.java:64: Class org.apache.jsp.HelloHome not found.

HelloHome home=(HelloHome)PortableRemoteObject.narrow(obj,HelloHome.class);

^

An error occured between lines: 7 and 17 in the jsp file: /ejb/invokeejb.jsp

Generated servlet error:

g:\j2sdkee1.3\repository\lyo\web\ejb\_0002fejb_0002finvokeejb_jsp.java:64: Class org.apache.jsp.HelloHome not found.

HelloHome home=(HelloHome)PortableRemoteObject.narrow(obj,HelloHome.class);

^

An error occured between lines: 7 and 17 in the jsp file: /ejb/invokeejb.jsp

Generated servlet error:

g:\j2sdkee1.3\repository\lyo\web\ejb\_0002fejb_0002finvokeejb_jsp.java:64: Undefined variable or class name: PortableRemoteObject

HelloHome home=(HelloHome)PortableRemoteObject.narrow(obj,HelloHome.class);

^

An error occured between lines: 7 and 17 in the jsp file: /ejb/invokeejb.jsp

Generated servlet error:

g:\j2sdkee1.3\repository\lyo\web\ejb\_0002fejb_0002finvokeejb_jsp.java:65: Class org.apache.jsp.Hello not found.

Hello hello=home.create();

^

4 errors, 1 warning

/////////////////////////////////////////////////////

我用的是sun的j2EE server没有问题,怎麽回事?请高手指点!

sprsong
2003-08-17 16:38
tomcat需要加入j2ee.jar

lyojbuilder
2003-08-17 18:10
可我已经把j2ee.jar和HelloClient.jar全加上了

jian
2003-08-19 07:47
tomcat only has a servlet container. It does not support

EJB. However, you can use it if it is integrated with

a EJB container, such as jboss from www.jboss.org

or openEJB. Now jboss has tomcat bundled as deport servlet

container.

Don't bother to use Sun's reference implementation.

It is buggy and no body ever uses in production.

Try www.jboss.org at least.

Good luck.

猜你喜欢