我遇到以下异常,有人能帮忙吗?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.event.internalEventListenerProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class com.stixcloud.config.persistence.PersistenceConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.hibernate.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) at org.springframework.context.annotation.AnnotationConfigApplicationContext.(AnnotationConfigApplicationContext.java:84) at com.stixcloud.main.StixCloneProductMain.main(StixCloneProductMain.java:30) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.tanukisoftware.wrapper.WrapperJarApp.run(WrapperJarApp.java:427) at java.lang.Thread.run(Thread.java:748) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class com.stixcloud.config.persistence.PersistenceConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.hibernate.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:201) at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:92) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:101) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:69) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:330) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:293) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ... 16 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class com.stixcloud.config.persistence.PersistenceConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.hibernate.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolv
下面是config类,我们使用spring、hibernate、java包装器
package com.stixcloud.config.persistence;
import com.stixcloud.service.common.factory.SisticCurrentTenantIdentifierResolver;
import com.stixcloud.service.common.factory.SisticMultiTenantConnectionProvider;
import com.stixcloud.service.common.listener.AuditInterceptor;
import oracle.jdbc.pool.OracleDataSource;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;
import org.springframework.core.env.Environment;
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.TransactionManagementConfigurer;
import javax.sql.DataSource;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@Configuration
@EnableTransactionManagement(proxyTargetClass = true, mode = AdviceMode.PROXY)
@PropertySource(value = "file:/opt/appsconfig/database.properties", ignoreResourceNotFound = true)
public class PersistenceConfig implements TransactionManagementConfigurer {
Logger logger = Logger.getLogger(PersistenceConfig.class);
@Autowired
private Environment environment;
@Value("${tenant.list}")
private String tenantList;
public DataSource newDataSource(String jdbcUrl, String jdbcUser, String jdbcPassword) {
OracleDataSource dataSource = null;
try {
dataSource = new OracleDataSource();
dataSource.setURL(jdbcUrl);
dataSource.setUser(jdbcUser);
dataSource.setPassword(jdbcPassword);
} catch (Exception e) {
logger.error("Error to create common datasource " + e);
throw new RuntimeException(e);
}
return dataSource;
}
@Bean
public SisticMultiTenantConnectionProvider sisticMultiTenantConnectionProvider() {
logger.info("Initializing datasource...");
SisticMultiTenantConnectionProvider connectionProvider = new SisticMultiTenantConnectionProvider();
Map<String, DataSource> map = new HashMap<String, DataSource>();
if(StringUtils.isBlank(tenantList)) {
throw new RuntimeException("No tenants configured in tenant list. Please check jdbc.properties.");
}
String[] tenants = tenantList.split(",");
for(String tenantID : tenants) {
String tenantJdbcUrl = environment.getProperty(tenantID + ".jdbc.url");
String tenantJdbcUser = environment.getProperty(tenantID + ".jdbc.user");
String tenantJdbcPassword = environment.getProperty(tenantID + ".jdbc.password");
DataSource dataSource = this.newDataSource(tenantJdbcUrl, tenantJdbcUser, tenantJdbcPassword);
map.put(tenantID.toUpperCase(), dataSource);
logger.info("Datasource initialized for tenant code " + tenantID.toUpperCase());
}
connectionProvider.setMap(map);
logger.info("Datasource initialization completed.");
return connectionProvider;
}
@Bean
public SisticCurrentTenantIdentifierResolver currentTenantIdentifierResolver() {
return new SisticCurrentTenantIdentifierResolver();
}
@Bean
public AuditInterceptor auditInterceptor() {
return new AuditInterceptor();
}
/**
* Session factory.
*
* @return the local session factory bean
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Bean(name = "sessionFactory")
public SessionFactory sessionFactory() {
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setPackagesToScan("com.stixcloud.domain");
sessionFactory.setEntityInterceptor(this.auditInterceptor());
sessionFactory.getHibernateProperties().put("hibernate.multi_tenant_connection_provider", this.sisticMultiTenantConnectionProvider());
sessionFactory.getHibernateProperties().put("hibernate.multiTenancy", "DATABASE");
sessionFactory.getHibernateProperties().put("hibernate.tenant_identifier_resolver", this.currentTenantIdentifierResolver());
sessionFactory.getHibernateProperties().put("hibernate.show_sql", "false");
sessionFactory.getHibernateProperties().put("hibernate.format_sql", "false");
sessionFactory.getHibernateProperties().put("hibernate.dialect", "com.stixcloud.common.dialect.OracleNativeDialect");
sessionFactory.getHibernateProperties().put("hibernate.jdbc.batch_size", "50");
sessionFactory.getHibernateProperties().put("hibernate.cache.region.factory_class", "org.hibernate.cache.ehcache.EhCacheRegionFactory");
sessionFactory.getHibernateProperties().put("hibernate.cache.use_query_cache", "false");
sessionFactory.getHibernateProperties().put("hibernate.cache.use_second_level_cache", "false");
sessionFactory.getHibernateProperties().put("hibernate.bytecode.use_reflection_optimizer", "true");
sessionFactory.getHibernateProperties().put("hibernate.connection.SetBigStringTryClob", "true");
sessionFactory.getHibernateProperties().put("hibernate.jdbc.batch_size", "0");
try {
sessionFactory.afterPropertiesSet();
} catch (IOException e) {
logger.error("Error to create session factory " + e);
throw new RuntimeException(e);
}
return sessionFactory.getObject();
}
@Bean(name = "hbTxManager")
@DependsOn("sessionFactory")
public HibernateTransactionManager hibernateTransactionManager() {
HibernateTransactionManager hibernateTransactionManager = new HibernateTransactionManager();
hibernateTransactionManager.setSessionFactory(this.sessionFactory());
hibernateTransactionManager.setAutodetectDataSource(false);
return hibernateTransactionManager;
}
public PlatformTransactionManager annotationDrivenTransactionManager() {
return this.hibernateTransactionManager();
}
}
抱歉,我看到了另一个堆栈跟踪,而再次运行,这是最底部的堆栈跟踪,这应该是原因
Caused by: java.lang.NullPointerException at org.hibernate.engine.jdbc.connections.spi.AbstractDataSourceBasedMultiTenantConnectionProviderImpl.getAnyConnection(AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java:42) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$MultiTenantConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:302) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:124) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178) at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928) at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:372) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:454) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:439) at com.stixcloud.config.persistence.PersistenceConfig.sessionFactory(PersistenceConfig.java:111) at com.stixcloud.config.persistence.PersistenceConfig$$EnhancerBySpringCGLIB$$141223b.CGLIB$sessionFactory$4() at com.stixcloud.config.persistence.PersistenceConfig$$EnhancerBySpringCGLIB$$141223b$$FastClassBySpringCGLIB$$9f56ffc0.invoke() at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:318) at com.stixcloud.config.persistence.PersistenceConfig$$EnhancerBySpringCGLIB$$141223b.sessionFactory() at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ... 63 more
在您的hibernate配置类文件中,您应该正确定义会话对象属性its方言、datasource和transaction manager,不要忘记用@bean注释它们
我试图使用Postgis 2.2和Postgreql 9.5与JPA,Postgis 9.5方言。我已经在pom.xml的要求,按这里http://www.hibernatespatial.org/documentation/documentation/和类型导入正确,但是当我试图运行程序使用几何类型我得到这个错误: 我显然遗漏了一些配置,有人能指出是什么吗?
我在MapFragment的布局文件中出现了这个错误 我试过了 > 安装Google Play服务,但仍有错误 - com.google.android.gms.maps.MapFragment(开放类,显示异常,清除缓存) 提示:在自定义视图中使用view.isinEditMode()跳过代码或在IDE中显示示例数据。 如果这是一个意外错误,您也可以尝试构建项目,然后手动刷新布局。 异常详细信息
我正在将一个Java EE应用程序部署到Bluemix,当第一个请求到达时,我得到了这个错误: 2015-05-20T23:11:58.51+0200[app/0]OUT[INFO]FFDC1015I:已创建FFDC事件:“java.util.ServiceConfigurationError:javax.servlet.ServletContainerInitializer:Provider o
我正在尝试将H2设置为内存数据库。我已将其配置为: 然而,当我尝试运行它时,我会遇到这个错误 我不确定它为什么不接受jdbc url,我的confg格式有什么问题吗?
我想使用我的本地代码通过spark-sql连接到远程配置单元。这是我的代码: 请帮帮我.