Spring 5 + Glassfish 4.1+ hibernate 5:AbstractMethodError:oracle.jdbc.driver.T4CConnection.getSchema

时间:2017-03-05 02:15:20

标签: java spring hibernate glassfish-4

我们正在升级一个应用程序,当我尝试在glassfish 4.1.1上部署应用程序时,我真的陷入了以下错误的几天

环境:

var index = draggingNode.parent.children.indexOf(draggingNode);
if (index > -1) {
    draggingNode.parent.children.splice(index, 1);
    // had to update the "draggingNode" parent "children" array if it's 
    // empty otherwise the "firstWalk()" core function throws an error when
    // trying to call "children[0]".
    if (draggingNode.parent.children.length == 0) {
        draggingNode.parent.children = null;
    }
}

// update the "draggingNode" parent as well as update all its children 
// so that their properties are properly adjusted to their new depths.
draggingNode.parent = selectedNode;
draggingNode.descendants().forEach(setNodeDepth);

// check for visible children.
if (selectedNode.children) {
    selectedNode.children.push(draggingNode);
// check for hidden children.
} else if (selectedNode._children) {
    selectedNode._children.push(draggingNode);
// no children exist, create new children array and add "draggingNode".
} else {
    selectedNode.children = [];
    selectedNode.children.push(draggingNode);
}

Hibernate Search失败,出现以下错误:

Java 8 DB1: Oracle 11g DB (ojdbc6.jar) DB2: Informix DB Hibernate Core : 5.2.8.Final Hibernate Search : 5.7.0.Final Spring 5.0.0 Atomikos 4.0.4 (for transaction management)

但是当我查看服务器实例日志时,根本原因在下面的堆栈跟踪中:

ERROR o.s.web.context.ContextLoader - Context initialization failed
org.hibernate.search.exception.SearchException: HSEARCH000222: The SearchFactory was not initialized

这些是我配置的所有类:

[2017-03-04T16:47:44.366-0500] [glassfish 4.1] [SEVERE] [jdbc.ex_connection_holder] 
[javax.enterprise.resource.resourceadapter.com.sun.gjc.spi] [tid: _ThreadID=56 _ThreadName=admin-listener(4)] [timeMillis: 1488664064366] [levelValue: 1000] [[
  RAR9008 : Exception while invoking method on Connection object. Exception : {0}
javax.resource.ResourceException: java.lang.reflect.InvocationTargetException
    at com.sun.gjc.util.MethodExecutor.invokeMethod(MethodExecutor.java:244)
    at com.sun.gjc.spi.jdbc40.ConnectionHolder40.getSchema(ConnectionHolder40.java:609)
    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:498)
    at org.hibernate.engine.jdbc.env.internal.DefaultSchemaNameResolver$SchemaNameResolverJava17Delegate.resolveSchemaName(DefaultSchemaNameResolver.java:72)
    at org.hibernate.engine.jdbc.env.internal.DefaultSchemaNameResolver.resolveSchemaName(DefaultSchemaNameResolver.java:59)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.determineCurrentSchemaName(JdbcEnvironmentImpl.java:274)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.<init>(JdbcEnvironmentImpl.java:210)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:114)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874)
    at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:135)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:5394)
    at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:743)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5963)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)  
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
    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:498)
    at com.sun.gjc.util.MethodExecutor.invokeMethod(MethodExecutor.java:238)
    ... 130 more
Caused by: java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.getSchema()Ljava/lang/String;
    ... 135 more
]]
@Configuration
@Import({AtomikosJtaConfig.class, Db1DatabaseConfig.class, Db2DatabaseConfig.class})
public class DatabaseConfig {
}
@Configuration
@ComponentScan
@EnableTransactionManagement
public class AtomikosJtaConfig {

    private static final Logger log = LoggerFactory.getLogger(AtomikosJtaConfig.class.getSimpleName());

    @Bean(name = "atomikosUserTransaction")
    public UserTransaction atomikosUserTransaction()  {
        UserTransactionImp userTransactionImp = new UserTransactionImp();
        try {
            userTransactionImp.setTransactionTimeout(240);
        } catch (SystemException e) {
            log.debug(" Failed to set atomikos user transaction timeout. Caught {} ", e);
            throw new AtomikosConfigException(" Failed to set atomikos user transaction timeout. Caught {} ", e);
        }
        return userTransactionImp;
    }

    @Bean(name = "atomikosTransactionManager", initMethod = "init", destroyMethod = "close")
    public TransactionManager atomikosTransactionManager()  {
        UserTransactionManager userTransactionManager = new UserTransactionManager();
        userTransactionManager.setForceShutdown(true);
        userTransactionManager.setStartupTransactionService(false);
        return userTransactionManager;
    }

    @Bean(name = "transactionManager")
    @DependsOn({ "atomikosUserTransaction", "atomikosTransactionManager" })
    public PlatformTransactionManager transactionManager() {
        return new JtaTransactionManager(atomikosUserTransaction(), atomikosTransactionManager());
    }
}
@Configuration
@DependsOn("transactionManager")
@EnableJpaRepositories( 
        entityManagerFactoryRef = "db1EntityManagerFactory"
)
@ComponentScan("xx.xxx.xxx.db1")
public class Db1DatabaseConfig extends BaseDatabaseConfig {

    @Primary
    @Bean(name = "db1DataSource")
    public DataSource db1DataSource() {
        JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
        dsLookup.setResourceRef(true);
        return dsLookup.getDataSource("jdbc/db1DB");
    }

    @Primary
    @Bean(name = "db1EntityManagerFactory")
    public LocalContainerEntityManagerFactoryBean db1EntityManagerFactory() {
        LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
        entityManagerFactory.setPackagesToScan("xx.xxx.xxx.db1.entity");
        entityManagerFactory.setPersistenceUnitName("db1PU");
        entityManagerFactory.setJtaDataSource(db1DataSource());
        entityManagerFactory.setPersistenceProvider(new HibernatePersistenceProvider());
        entityManagerFactory.setJpaVendorAdapter(db1JpaVendorAdapter());
        entityManagerFactory.setJpaDialect(new HibernateJpaDialect());
        entityManagerFactory.setJpaPropertyMap(jpaPropertiesMap());
        entityManagerFactory.setJpaProperties(jpaAdditionalProperties());
        return entityManagerFactory;
    }

    @Bean("fullTextEntityManager")
    public FullTextEntityManager fullTextEntityManager() throws InterruptedException {
        return Search.getFullTextEntityManager(db1EntityManagerFactory().getObject().createEntityManager());
    }

    @Bean
    public PersistenceAnnotationBeanPostProcessor persistenceAnnotationBeanPostProcessor()  {
        return new PersistenceAnnotationBeanPostProcessor();
    }

    @Bean
    public PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor()  {
        return new PersistenceExceptionTranslationPostProcessor();
    }
}
@Configuration
@DependsOn("transactionManager")
@EnableJpaRepositories(
        entityManagerFactoryRef = "db2EntityManagerFactory"
)
@ComponentScan("xx.xxx.xxx.db2")
public class Db2DatabaseConfig  extends BaseDatabaseConfig {

    @Primary
    @Bean(name = "db2DataSource")
    public DataSource db2DataSource() {
        JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
        dsLookup.setResourceRef(true);
        return dsLookup.getDataSource("jdbc/db2DB");
    }

    @Bean(name = "db2EntityManagerFactory")
    public LocalContainerEntityManagerFactoryBean db2EntityManagerFactory()  {
        LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
        entityManagerFactory.setPackagesToScan("xx.xxxdb2.entity");
        entityManagerFactory.setPersistenceUnitName("db2PU");
        entityManagerFactory.setJtaDataSource(db2DataSource());
        entityManagerFactory.setPersistenceProvider(new HibernatePersistenceProvider());
        entityManagerFactory.setJpaVendorAdapter(db2JpaVendorAdapter());
        entityManagerFactory.setJpaDialect(new HibernateJpaDialect());
        entityManagerFactory.setJpaPropertyMap(jpaPropertiesMap());
        return entityManagerFactory;
    }

    @Bean
    public PersistenceAnnotationBeanPostProcessor persistenceAnnotationBeanPostProcessor()  {
        return new PersistenceAnnotationBeanPostProcessor();
    }

    @Bean
    public PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor()  {
        return new PersistenceExceptionTranslationPostProcessor();
    }

}

JNDI资源(jdbc / db1DB和jdbc / db2DB)已在Glassfish中成功创建并绑定到连接池(poolDB1和poolDB2)。 Ping查询工作。 Oracle驱动程序(ojdbc6.jar)和informix已被删除在glassfish / domains / zzzz / lib中,而不是在应用程序中打包(标记为im pom.xml提供)

我没有看到我的配置有什么问题。

非常感谢任何帮助。

0 个答案:

没有答案