将80000左右的大数据插入到使用Java失败的postgres数据库中

问题描述 投票:0回答:1

我有以下file.txt参考this post

它可能包含多达400,000个条目,我需要将它们插入到数据库中,但是对于大约80000到最大100,000的文件,该过程是成功的,但如果超出则失败。

问题可能在于写入数据库的最终循环,

FILETYPE: STUDENT
FORMATVERSION: 1.2 
ACTION: REPLACEALL
COLUMNS: NAME,SURNAME,AGE,SEX
"raj","jonson",17,"M"
"Rita","Sweety",17,"F"

这是我的示例代码

//入口点

public RestResponse provisionStudent(MultipartFormDataInput input) {
    long processed = 0L;
    HashMap<String, String> columnMaping = new HashMap<String, String>();

    //mapping here as the column name is not same as in the database
    columnMaping.put("NAME","name");
    columnMaping.put("surname","s_name");
    columnMaping.put("AGE","age");
    columnMaping.put("SEX","mf");

    try {

        String lineRead;
        List<Map<String, String>> listheader = new ArrayList<>();
        Map<String, String> obj = new LinkedHashMap<>();
        ArrayList<String> body = new ArrayList<String>();
        InputStream result;


        //checking if file contain data
        if (input == null || input.getParts() == null || input.getParts().isEmpty()) {
            throw new IllegalArgumentException("Multipart request is empty");
        }

        if (input.getParts().size() == 1) {
            InputPart filePart = input.getParts().iterator().next();
            result = filePart.getBody(InputStream.class, null);
        } else {
            result = input.getFormDataPart("file", InputStream.class, null);
        }

        BufferedReader httpResponseReader = new BufferedReader(new InputStreamReader(result));

        // reading the header part into obj and the body part in array list body
        while ((lineRead = httpResponseReader.readLine()) != null) {
            if (lineRead.contains(":")) {
                String[] headervalues = lineRead.replace(" ", "").split(":");
                obj.put(headervalues[0], headervalues[1]);
            } else {
                if (lineRead.length() > 0) body.add(lineRead.replace(" ", ""));
            }
        }

        //converting the csv into json array
        //like this [{"name":"raj","s_name":"jonson","age":17,"mf":"M"},...]


        List<Map<String, String>> finallist = new ArrayList<>();
        String[] finalColumns = obj.get("COLUMNS").split(",");
        String[] MappedfinalColumns = obj.get("COLUMNS").split(",");

        for (int finC = 0; finC < finalColumns.length; finC++) {
            MappedfinalColumns[finC]=columnMaping.get(finalColumns[finC]);
        }

        for (int i = 0; i < body.size(); i++) {
            Map<String, String> finalBuild = new LinkedHashMap<>();
            String[] bodyChunks = body.get(i).split(",");

            for (int j = 0; j < bodyChunks.length; j++) {
                finalBuild.put(MappedfinalColumns[j], bodyChunks[j].replace("\"", ""));
            }

            finallist.add(finalBuild);
        }

        JSONArray jsArray = new JSONArray(finallist);

        processed =updatebulkstudentJsonArray(jsArray.toString(),generatedString);

        logger.info("end of execution");
        //

    } catch (Exception e) {
        logError(e);
        return getRestResponse("1", "Could not insert" + e, "");
    }

    return getRestResponse("0", "OK", "inserted"+processed);

}

//确定学生是否已经存在于数据库中,而不是多次查询数据库

public Long updatebulkstudentJsonArray(String jsarray,String hash) {
    Long counter = 0L;
    Long id = 0L;
    try {


        HashMap<Long, Student> Stud_map = new HashMap<Long, Student>();
        HashMap<Long, Student> originalStud_map = new HashMap<Long, Student>();

        JsonParser jsonParser = new JsonParser();
        JsonArray jsonArrayD = (JsonArray) jsonParser.parse(jsarray);



        if (jsonArrayD.size() > 0) {

               TypedQuery<Student> queryInfo = em.createQuery("SELECT s FROM Student s", Student.class);
                List<Student> Stud_listInfo = queryInfo.getResultList();

                //here i am creating an 2 identical hash map from the data i got from the database
                //the first hash map will be updated dynamically when the data is being inserted
                //the original map will remain unchanged so that i can keep tract of the changes ( knowing if a data is being added or modified as the file may contain duplicates) 

                if (Stud_listInfo.size() > 0) {
                    for (int i = 0; i < Stud_listInfo.size(); i++) {
                        Student existingInfo = Stud_listInfo.get(i);
                        Stud_map.put(existingInfo.getStud__id(), existingInfo);
                        originalStud_map.put(existingInfo.getStud__id(), existingInfo);
                    }
                }
                Date date = new Date();

                int clearCounter=0;

                //looping to insert into the database here, the problem is somewhere here
                for (int i = 0; i < jsonArrayD.size(); i++) {

                    ObjectMapper objectMapper = new ObjectMapper();
                    Student StudentObj =  objectMapper.readValue(jsonArrayD.get(i).toString(), Student.class) ;

                    //Stud_obj = decoded line sent by the php
                    //Stud_map = list of existing data in the database plus it will be updated as the function executes
                    //originalStud_map = list of existing data in the database plus it will not be updated as the function executes
//i got this from searches online however it doesn't seem to help
                    if ( i % 10000 == 0 ) {
                        clearCounter=clearCounter+1;
                        log.info(" clearing memory"+clearCounter);

                    }

                    if(Stud_map.containsKey(StudentObj.getStud__id())){
                        id = updateStud_(StudentObj, Stud_map.get(StudentObj.getStud__id()), Stud_map.containsKey(StudentObj.getStud__id()), originalStud_map.containsKey(StudentObj.getStud__id()),date);

                    }else{
                        id = updateStud_(StudentObj, null, Stud_map.containsKey(StudentObj.getStud__id()), originalStud_map.containsKey(StudentObj.getStud__id()),date);

                    }

                    StudentObj.setId(id);
                    if (!Stud_map.containsKey(StudentObj.getStud__id()))
                        Stud_map.put(StudentObj.getStud__id(), StudentObj);
                    counter++;

                }             


        }

    } catch (Exception e) {

        log.info(e.toString());

    }


    return counter;

}

//将数据添加到数据库

    public Long updateStud_(Student Student, Student Stud_map, Boolean foundinupdatedList, Boolean foundinoriginalList,Date date) {


    Long id = -1L;
    if (foundinupdatedList) {
        Student existingInfo = Stud_map;

        if (Student.getName() != null)
            existingInfo.setLac(Student.getName());


        if (Student.getSname() != null)
            existingInfo.setLongitude(Student.getSname());


        if (Student.getSex() != null)
            existingInfo.setLatitude(Student.getSex());


        if (Student.getAge() != null)
            existingInfo.setRange(Student.getAge());


//determining if its a new insert or a modification 
        if (foundinoriginalList) {
            existingInfo.setLastaction("MODIFY");
            existingInfo.setLast_modified_date(new Timestamp(date.getTime()));
        } else {
            existingInfo.setLastaction("ADD");
        }

        existingInfo.setProcessing("t");

        //info.setId(info.getId());
        em.merge(existingInfo);
        //em.flush();
        id = Student.getId();
    } else {

        Student.setCreatedate(new Timestamp(date.getTime()));


        em.persist(Student);
        em.flush();
        id = Student.getId();

    }

    return id;
}

错误日志

2018-08-30 10:46:23,665 INFO  [com.project.school.MyStudentEjb] (default task-22)  clearing memory1
2018-08-30 10:47:38,432 INFO  [com.project.school.MyStudentEjb] (default task-22)  clearing memory2
2018-08-30 10:50:11,276 INFO  [com.project.school.MyStudentEjb] (default task-22)  clearing memory3
2018-08-30 10:51:12,620 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper) ARJUNA012117: TransactionReaper::check timeout for TX 0:ffff7f000001:-78d9068d:5b878b54:1a1 in
 state  RUN
2018-08-30 10:51:12,623 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012095: Abort of action id 0:ffff7f000001:-78d9068d:5b878b54:1a1 invoked while
multiple threads active within it.
2018-08-30 10:51:12,643 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012381: Action id 0:ffff7f000001:-78d9068d:5b878b54:1a1 completed with multiple
 threads - thread default task-22 was in progress with org.hibernate.engine.internal.EntityEntryContext.reentrantSafeEntityEntries(EntityEntryContext.java:318)
org.hibernate.engine.internal.StatefulPersistenceContext.reentrantSafeEntityEntries(StatefulPersistenceContext.java:1128)
org.hibernate.event.internal.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:136)
org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:74)
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:38)
org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1282)
org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1300)
org.jboss.as.jpa.container.AbstractEntityManager.flush(AbstractEntityManager.java:459)
com.project.school.MyStudentEjb.updateStud_(MyStudentEjb.java:560)
com.project.school.MyStudentEjb.updatebulkStud_(MyStudentEjb.java:371)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)
org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82)
org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93)
org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)
org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64)
org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)
org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:327)
org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:636)
org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:198)
org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:185)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73)
com.project.school.MyStudentEjb$$$view137.updatebulkStud_(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.jboss.weld.util.reflection.Reflections.invokeAndUnwrap(Reflections.java:433)
org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:128)
org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)
org.jboss.weld.bean.proxy.InjectionPointPropagatingEnterpriseTargetBeanInstance.invoke(InjectionPointPropagatingEnterpriseTargetBeanInstance.java:67)
org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:100)
com.project.school.MyStudentEjb$Proxy$_$$_Weld$EnterpriseProxy$.updatebulkStud_(Unknown Source)
com.project.school.StudentImpl.updatebulkstudentJsonArray(StudentImpl.java:256)
com.project.school.StudentImpl.provisionStudent(StudentImpl.java:164)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:402)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:209)
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)
io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)

2018-08-30 10:51:12,644 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012108: CheckedAction::check - atomic action 0:ffff7f000001:-78d9068d:5b878b54:
1a1 aborting with 1 threads active!
2018-08-30 10:51:12,652 INFO  [com.project.school.MyStudentEjb] (default task-22) javax.persistence.TransactionRequiredException: WFLYJPA0060: Transaction is required
to perform this operation (either use a transaction or extended persistence context)
2018-08-30 10:51:12,653 WARN  [com.arjuna.ats.arjuna] (default task-22) ARJUNA012077: Abort called on already aborted atomic action 0:ffff7f000001:-78d9068d:5b878b54:1a1

2018-08-30 10:51:12,662 WARN  [org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackCoordinatorTrackingImpl] (Transaction Reape
r Worker 0) HHH000451: Transaction afterCompletion called by a background thread; delaying afterCompletion processing until the original thread can handle it. [status=4]

2018-08-30 10:51:12,664 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012121: TransactionReaper::doCancellations worker Thread[Transaction Reaper Wor
ker 0,5,main] successfully canceled TX 0:ffff7f000001:-78d9068d:5b878b54:1a1
2018-08-30 10:51:12,673 ERROR [org.jboss.as.ejb3.invocation] (default task-22) WFLYEJB0034: EJB Invocation failed on component MyStudentEjb for method public java.lang.Long
 com.project.school.MyStudentEjb.updatebulkStud_(java.lang.String,java.lang.String): javax.ejb.EJBTransactionRolledbackException: Transaction rolled back
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleEndTransactionException(CMTTxInterceptor.java:137)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:117)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:279)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:327)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:636)
        at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
        at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at ......
        at com.project.school.MyStudentEjb$$$view137.updatebulkStud_(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 

----删除其他部分,因为它不适合这个线程.....

Caused by: javax.transaction.RollbackException: WFLYEJB0447: Transaction 'TransactionImple < ac, BasicAction: 0:ffff7f000001:-78d9068d:5b878b54:1a1 status: ActionStatus.
ABORTED >' was already rolled back
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:98)
        ... 102 more

2018-08-30 10:51:12,685 WARNING [com.project.school.StudentImpl] (default task-22) Transaction rolled back
2018-08-30 10:51:12,685 INFO  [log] (default task-22) end of execution
java sql postgresql hibernate transactions
1个回答
1
投票

也许你在服务器端有一个超时,尝试将statement_timeout设置得更高。您应该检查有很多超时选项。

© www.soinside.com 2019 - 2024. All rights reserved.