spring配置出错at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244
1.SSM集成:
spring 4.0.5
hibernate 4.3.1;
sessionFactory 注入datasource
-
<bean id="sf" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
-
<property name="dataSource" ref="myDataSource" />
-
<property name="packagesToScan">
-
<list>
-
<value>xx.xx.model</value>
-
</list>
-
</property>
-
<property name="hibernateProperties">
-
<props>
-
<prop key="hibernate.dialect">
-
org.hibernate.dialect.Oracle9Dialect
-
</prop>
-
<prop key="hibernate.show_sql">true</prop>
-
</props>
-
</property>
-
</bean>
2.出错:
-
INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
-
2016-5-19 22:38:58 org.hibernate.Version logVersion
-
INFO: HHH000412: Hibernate Core {4.3.1.Final}
-
2016-5-19 22:38:58 org.hibernate.cfg.Environment <clinit>
-
INFO: HHH000206: hibernate.properties not found
-
2016-5-19 22:38:58 org.hibernate.cfg.Environment buildBytecodeProvider
-
INFO: HHH000021: Bytecode provider name : javassist
-
2016-5-19 22:38:58 org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure
-
WARN: HHH000341: Could not obtain connection metadata : 不支持的特性
-
2016-5-19 22:38:58 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
-
INFO: HHH000422: Disabling contextual LOB creation as connection was null
-
2016-5-19 22:38:58 org.springframework.web.context.ContextLoader initWebApplicationContext
-
严重: Context initialization failed
-
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sf' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
-
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
-
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
-
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
-
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
-
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
-
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
-
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
-
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:684)
-
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
-
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
-
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
-
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
-
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
-
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
-
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
-
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
-
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
-
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
-
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
-
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1263)
-
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1978)
-
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
-
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
-
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
-
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
-
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
-
at java.lang.Thread.run(Thread.java:662)
-
Caused by: java.lang.NullPointerException
-
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244)
-
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:343)
-
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431)
-
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416)
-
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
-
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
-
... 26 more
-
2016-5-19 22:38:58 org.apache.catalina.core.StandardContext listenerStart
-
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
-
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sf' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
-
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
-
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
-
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
-
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
-
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
-
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
-
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
-
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:684)
-
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
-
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
-
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
-
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
-
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
-
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
-
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
-
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
-
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
-
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
-
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
-
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1263)
-
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1978)
-
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
-
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
-
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
-
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
-
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
-
at java.lang.Thread.run(Thread.java:662)
-
Caused by: java.lang.NullPointerException
-
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244)
-
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:343)
-
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431)
-
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416)
-
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
-
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
-
... 26 more
-
-
3.查了半天也没发现问题在哪里,
后来看到了一位博友博文: http://blog.csdn.net/luxiaoshuai/article/details/40540929
原来是使用连接池注入的数据源 需要添加如下一条属性:
<prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
配置如下:
-
<bean id="sf"
-
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
-
<property name="dataSource" ref="myDataSource" />
-
<property name="packagesToScan">
-
<list>
-
<value>xx.xx.model</value>
-
</list>
-
</property>
-
<property name="hibernateProperties">
-
<props>
-
<prop key="hibernate.dialect">
-
org.hibernate.dialect.Oracle9Dialect
-
</prop>
-
<prop key="hibernate.show_sql">true</prop>
-
<!-- 重要: 使用连接池设置false -->
-
<prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
-
</props>
-
</property>
-
</bean>
添加上以后,问题立马解决!
以后还是要多看源码啊.
相关推荐
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService...
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet at org.apache.catalina.loader.WebappClassLoader.loadClass (WebappClassLoader.java:1680) 严重: Servlet /LogMess ...
解决 java.lang.NoSuchFieldError: STRING at org.jbpm.identity.hibernate.PermissionUserType. 不用jbpm的jbpm-identity.jar 用这个就好
SpringBoot是一种广泛使用的Java开发框架,它简化了基于Spring的应用开发。其中,将SpringBoot应用打包成WAR(Web Application Archive)文件用于部署到Web服务器上是一种常见的需求。然而,在这个过程中可能会遇到...
java.lang.SecurityException: class "org.apache.commons.collections.SequencedHashMap"'s signer information does not match signer information of other classes in the same package at java.lang....
oracle.odi.core.exception.OdiRuntimeException: java.lang.IllegalArgumentException: Could not load JDBC driver class [com.microsoft.jdbc.sqlserver.SQLServerDriver] at oracle.odi.core.datasource....
3. 运行 `./configure` 进行配置 4. 编译源码:`make` 5. 安装:`make install` 6. 验证安装:运行 `rpcinfo -p`,如果没有错误返回,表示安装成功。 其次,LoadRunner 监控还需要 `rsh` 服务的支持。你可以通过 `...
2. **数据库连接配置**:在Java代码中,我们需要使用`Class.forName()`方法来加载JDBC驱动,例如: ```java Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); ``` 然后创建数据库连接,通过`...
Auto-configured JDBC Tests 43.3.13. Auto-configured jOOQ Tests 43.3.14. Auto-configured Data MongoDB Tests 43.3.15. Auto-configured Data Neo4j Tests 43.3.16. Auto-configured Data Redis Tests 43.3.17....
SpringSecurity是Java领域中一个强大的安全框架,用于处理Web应用的安全性问题,如认证、授权等。在SpringSecurity中,登出(logout)功能是应用中不可或缺的一部分,它允许用户安全地结束当前会话,清除相关认证...
Spring Boot 之 Jackson 配置方式详解 Spring Boot 框架中,Jackson 是默认的 JSON 处理器,它提供了两种配置方式来控制 JSON 序列化和反序列化的行为。在本文中,我们将详细介绍这两种配置方式的使用。 方式一:...
### 揭秘Spring的魔力:Spring框架在Java开发中的核心作用 #### Java的主要特点及其应用领域 Java作为一门广泛使用的编程语言,自1995年由Sun Microsystems首次发布以来,已经成为众多领域的首选语言之一。Java的...
Over 40 recipes for creating cloud-ready Java web applications with Spring MVC About This Book Configure Spring MVC to build logic-less controllers that transparently support the most advanced web ...
SSM框架是Java Web开发中的一个重要组合,它结合了Spring框架的强大功能、MyBatis的高效持久层框架以及Spring MVC的Web层控制能力,为开发者提供了简洁高效的Web应用解决方案。 ### 一、环境搭建 #### 1. 开发工具...
SpringSecurity是一款广泛应用于Java平台的安全框架,用于保护Web应用程序免受未经授权的访问和攻击。它提供了全面的身份验证、授权和会话管理功能。在“SpringSecurity静态资源.rar”这个压缩包中,我们可以推测...
3. 配置 MySQL:./configure --help 4. 设置 MySQL 的安装目录:/usr/local/mysql 5. 设置 MySQL 的默认编码:GBK 6. 创建 MySQL 用户和组:groupadd mysql、useradd mysql -g mysql 7. 初始化 MySQL 数据库:./...
在这个阶段,你需要运行`./configure`脚本来配置编译选项。在标题中提到的配置中,`--prefix`用于设置Nginx的安装路径,默认为`/usr/local/nginx`。你可以根据需要添加其他配置参数。例如: ```bash ./configure...
《SQL JDBC4与Java连接数据库在MyEclipse中的...掌握JDBC的基本用法和高级特性,以及如何在IDE中配置和使用驱动,对于Java开发者来说至关重要。通过实践和理解这些知识,你可以更有效地构建和维护数据驱动的应用程序。
You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. 加上serverTimezone...
### Spring Security与Spring Boot集成详解 #### 一、Spring Security简介 Spring Security 是一个功能强大的安全框架,它为基于 Java 的应用程序提供了身份验证(authentication)、授权(authorization)、CSRF ...