在 Wildfly8 上部署/启动战争期间的 Oracle BLOB 异常 [英] Oracle BLOB exception during deployment/starting up war on Wildfly8

查看:75
本文介绍了在 Wildfly8 上部署/启动战争期间的 Oracle BLOB 异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

war java/w spring 应用程序启动时出现以下异常

I have following exception during start-up of war java /w spring app

Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' defined in "/content/service.war/WEB-INF/classes/META-INF/spring/applicationContext-service.xml": Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't retrieve job because the BLOB couldn't be deserialized: null [See nested exception: java.io.EOFException]
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:222)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    ... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' defined in "/content/service.war/WEB-INF/classes/META-INF/spring/applicationContext-service.xml": Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't retrieve job because the BLOB couldn't be deserialized: null [See nested exception: java.io.EOFException]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:615)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:193)
    ... 7 more
Caused by: org.quartz.JobPersistenceException: Couldn't retrieve job because the BLOB couldn't be deserialized: null [See nested exception: java.io.EOFException]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1421)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$7.execute(JobStoreSupport.java:1396)
    at org.quartz.impl.jdbcjobstore.JobStoreCMT.executeInLock(JobStoreCMT.java:242)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeWithoutLock(JobStoreSupport.java:3693)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1393)
    at org.quartz.core.QuartzScheduler.getJobDetail(QuartzScheduler.java:1431)
    at org.quartz.impl.StdScheduler.getJobDetail(StdScheduler.java:539)
    at org.springframework.scheduling.quartz.SchedulerAccessor.jobDetailExists(SchedulerAccessor.java:420)
    at org.springframework.scheduling.quartz.SchedulerAccessor.addJobToScheduler(SchedulerAccessor.java:338)
    at org.springframework.scheduling.quartz.SchedulerAccessor.registerJobsAndTriggers(SchedulerAccessor.java:281)
    at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:508)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
    ... 21 more
Caused by: java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2328) [rt.jar:1.8.0_45]
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2797) [rt.jar:1.8.0_45]
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:802) [rt.jar:1.8.0_45]
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299) [rt.jar:1.8.0_45]
    at org.quartz.impl.jdbcjobstore.oracle.OracleDelegate.getObjectFromBlob(OracleDelegate.java:156)
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectJobDetail(StdJDBCDelegate.java:904)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1404)
    ... 33 more

它部署在集群的 wildfly 8.1.x 上.该应用程序使用 Quartz 1.8.6 版.Spring 版本是 3.2.5.我在较低的环境中遇到了类似的(没有提到 EOF)问题,但这是由于缺乏 JDBC 驱动程序配置.

It is deployed on clustered wildfly 8.1.x. The application uses Quartz ver 1.8.6. The Spring version is 3.2.5. I had similar (no EOF mentioned) problem on lower enviroment, but it was due to lack of JDBC driver configuration.

quartz 配置和这个类似(http://quartz-scheduler.org/documentation/quartz-2.x/configuration/ConfigJDBCJobStoreClustering),除了数据源是在wildfly上配置的.

The quartz configuration is similar to this one (http://quartz-scheduler.org/documentation/quartz-2.x/configuration/ConfigJDBCJobStoreClustering), except the Data Source is configured on the wildfly.

The DS itslef bounds correctly:
2015-09-25 14:57:21,411 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:/quartzDs]

我真的很困惑,因为在另一个(镜像)环境中它工作得很好.

I am really confused with this, because on another (mirrored) enviroment it works just fine.

有什么线索吗?

推荐答案

好的,我已经设法解决了这个问题.原来问题出在 org.quartz.impl.jdbcjobstore.oracle.OracleDelegate 和 Oracle 10.2.x 上.它适用于 Oracle 11.x.问题本身是 Oracle 10.2.x 中的作业被序列化为 null 因此它们以后不能反序列化,因此上面的堆栈跟踪.

Okay, I've manage to resolve the issuse. It turned out that the problem is with org.quartz.impl.jdbcjobstore.oracle.OracleDelegate and Oracle 10.2.x. It works fine with Oracle 11.x. The problem itself is that the jobs in Oracle 10.2.x are serialized as null therefore they can't be deserialized later, hence the above stack trace.

为了解决这个问题,我编写了自己的委托来扩展 OracleDelegate 并覆盖 getObjectFromBlob 方法.

To resolve this issue I had write own delegate extending OracleDelegate and override getObjectFromBlob method.

public class CustomDelegate extends OracleDelegate {

    public CustomDelegate(Logger logger, String tablePrefix, String instanceId) {
        super(logger, tablePrefix, instanceId);
    }

    public CustomDelegate(Logger logger, String tablePrefix, String instanceId, Boolean useProperties) {
        super(logger, tablePrefix, instanceId, useProperties);
    }

    protected Object getObjectFromBlob(ResultSet rs, String colName)
            throws ClassNotFoundException, IOException, SQLException {
        byte[] data = rs.getBytes(colName);
        if (data == null || data.length == 0) {
            return null;
        }
        ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data));
        try {
            return in.readObject();
        } finally {
            in.close();
        }
    }
}

然后我不得不改变石英属性

Then I had to change the quartz properties

org.quartz.jobStore.driverDelegateClass = my.package.CustomDelegate

现在一切正常.

这篇关于在 Wildfly8 上部署/启动战争期间的 Oracle BLOB 异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆