获取无法序列化SCDF中任务的访问异常

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取无法序列化SCDF中任务的访问异常相关的知识,希望对你有一定的参考价值。

我们使用SCDF 1.2.3.RELEASE(本地服务器)来调用使用spring cloud任务1.2.2.RELEASE创建的不同任务,该任务在内部使用批处理作业进行实际作业。这两个SCDF和任务都使用相同的Oracle DB。当我们从已在SCDF上注册的任务触发任务时,有时我们可以看到该任务的开始时间,但任务的整体初始化失败,并出现以下错误

2018-02-28 11:23:50.286 ERROR 2719 --- [main] o.s.boot.SpringApplication               
: Application startup failed

java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:735)
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:716)
    at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:703)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:304)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
    at com.vmware.usage.report.UsageETLBatchApplication.main(UsageETLBatchApplication.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
    Caused by: org.springframework.dao.CannotSerializeTransactionException: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; ORA-08177: can't serialize access for this transaction
    ; nested exception is java.sql.SQLException: ORA-08177: can't serialize access for this transaction

    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:267)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:655)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:876)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:937)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:942)
    at org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.createJobInstance(JdbcJobInstanceDao.java:115)
    at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:135)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean$1.invoke(AbstractJobRepositoryFactoryBean.java:172)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy103.createJobExecution(Unknown Source)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:125)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy130.run(Unknown Source)
    at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.execute(JobLauncherCommandLineRunner.java:211)
    at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.executeLocalJobs(JobLauncherCommandLineRunner.java:227)
    at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.launchJobFromProperties(JobLauncherCommandLineRunner.java:123)
    at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.run(JobLauncherCommandLineRunner.java:117)
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:732)
    ... 14 common frames omitted
    Caused by: java.sql.SQLException: ORA-08177: can't serialize access for this transaction

    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114)
    at com.sun.proxy.$Proxy144.executeUpdate(Unknown Source)
    at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:883)
    at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:876)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:639)
    ... 51 common frames omitted

请在下面找到SCDF服务器的属性文件:

eureka.client.service-url.defaultZone=http://localhost:9000/eureka/
spring.application.name=SpringCloudDataFlowServer


spring.datasource.url=jdbc:oracle:thin:@<host>:1521:<db>
spring.datasource.username=USERNAME
spring.datasource.password=PASSWORD
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver


spring.cloud.deployer.local.deleteFilesOnExit=false
spring.cloud.deployer.local.javaOpts=-Xms256M -Xmx1G

spring.zipkin.baseUrl=http://localhost:8012/
spring.zipkin.urlSuffix=api/zipkin_trace/spans
spring.sleuth.sampler.percentage=1.0

请在下面找到任务的属性文件:

spring.application.name=SpringCloudTask
logging.level.org.springframework.cloud.task=DEBUG

spring.oracle.datasource.url =jdbc:oracle:thin:@<host>:1521:<db>
spring.oracle.datasource.username=USERNAME
spring.oracle.datasource.password=PASSWORD
spring.oracle.datasource.driverClassName=oracle.jdbc.OracleDriver

spring.data.mongodb.host=HOST
spring.data.mongodb.port=PORT
spring.data.mongodb.database=DATABASE
spring.data.mongodb.username=USERNAME
spring.data.mongodb.password=PASSWORD

spring.zipkin.baseUrl=http://localhost:8012/
spring.zipkin.urlSuffix=api/zipkin_trace/spans
spring.sleuth.sampler.percentage=1.0

#other task-specific properties

此外,我们在运行SCDF服务器之前默认创建所需的数据库结构,因为我们的某些环境可能无法访问创建表的服务。请在下面找到数据库脚本:

https://drive.google.com/file/d/1xajuUz-7IBtdKyGWuxmQavqhYEPY1pt_/view?usp=sharing

请告诉我们如何解决此问题“无法序列化此事务的访问权限”异常

谢谢

答案

这是一个Spring Batch问题(不是Spring Cloud Task)。尝试将事务隔离级别更改为ISOLATION_REPEATABLE_READ

以上是关于获取无法序列化SCDF中任务的访问异常的主要内容,如果未能解决你的问题,请参考以下文章

从 SCDF 执行任务时,数据库凭证作为部分作业参数公开

SCDF 未获取最新的应用程序 docker 映像

从 Kubernetes 部署中公开 SCDF 服务

从第三方 WCF 获取底层异常 - SOAP 异常

访问片段的子视图时出现空指针异常

异常处理