请问这个错误是什么原因引起的 一定要保证正确部署了你所使用的ejb。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个问题应该是你的servlet找不到你的BEAN的home接口。可以通过import来解决。或者一个简单但是有点笨的方法,你就直接把home接口的.class文件拷到和你的servlet一个目录下面。 ClusterableRemoteRef(90.90.190.71 [90.90.190.71])/292就是从已经布署的EJB中找到的数据;错误是:firstejbHomes = (firstejbHome)PortableRemoteObject.narrow(ref, firstejbHome.class);引起的,但是这句话看来看去都不像错,而且里面小改一下,就不能编译(这样写可以编译,在JSP中调用时出的错);也不知道是什么原故 程序是这样的:package ejbclass;import java.rmi.*;import javax.ejb.*;import java.io.*;public class firstejb implements SessionBean{ private SessionContext sessionContext; public void ejbCreate() { } public void ejbRemove() { } public void ejbActivate() { } public void ejbPassivate() { } public void setSessionContext(SessionContext sessionContext) { this.sessionContext=sessionContext; } public String hello() { //System.out.print("hello world"); return "hello world"; }}===================================================================package ejbclass;import java.rmi.*;import javax.ejb.*;public interface firstejbHome extends EJBHome{ public firstejbRemote create() throws RemoteException,CreateException;}==============================================================================package ejbclass;import java.rmi.*;import javax.ejb.*;public interface firstejbRemote extends EJBObject{ String hello() throws java.rmi.RemoteException;}===============================================================================<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd"><ejb-jar> <enterprise-beans> <session> <ejb-name>firstejb</ejb-name> <home>ejbclass.firstejbHome</home> <remote>ejbclass.firstejbRemote</remote> <ejb-class>ejbclass.firstejb</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> </enterprise-beans> <assembly-descriptor> <container-transaction> <method> <ejb-name>firstejb</ejb-name> <method-name>*</method-name> </method> <trans-attribute>Required</trans-attribute> </container-transaction> </assembly-descriptor></ejb-jar>======================================================================<!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN' 'http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd'><weblogic-ejb-jar> <weblogic-enterprise-bean> <ejb-name>firstejb</ejb-name> <jndi-name>firstejb</jndi-name> </weblogic-enterprise-bean></weblogic-ejb-jar>======================================================================import javax.naming.*;import java.util.Properties;import javax.rmi.PortableRemoteObject;import ejbclass.*;public class firstejbClient { private static final String ERROR_NULL_REMOTE = "Remote interface reference is null. It must be created by calling one of the Home interface methods first."; private static final int MAX_OUTPUT_LINE_LENGTH = 100; private boolean logging = true; private firstejbHome firstejbHomes=null; private firstejbRemote firstejb = null; //Construct the EJB test client public firstejbClient() { try{ //get naming context Context ctx = getInitialContext(); //look up jndi name Object ref = ctx.lookup("firstejb"); System.out.print(ref); //cast to Home interface firstejbHomes = (firstejbHome)PortableRemoteObject.narrow(ref, firstejbHome.class); } catch(Exception e) { System.out.print("error in this"); } } private Context getInitialContext() throws Exception { String url = "t3://localhost:7001"; String user = null; String password = null; Properties properties = null; try { properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); properties.put(Context.PROVIDER_URL, url); if (user != null) { properties.put(Context.SECURITY_PRINCIPAL, user); properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password); } //Context cn=new InitialContext(properties); //System.out.print(PortableRemoteObject.narrow(cn.lookup("firstejb"),firstejbHome.class)); return new InitialContext(properties); } catch(Exception e) { throw e; } } public firstejbRemote create() { try { firstejb = firstejbHomes.create(); } catch(Exception e) { e.printStackTrace(); } if (logging) { } return firstejb; } public String sayhello() throws Exception { firstejb = firstejbHomes.create(); return firstejb.hello(); //return "heklkl"; } public String sayhello1() throws Exception { return "heklkl"; }} 你把你部署的ejb的jar文件加到你jbuilder这个project的classpath中,放到最前面 jsp 中如何更好的操作数据库 spring service 线程安全问题 struts tiles 的问题 请问现在用jdk1.4过不过时? 难题:JAVA 怎么关闭系统进程 字符分割分问题 在JSP中,下面这段代码如何解释? 有关JTable的问题 ####################findByPrimaryKey问题#####################在线 Extjs上传文件 如何在pc甲上访问pc乙上的Ejb? jsp中调用EJB,找不着BEAN的类的问题。
就是从已经布署的EJB中找到的数据;
错误是:
firstejbHomes = (firstejbHome)PortableRemoteObject.narrow(ref, firstejbHome.class);
引起的,但是这句话看来看去都不像错,而且里面小改一下,就不能编译(这样写可以编译,在JSP中调用时出的错);也不知道是什么原故
程序是这样的:package ejbclass;import java.rmi.*;
import javax.ejb.*;
import java.io.*;public class firstejb implements SessionBean
{
private SessionContext sessionContext;
public void ejbCreate()
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}
public void setSessionContext(SessionContext sessionContext)
{
this.sessionContext=sessionContext;
}
public String hello()
{
//System.out.print("hello world");
return "hello world";
}
}
===================================================================
package ejbclass;import java.rmi.*;
import javax.ejb.*;public interface firstejbHome extends EJBHome
{
public firstejbRemote create() throws RemoteException,CreateException;
}
==============================================================================
package ejbclass;import java.rmi.*;
import javax.ejb.*;public interface firstejbRemote extends EJBObject
{
String hello() throws java.rmi.RemoteException;
}
===============================================================================
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>firstejb</ejb-name>
<home>ejbclass.firstejbHome</home>
<remote>ejbclass.firstejbRemote</remote>
<ejb-class>ejbclass.firstejb</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>firstejb</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor></ejb-jar>
======================================================================
<!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN' 'http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd'>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>firstejb</ejb-name>
<jndi-name>firstejb</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
======================================================================import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
import ejbclass.*;public class firstejbClient {
private static final String ERROR_NULL_REMOTE = "Remote interface reference is null. It must be created by calling one of the Home interface methods first.";
private static final int MAX_OUTPUT_LINE_LENGTH = 100;
private boolean logging = true;
private firstejbHome firstejbHomes=null;
private firstejbRemote firstejb = null; //Construct the EJB test client
public firstejbClient()
{
try{
//get naming context
Context ctx = getInitialContext();
//look up jndi name
Object ref = ctx.lookup("firstejb");
System.out.print(ref); //cast to Home interface
firstejbHomes = (firstejbHome)PortableRemoteObject.narrow(ref, firstejbHome.class);
}
catch(Exception e)
{
System.out.print("error in this");
}
} private Context getInitialContext() throws Exception {
String url = "t3://localhost:7001";
String user = null;
String password = null;
Properties properties = null;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
}
//Context cn=new InitialContext(properties);
//System.out.print(PortableRemoteObject.narrow(cn.lookup("firstejb"),firstejbHome.class));
return new InitialContext(properties);
}
catch(Exception e) {
throw e;
}
} public firstejbRemote create() { try {
firstejb = firstejbHomes.create();
}
catch(Exception e) {
e.printStackTrace(); } if (logging) {
}
return firstejb;
}
public String sayhello() throws Exception
{
firstejb = firstejbHomes.create();
return firstejb.hello();
//return "heklkl";
}
public String sayhello1() throws Exception
{
return "heklkl";
}
}