I have question about EJB,I want to call ejb from a servlet,but I can't call
it successfully.My EJB locates in follow directory:

F:\login\ejb\loginEJB\CheckPasswordHome.class
F:\login\ejb\loginEJB\CheckPassword.class
F:\login\ejb\loginEJB\CheckPasswordEJB.class
F:\login\ejb\loginEJB\CheckPasswordHome.java
F:\login\ejb\loginEJB\CheckPassword.java
F:\login\ejb\loginEJB\CheckPasswordEJB.java
F:\login\ejb\CheckPassword.jar
F:\login\ejb\META-INF\ejb-jar.xml
F:\login\ejb\META-INF\ejb-jar.xml

I create CheckPassword.jar like follows:
F:\login\ejb\>javac -classpath .;F:\j2sdkee1.3.1\lib\j2ee.jar loginEJB\*.java

//CheckPasswordEJB.java
package loginEJB;
import javax.ejb.SessionContext;
public class CheckPasswordEJB implements javax.ejb.SessionBean
{
public void ejbCreate()
{ }
public void ejbRemove()
{ }
public void ejbActivate()
{ }
public void ejbPassivate()
{ }
public void setSessionContext(SessionContext ctx)
{ }
public String logininformation(String username,String password)
{ System.out.println("ID="+username+",Password="+password);
return "OK";}
}

My servlet locates in follow directory:

D:\Apache Tomcat 4.0\webapps\login\servlets\index.html
D:\Apache Tomcat 4.0\webapps\login\WEB-INF\classes\GetUserIdentity.class

In my index.html,I call my servlet "GetUserIdentity.class",the file "index.html"
is follows:
<html>
<head>
<title>Check Identity</title>
</head>
<body>
<center>
<br><br>
<form action="http://192.168.39.152:8080/login/servlet/GetUserIdentity"
method="POST">
<table align="center" width="%100" cellspacing="2" cellpadding="2">
<tr>
<td align="right">Input ID </td>
<td><input type="Text" name="ID" align="left" size=15></td>
</tr>
<br><br><br>
<tr>
<td align="right">Input Password </td>
<td><input type="password" name="password" align="left" size=15
color="red"></td>
</tr>
</table>
<br><br>
<input type="Submit" name="okbutton" value=" OK " >
<input type="button" name="cancelbutton" value=" Cancel " onclick="window.close()">
</form>
</center>
</body>
<html>

My GetUserIdentity is follows:

import loginEJB.*;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;

public class GetUserIdentity extends HttpServlet
{

public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
String username=request.getParameter("ID");
String password=request.getParameter("password");
String pp=test();
out.println("<html>");
out.println("<title>Login Succeed!</title>");
out.println("<body>");
out.println("<p> ssssYour ID is "+username+"</p>");
out.println("<p> Your Password is "+password+"</p>");
out.println("<p> Message is "+pp+"</p>");
out.println("</body>");
out.println("</html>");
}

}

public String test()
{
try
{

String message = "";
Properties prop=new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL,"t3://192.168.39.152:7001");
Context ctx=new InitialContext(prop);
Object objref=ctx.lookup("CheckPassword");
CheckPasswordHome home=(CheckPasswordHome)javax.rmi.PortableRemoteObject.narrow(
objref,CheckPasswordHome.class);
CheckPassword ss=home.create();
message=ss.logininformation("Mary","456");
System.out.println("Return message:"+message);
ss.remove();

return message;

}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
return "abc";
}
}

}

When I run index.html,and click OK button,it raise follows error:

type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error)
that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Cannot allocate servlet instance for path
/login/servlet/GetUserIdentity
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:415)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.ja va:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
at java.lang.Thread.run(Unknown Source)
root cause
java.lang.NoClassDefFoundError: javax/ejb/EJBObject
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:820)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:615)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:396)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.ja va:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
at java.lang.Thread.run(Unknown Source)

I'm very puzzled with it,because I make a test my ejb program,it can run
at command prompt,my test ejb program like that:

//testEJB.java
import loginEJB.*;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
public class testEJB
{
public static void main(String args[])
{
test();
}
public static void test()
{
try
{
String message;
Properties prop=new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL,"t3://192.168.39.152:7001");
Context ctx=new InitialContext(prop);
Object objref=ctx.lookup("CheckPassword");
CheckPasswordHome home=(CheckPasswordHome)javax.rmi.PortableRemoteObject.narrow(
objref,CheckPasswordHome.class);
CheckPassword ss=home.create();
message=ss.logininformation("Mary","123");
System.out.println("Return message:"+message);
ss.remove();
}
catch(Exception e)
{
e.printStackTrace();
}
}

}

The file testEJB.java locates F:\login\ejb\testEJB.java
When I compile it likes follows:
F:\login\ejb\>javac -classpath .;F:\j2sdkee1.3.1\lib\j2ee.jar;E:\bea\wlserver6.1\lib\weblogic.jar;CheckPassword.jar
testEJB.java

Then I run it like follows:
F:\login\ejb\>java -classpath .;F:\j2sdkee1.3.1\lib\j2ee.jar;E:\bea\wlserver6.1\lib\weblogic.jar;CheckPassword.jar
testEJB

I found testEJB runs well. I'm very puzzled why I put parts code of it into
a servlet,it can't work??? I don't know the reason,Please help me!
Any idea will be appreciated!
Thanks in advances!!!

Edward