当前位置: 代码迷 >> Java Web开发 >> [求助]有状态会话Bean出现的问题
  详细解决方案

[求助]有状态会话Bean出现的问题

热度:453   发布时间:2006-12-19 14:39:16.0
[求助]有状态会话Bean出现的问题
我运行客户端测试的时候出现这个提示信息,请问是何意思?
javax.naming.NameNotFoundException: Unable to resolve 'CountHome'. Resolved '' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'CountHome'. Resolved '']; remaining name 'CountHome'
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:195)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:338)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:252)
at weblogic.jndi.internal.ServerNamingNode_920_WLStub.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:374)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:362)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at examples.CountClient.main(CountClient.java:19)
Caused by: javax.naming.NameNotFoundException: Unable to resolve 'CountHome'. Resolved ''
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:252)
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:171)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:517)
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:224)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:407)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:403)
at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:56)
at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:934)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
搜索更多相关主题的帖子: Bean  状态  会话  cluster  java  

----------------解决方案--------------------------------------------------------
你用的是EJB3.0的话,把代码帖上来,我帮你看看

如果不是的话,那我也不太清楚了
----------------解决方案--------------------------------------------------------

我做的是精通EJB(第三版)里面的例子,开发平台是JB2006+weblogic9.0
远程接口
package examples;

import javax.ejb.*;
import java.rmi.RemoteException;

public interface Count extends EJBObject {
public int count() throws RemoteException;
}

Bean类
package examples;

import javax.ejb.*;

public class CountBean implements SessionBean {
public int val;
public int count() {
System.out.println("count()");
return++val;
}

public void ejbCreate(int val) throws CreateException {
this.val = val;
System.out.println("ejbCreate()");
}

public void ejbRemove() {
System.out.println("ejbRemove()");
}

public void ejbActivate() {
System.out.println("ejbActivate()");
}

public void ejbPassivate() {
System.out.println("ejbPassivate()");
}

public void setSessionContext(SessionContext ctx) {
System.out.println("setSessionContext()");
}
}

Home接口
package examples;

import javax.ejb.*;
import java.rmi.RemoteException;

public interface CountHome extends EJBHome {
Count create(int val) throws RemoteException, CreateException;
}


weblogic-ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<weblogic-enterprise-bean>
<ejb-name>Count</ejb-name>
<jndi-name>CountHome</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>

ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

<ejb-jar>
<display-name>EJBModule1</display-name>
<enterprise-beans>
<session>
<ejb-name>Count</ejb-name>
<home>examples.CountHome</home>
<remote>examples.Count</remote>
<ejb-class>examples.CountBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>




----------------解决方案--------------------------------------------------------
EJB2.X我不会

我一直都在看EJB3.0

它不用XML文件来配置,并且也变得非常简单了,用元数据注释就OK了

建议你去看看EJB3.0,简单易用,功能强大

呵呵
----------------解决方案--------------------------------------------------------
EJB3.0是最新的吗,和旧版本有什么区别?
----------------解决方案--------------------------------------------------------

学EJB3.0不需要EJB2.X的基础

全新的概念,并且比EJB2.X容易很多,不需要任何XML配置


----------------解决方案--------------------------------------------------------
  相关解决方案