简体   繁体   中英

Exception on job execution (Websphere)

I am getting the following exception when I try to execute a query by the entity manager with jpa. it seems I am with a jta configuration problem, but I am not sure. I am using quartz with a java ee 5 application and I running in a webpshere server.

E org.hibernate.ejb.AbstractEntityManagerImpl handlePersistenceException Unable to mark for rollback on PersistenceException:
                                 org.hibernate.HibernateException: javax.naming.ConfigurationException: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component.  
This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request.  Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application.  Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. [Root exception is javax.naming.NameNotFoundException: Name comp/websphere not found in context "java:".]

at

org.hibernate.transaction.WebSphereExtendedJTATransactionLookup$TransactionManagerAdapter$TransactionAdapter.<init>(WebSphereExtendedJTATransactionLookup.java:188)
            at org.hibernate.transaction.WebSphereExtendedJTATransactionLookup$TransactionManagerAdapter$TransactionAdapter.<init>(WebSphereExtendedJTATransactionLookup.java:178)
            at org.hibernate.transaction.WebSphereExtendedJTATransactionLookup$TransactionManagerAdapter.getTransaction(WebSphereExtendedJTATransactionLookup.java:140)
            at org.hibernate.ejb.transaction.JoinableCMTTransaction.isTransactionInProgress(JoinableCMTTransaction.java:64)
            at org.hibernate.ejb.transaction.JoinableCMTTransaction.tryJoiningTransaction(JoinableCMTTransaction.java:78)
            at org.hibernate.ejb.transaction.JoinableCMTTransactionFactory.isTransactionInProgress(JoinableCMTTransactionFactory.java:51)
            at org.hibernate.jdbc.JDBCContext.isTransactionInProgress(JDBCContext.java:235)
            at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:200)
            at org.hibernate.impl.SessionImpl.checkTransactionSynchStatus(SessionImpl.java:2112)
            at org.hibernate.impl.SessionImpl.getSessionFactory(SessionImpl.java:1853)
            at org.hibernate.ejb.AbstractEntityManagerImpl.markAsRollback(AbstractEntityManagerImpl.java:1123)
            at org.hibernate.ejb.AbstractEntityManagerImpl.handlePersistenceException(AbstractEntityManagerImpl.java:1296)
            at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1390)
            at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1317)
            at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1252)
            at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:168)
            at org.hibernate.ejb.EntityManagerImpl.<init>(EntityManagerImpl.java:84)
            at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:112)
            at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:107)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
            at java.lang.reflect.Method.invoke(Method.java:611)
            at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.invokeProxyMethod(AbstractEntityManagerFactoryBean.java:388)
            at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke(AbstractEntityManagerFactoryBean.java:541)
            at com.sun.proxy.$Proxy521.createEntityManager(Unknown Source)
            at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:285)
            at com.sun.proxy.$Proxy524.createQuery(Unknown Source)
            at br.com.vr.platpedidos.infrastructure.pedido.persistence.PedidoORMRepositoryImpl.buscarReferencia(PedidoORMRepositoryImpl.java:44)
            at br.com.vr.platpedidos.application.pedido.repository.PedidoRepositoryImpl.buscarModalidadeProdutoDoPedido(PedidoRepositoryImpl.java:29)
            at br.com.vr.platpedidos.application.pedido.services.PedidoApplicationServiceImpl.obterModalidadeDeProdutoDoPedido(PedidoApplicationServiceImpl.java:42)
            at br.com.vr.platpedidos.application.facade.PlatpedidosFacadeImpl.obterModalidadeDeProduto(PlatpedidosFacadeImpl.java:64)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
            at java.lang.reflect.Method.invoke(Method.java:611)
            at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
            at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
            at br.com.vr.platpedidos.infrastructure.exception.ExceptionLoggingAspect.logException(ExceptionLoggingAspect.java:14)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
            at java.lang.reflect.Method.invoke(Method.java:611)
            at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
            at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
            at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
            at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
            at com.sun.proxy.$Proxy540.obterModalidadeDeProduto(Unknown Source)
            at br.com.vr.platpedidos.orquestracao.infrastructure.PlataformaDePedidosGateway.obterModalidadeDeProduto(PlataformaDePedidosGateway.java:60)
            at br.com.vr.platpedidos.orquestracao.application.OrquestracaoApplicationServiceImpl.importarArquivosDePedido(OrquestracaoApplicationServiceImpl.java:40)
            at br.com.vr.platpedidos.orquestracao.facade.OrquestracaoFacadeImpl.importarArquivosDePedido(OrquestracaoFacadeImpl.java:16)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
            at java.lang.reflect.Method.invoke(Method.java:611)
            at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:269)
            at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:257)
            at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75)
            at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
            at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)

You have detailed answer in the error message and the stack trace:

ConfigurationException: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component. This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request .

And below:

org.quartz.core.JobRunShell.run (JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)

Either replace quartz with for example ejbTimers or managedThreads if you are on WebSphere Liberty, or change the JNDI to global name.

Using quartz is not recommended in Java EE applications, since it creates unmanaged threads.

我在以下帖子中找到了答案: http : //gybas.com/2014/quartz-websphere-spring/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM