ejb方法调用期间出现未知异常

时间:2010-12-06 00:39:37

标签: java glassfish-3

我为我的摇摆应用程序创建压力测试。 swing app调用返回实体List的远程EJB方法。我把远程方法调用放在for循环中,并将max iteration设置为5000次调用服务器,之后我运行2个客户端,但经过一些调用后,服务器抛出异常

应用程序服务器GlassFish 3.01 b22

    WARNING: "IOP00010202: (UNKNOWN) Unknown user exception thrown by the server - exception: java.util.ConcurrentModificationException; message: null"
org.omg.CORBA.UNKNOWN:   vmcid: SUN  minor code: 202 completed: Maybe
    at com.sun.corba.ee.impl.logging.ORBUtilSystemException.runtimeexception(ORBUtilSystemException.java:11015)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.convertThrowableToSystemException(CorbaMessageMediatorImpl.java:2075)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleThrowableDuringServerDispatch(CorbaMessageMediatorImpl.java:2025)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleThrowableDuringServerDispatch(CorbaMessageMediatorImpl.java:1978)
    at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:289)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1841)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1695)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1078)
    at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:221)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:797)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:561)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2558)
    at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:492)
    at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:528)
Caused by: java.util.ConcurrentModificationException
    at java.util.ArrayList.writeObject(ArrayList.java:573)
    at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.invokeObjectWriter(IIOPOutputStream.java:760)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:716)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:227)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:268)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(ValueHandlerImpl.java:240)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:193)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.callWriteValue(CDROutputStream_1_0.java:932)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(CDROutputStream_1_0.java:917)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:1044)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:1057)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:774)
    at com.sun.corba.ee.impl.encoding.CDROutputObject.write_value(CDROutputObject.java:681)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:887)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:959)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:281)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:718)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:227)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:268)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(ValueHandlerImpl.java:240)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:193)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.callWriteValue(CDROutputStream_1_0.java:932)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(CDROutputStream_1_0.java:917)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:1044)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:1057)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_abstract_interface(CDROutputStream_1_0.java:760)
    at com.sun.corba.ee.impl.encoding.CDROutputObject.write_abstract_interface(CDROutputObject.java:709)
    at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.writeAbstractObject(Util.java:501)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.writeObjectOverride(IIOPOutputStream.java:197)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:322)
    at java.util.ArrayList.writeObject(ArrayList.java:570)
    at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.invokeObjectWriter(IIOPOutputStream.java:760)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:716)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:227)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:268)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(ValueHandlerImpl.java:240)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:193)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.callWriteValue(CDROutputStream_1_0.java:932)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(CDROutputStream_1_0.java:917)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:1044)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:1057)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:774)
    at com.sun.corba.ee.impl.encoding.CDROutputObject.write_value(CDROutputObject.java:681)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:887)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:959)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:281)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:718)
    at com.sun.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:227)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:268)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(ValueHandlerImpl.java:240)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:193)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.callWriteValue(CDROutputStream_1_0.java:932)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(CDROutputStream_1_0.java:917)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:1044)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:1057)
    at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:774)
    at com.sun.corba.ee.impl.encoding.CDROutputObject.write_value(CDROutputObject.java:681)
    at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$14.write(DynamicMethodMarshallerImpl.java:394)
    at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.writeResult(DynamicMethodMarshallerImpl.java:490)
    at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:180)
    at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:682)
    at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:216)
    ... 9 more

EJB方法返回文件夹实体

@Entity

    public class Folders implements Serializable {

    private static final long serialVersionUID = 1L;

    @Transient
    private List<Folders> chileFolders = new ArrayList<Folders>();

    @Basic(optional = false)
    @Column(name = "FOLDER_GROUP_ID", nullable = false, unique = false)
    private long parentFolderId;

    //other attributes of folder entity

    public Folders() {
    }

public List<Folders> getChildes() {
    return chileFolders;
}

public void setChildes(List<Folders> foldersList) {
    this.chileFolders = foldersList;
}

/**
 * removes all elements from transiant field {@link #chileFolders}
 */
public void removeAllChildes() {
    chileFolders.removeAll(chileFolders);
    }
}

在EJB方法中,我创建了递归选择文件夹实体与它的childes。数据库中的文件夹实体 通过parentFolderId对象映射到其父实体。

@Stateless 
    public class FolderManager implements FolderManagerRemote {
    //remote ejb method
    @Override
    public Folders findRootFolder() throws RecordDoNotExistException {
        //root folder
        Folders tempRoot = new Folders();
        tempRoot.setId((long) 1);
        tempRoot.setParentFolderId(0);
        recursionSelectFromRootFolder(tempRoot);
        return tempRoot;
    }
    //recursion select
    private void recursionSelectFromRootFolder(Folders root) {
        List<Folders> folderList = getChildes(root);
        //maybe this is cause of exception ????? removeAllChildes()
        root.removeAllChildes();
        for (Iterator iterator = folderList.iterator(); iterator.hasNext();) {
            Folders folders = (Folders) iterator.next();
            List<Folders> childesOfRoot = root.getChildes();
            childesOfRoot.add(folders);
            root.setChildes(childesOfRoot);
            if (hasChildes(folders)) {
                recursionSelectFromRootFolder(folders);
            }
        }
    }

    }

我使用Folders Entity中的removeAllChildes()方法删除以前为文件夹选择的子项

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

问题似乎是列表列表被两个不同的线程同时序列化和修改。序列化是由远程EJB调用引起的,但要说明修改的位置,我们需要查看一些代码

基于您在堆栈跟踪中有两个这样的事实

at java.util.ArrayList.writeObject(ArrayList.java:570)

您是否将列表列表作为EJB类的成员?您是在EJB调用中修改它还是返回它?