当问题变成死结的时候。

lanfengjiyue 2003-05-16 10:00:52
在N个论坛贴了N回了,这是最后一次贴了5555555555555555。

我在做BMP时抛出如下异常:
RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: Transaction aborted (possibly due to transaction time out).; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback

运行环境:j2sdkee(j2ee),cloudscape;

我的JTA timeout已经设置为无超时了:timeout=0。

并且如果查询结果为空,无异常。一旦有数据,就抛出以上结果。插入数据等操作都抛出异常。

N天了,近乎绝望,望大侠横空济世。
...全文
90 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
yfh0919 2003-05-26
  • 打赏
  • 举报
回复
你的ejb-jar.xml中
<assembly-descriptor>

<container-transaction>
<method>
<ejb-name>ejbsample</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>

</assembly-descriptor>
定义的方法的事务属性是不是Required还是其他的,我觉得应该和你定义的事务属性有关系
lanfengjiyue 2003-05-23
  • 打赏
  • 举报
回复
up
lanfengjiyue 2003-05-20
  • 打赏
  • 举报
回复
up
sobingman 2003-05-19
  • 打赏
  • 举报
回复
EntityBeanContext.getXXX.commit()
忘了get什么,是一个事务环境,你查查文档好了。
lanfengjiyue 2003-05-19
  • 打赏
  • 举报
回复
楼上的,请问如何提交?谢谢。
sobingman 2003-05-18
  • 打赏
  • 举报
回复
如果你的事务是BEAN管理的,请在最后完成事务后commit
sobingman 2003-05-18
  • 打赏
  • 举报
回复
无超时是-1,0是一开始就超时
lanfengjiyue 2003-05-18
  • 打赏
  • 举报
回复
up
lanfengjiyue 2003-05-17
  • 打赏
  • 举报
回复
up
Zhakrin 2003-05-17
  • 打赏
  • 举报
回复
把Transaction统统改成TX_NOT_SUPPORTED然后你就知道了
lamelark 2003-05-17
  • 打赏
  • 举报
回复
不知道什么原因了,我也有一个deploy的错误,所以通病相连,唯有up助威
lanfengjiyue 2003-05-16
  • 打赏
  • 举报
回复
//取得资料库连结
//=============================================


private void getConnection()
throws NamingException, SQLException{

InitialContext ic=new InitialContext();
DataSource ds=(DataSource) ic.lookup(DBJndi);
con= ds.getConnection();
}

private void insertCart(
String cart_id,String netname,String book_id,String isbn,String bname,int num,int rmb)
throws SQLException{

String insertStatement =
"insert into cart values(? ,? ,? ,? ,? ,? ,?)";
PreparedStatement ps=
con.prepareStatement(insertStatement);
try{
ps.setString(1, cart_id);
ps.setString(2, netname);
ps.setString(3, book_id);
ps.setInt(4, num);
ps.setString(5, isbn);
ps.setString(6, bname);
ps.setInt(7, rmb);
ps.executeUpdate();
}finally{
ps.close();
}
}



private boolean selectByPrimaryKey(String primaryKey)
throws SQLException{

String sqlStatement =
"select cart_id "+
"from cart where cart_id=?";
PreparedStatement ps =
con.prepareStatement(sqlStatement);
try{
ps.setString(1, primaryKey);
ResultSet rs=ps.executeQuery();
return rs.next();
}finally{
ps.close();
}
}

private Collection selectAll()
throws SQLException{

String sqlStatement=
"select cart_id from cart";
PreparedStatement ps=
con.prepareStatement(sqlStatement);
try{
ResultSet rs=ps.executeQuery();
ArrayList al=new ArrayList();
while(rs.next()){
String id=rs.getString(1);
al.add(id);
}
return al;
}finally{
ps.close();
}
}

private Collection selectByNetname(String netname)
throws SQLException{

String sqlStatement=
"select cart_id from cart "+
"where netname=?";
PreparedStatement ps=
con.prepareStatement(sqlStatement);
try{
ps.setString(1, netname); //??????????????
ResultSet rs=ps.executeQuery();
ArrayList al=new ArrayList();
while(rs.next()){
String id=rs.getString(1);
al.add(id);
}
return al;
}finally{
ps.close();
}
}


private void deleteCart()
throws SQLException{

String deleteStatement =
"delete from cart "+
"where cart_id=?";
PreparedStatement ps =
con.prepareStatement(deleteStatement);
try{
ps.setString(1, cart_id);
ps.executeUpdate();
}finally{
ps.close();
}
}

private void loadCart()
throws SQLException{

String selectStatement =
"select netname, book_id, num, isbn, bname, rmb "+
"from cart where cart_id=?";
PreparedStatement ps=
con.prepareStatement(selectStatement);

try{
ps.setString(1, cart_id);
ResultSet rs=ps.executeQuery();
if(rs.next()){
netname=rs.getString(1);
book_id=rs.getString(2);
num=rs.getInt(3);
isbn=rs.getString(4);
bname=rs.getString(5);
rmb=rs.getInt(6);
}
else{
throw new NoSuchEntityException(
cart_id+" not found.");
}
}finally{
ps.close();
}
}


private void storeCart()
throws SQLException{

String updateStatement =
"update cart set netname=?, book_id=?, num=?, isbn=?, bname=?, rmb=? "+
"where cart_id=?";
PreparedStatement ps=
con.prepareStatement(updateStatement);
int rowCount;
try{
ps.setString(1, netname);
ps.setString(2, book_id);
ps.setInt(3, num);
ps.setString(4, isbn);
ps.setString(5, bname);
ps.setInt(6, rmb);

rowCount=ps.executeUpdate();
}finally{
ps.close();
}
if(rowCount == 0){
throw new EJBException(
"Storing "+cart_id+ " failed.");
}
}

}
lanfengjiyue 2003-05-16
  • 打赏
  • 举报
回复
ejb如下:
package carts.ejb;

import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.ejb.*;
import javax.naming.*;
import carts.common.*;

public class CartEJB implements EntityBean{

public String cart_id=null;
public String netname=null;
public String book_id=null;
public String isbn=null;
public String bname=null;

public int num=0;
public int rmb=0;

public CartId cartid;

private EntityContext context;
private Connection con;
private String DBJndi="java:comp/env/jdbc/ExampleDB";


public void setEntityContext(EntityContext context){

this.context = context;
try{
getConnection();
}catch(Exception ex){
throw new EJBException(
"Connect to DataBase failed:"+ex.getMessage());
}
}

public void unsetEntityContext(){

try{
con.close();
}catch(SQLException ex){
throw new EJBException(
"Close DataBase Connection failed:"+ex.getMessage());
}
}


public String ejbCreate(String netname,String book_id,String isbn,String bname,int num,int rmb)
throws DuplicateKeyException, CreateException{
this.cart_id=cartid.getCart_id();
this.netname =netname;
this.book_id = book_id;
this.isbn=isbn;
this.bname=bname;
this.num=num;
this.rmb=rmb;
try{

insertCart(cart_id, netname, book_id, isbn, bname, num, rmb);
}catch(Exception ex){
throw new EJBException(
"ejbCreate exception: "+ex.getMessage());
}



return cart_id;
}

public void ejbPostCreate(String netname,String book_id,String isbn,String bname,int num,int rmb){
}

public String ejbFindByPrimaryKey(String cart_id)
throws FinderException{

boolean result;

try{
result=selectByPrimaryKey(cart_id);
}catch(Exception ex){
throw new EJBException(
"ejbFindByPrimaryKey exception:"+ex.getMessage());
}

if(result)
return cart_id;
else
throw new ObjectNotFoundException(
"Row for id "+cart_id+" not found.");

}

public Collection ejbFindByNetname(String netname)
throws FinderException {
Collection result;

try{
result=selectByNetname(netname);
}catch(Exception ex){
throw new EJBException(ex.getMessage());
}


return result;

}

public Collection ejbFindAll()
throws FinderException {
Collection result;

try{
result=selectAll();
}catch(Exception ex){
throw new EJBException(ex.getMessage());
}


return result;

}

/* public void setCart_id(String cart_id)
{
this.cart_id = cart_id;
}*/
public String getCart_id()
{
return cart_id;
}

public void setNetname(String netname)
{
this.netname = netname;
}
public String getNetname()
{
return netname;
}

public void setIsbn(String isbn)
{
this.isbn = isbn;
}
public String getIsbn()
{
return isbn;
}

public void setBook_id(String book_id)
{
this.book_id = book_id;
}
public String getBook_id()
{
return book_id;
}

public void setBname(String bname)
{
this.bname = bname;
}
public String getBname()
{
return bname;
}

public void setNum(int num)
{
this.num = num;
}
public int getNum()
{
return num;
}

public void setRmb(int rmb)
{
this.rmb = rmb;
}
public int getRmb()
{
return rmb;
}




public void ejbActivate(){

cart_id = (String)context.getPrimaryKey();
}

public void ejbPassivate(){

cart_id=null;
netname=null;
book_id=null;
isbn=null;
bname=null;

num=0;
rmb=0;

}

public void ejbRemove(){
try{
deleteCart();

}catch(Exception ex){
throw new EJBException(
"ejbRemove exception:"+ex.getMessage());
}
}

public void ejbLoad(){

try{
loadCart();

}catch(Exception ex){
throw new EJBException(
"ejbLoad exception:"+ex.getMessage()+".....");
}
}

public void ejbStore(){

try{
storeCart();
}catch(Exception ex){
throw new EJBException(
"ejbLoad exception:"+ex.getMessage());
}
}

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧