当前位置: 技术问答>java相关
发布session bean遇错误之二
来源: 互联网 发布时间:2015-01-09
本文导语: 在session bean中操作entity bean 客户端调用时出错,如下: 星期五 六月 08 17:57:30 GMT+08:00 2001: Signaling peer -7633149239751353651C202.104.155.131 gone: weblogic.rjvm.PeerGoneException: - with nested exception: [java.net.SocketException:...
在session bean中操作entity bean
客户端调用时出错,如下:
星期五 六月 08 17:57:30 GMT+08:00 2001: Signaling peer -7633149239751353651C202.104.155.131 gone: weblogic.rjvm.PeerGoneException:
- with nested exception:
[java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read]
星期五 六月 08 17:57:46 GMT+08:00 2001: Transaction: '991994211380_29' rolled back due to EJB exception:
javax.ejb.EJBException
at com.titan.cabin.CabinBeanEOImpl.getShip(CabinBeanEOImpl.java:459)
at com.titan.travelagent.TravelAgentBean.listCabins(TravelAgentBean.java, Compiled Code)
at com.titan.travelagent.TravelAgentBeanEOImpl.listCabins(TravelAgentBeanEOImpl.java:56)
at com.titan.travelagent.TravelAgentBeanEOImpl_WLSkel.invoke(TravelAgentBeanEOImpl_WLSkel.java:75)
at weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(BasicServerObjectAdapter.java, Compiled Code)
at weblogic.rmi.extensions.BasicRequestHandler.handleRequest(BasicRequestHandler.java, Compiled Code)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java, Compiled Code)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
在客户端调用entity bean时没有问题。
entity bean的Transaction isolation level为TRANSACTION_READ_UNCOMMITTED
因为我用的是sql server7.0,由于它不支持TRANSACTION_SERIALIZABLE,我没试。
请教各位。
bean 的代码如下:
package com.titan.travelagent;
import com.titan.cabin.Cabin;
import com.titan.cabin.CabinHome;
import com.titan.cabin.CabinPK;
import java.rmi.RemoteException;
import javax.naming.InitialContext;
import javax.naming.Context;
import java.util.Properties;
import java.util.Vector;
import javax.ejb.EJBException;
import weblogic.jndi.WLInitialContextFactory;
public class TravelAgentBean implements javax.ejb.SessionBean {
public void ejbCreate() {
// Do nothing.
}
public String [] listCabins(int shipID, int bedCount) {
try {
javax.naming.Context jndiContext = getWeblogicInitialContext();
Object obj = jndiContext.lookup("CabinBean");
CabinHome home = (CabinHome)
javax.rmi.PortableRemoteObject.narrow(obj, CabinHome.class);
Vector vect = new Vector();
CabinPK pk = new CabinPK();
Cabin cabin;
for(int i = 1; ; i++){
pk.id = i;
try {
cabin = home.findByPrimaryKey(pk);
} catch(javax.ejb.FinderException fe){
break;
}
// Check to see if the bed count and ship ID match.
if (cabin.getShip() == shipID &&
cabin.getBedCount() == bedCount){
String details =
i+","+cabin.getName()+","+cabin.getDeckLevel();
vect.addElement(details);
}
}
String [] list = new String[vect.size()];
vect.copyInto(list);
return list;
} catch(javax.naming.NamingException ne){
throw new EJBException(ne);
} catch(java.rmi.RemoteException re){
throw new EJBException(re);
}
}
private javax.naming.Context getInitialContext()
throws javax.naming.NamingException{
Properties p = new Properties();
// ... Specify the JNDI properties specific to the vendor.
return new javax.naming.InitialContext(p);
}
public void ejbRemove(){}
public void ejbActivate(){}
public void ejbPassivate(){}
public void setSessionContext(javax.ejb.SessionContext cntx){}
public static Context getWeblogicInitialContext()
throws javax.naming.NamingException {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://bingo:7001");
return new InitialContext(p);
}
}
ejb-jar.xml如下:
TravelAgentBean
com.titan.travelagent.TravelAgentHome
com.titan.travelagent.TravelAgent
com.titan.travelagent.TravelAgentBean
Stateless
Container
ejb/CabinBean
Entity
com.titan.cabin.CabinHome
com.titan.cabin.Cabin
This role represents everyone who is allowed full access
to the cabin bean.
everyone
everyone
TravelAgentBean
*
TravelAgentBean
*
Required
各位ggddjjmm帮忙呀!
真是郁闷!
客户端调用时出错,如下:
星期五 六月 08 17:57:30 GMT+08:00 2001: Signaling peer -7633149239751353651C202.104.155.131 gone: weblogic.rjvm.PeerGoneException:
- with nested exception:
[java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read]
星期五 六月 08 17:57:46 GMT+08:00 2001: Transaction: '991994211380_29' rolled back due to EJB exception:
javax.ejb.EJBException
at com.titan.cabin.CabinBeanEOImpl.getShip(CabinBeanEOImpl.java:459)
at com.titan.travelagent.TravelAgentBean.listCabins(TravelAgentBean.java, Compiled Code)
at com.titan.travelagent.TravelAgentBeanEOImpl.listCabins(TravelAgentBeanEOImpl.java:56)
at com.titan.travelagent.TravelAgentBeanEOImpl_WLSkel.invoke(TravelAgentBeanEOImpl_WLSkel.java:75)
at weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(BasicServerObjectAdapter.java, Compiled Code)
at weblogic.rmi.extensions.BasicRequestHandler.handleRequest(BasicRequestHandler.java, Compiled Code)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java, Compiled Code)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
在客户端调用entity bean时没有问题。
entity bean的Transaction isolation level为TRANSACTION_READ_UNCOMMITTED
因为我用的是sql server7.0,由于它不支持TRANSACTION_SERIALIZABLE,我没试。
请教各位。
bean 的代码如下:
package com.titan.travelagent;
import com.titan.cabin.Cabin;
import com.titan.cabin.CabinHome;
import com.titan.cabin.CabinPK;
import java.rmi.RemoteException;
import javax.naming.InitialContext;
import javax.naming.Context;
import java.util.Properties;
import java.util.Vector;
import javax.ejb.EJBException;
import weblogic.jndi.WLInitialContextFactory;
public class TravelAgentBean implements javax.ejb.SessionBean {
public void ejbCreate() {
// Do nothing.
}
public String [] listCabins(int shipID, int bedCount) {
try {
javax.naming.Context jndiContext = getWeblogicInitialContext();
Object obj = jndiContext.lookup("CabinBean");
CabinHome home = (CabinHome)
javax.rmi.PortableRemoteObject.narrow(obj, CabinHome.class);
Vector vect = new Vector();
CabinPK pk = new CabinPK();
Cabin cabin;
for(int i = 1; ; i++){
pk.id = i;
try {
cabin = home.findByPrimaryKey(pk);
} catch(javax.ejb.FinderException fe){
break;
}
// Check to see if the bed count and ship ID match.
if (cabin.getShip() == shipID &&
cabin.getBedCount() == bedCount){
String details =
i+","+cabin.getName()+","+cabin.getDeckLevel();
vect.addElement(details);
}
}
String [] list = new String[vect.size()];
vect.copyInto(list);
return list;
} catch(javax.naming.NamingException ne){
throw new EJBException(ne);
} catch(java.rmi.RemoteException re){
throw new EJBException(re);
}
}
private javax.naming.Context getInitialContext()
throws javax.naming.NamingException{
Properties p = new Properties();
// ... Specify the JNDI properties specific to the vendor.
return new javax.naming.InitialContext(p);
}
public void ejbRemove(){}
public void ejbActivate(){}
public void ejbPassivate(){}
public void setSessionContext(javax.ejb.SessionContext cntx){}
public static Context getWeblogicInitialContext()
throws javax.naming.NamingException {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://bingo:7001");
return new InitialContext(p);
}
}
ejb-jar.xml如下:
TravelAgentBean
com.titan.travelagent.TravelAgentHome
com.titan.travelagent.TravelAgent
com.titan.travelagent.TravelAgentBean
Stateless
Container
ejb/CabinBean
Entity
com.titan.cabin.CabinHome
com.titan.cabin.Cabin
This role represents everyone who is allowed full access
to the cabin bean.
everyone
everyone
TravelAgentBean
*
TravelAgentBean
*
Required
各位ggddjjmm帮忙呀!
真是郁闷!
|
事务处理的问题