`

spring配置出错jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244

 
阅读更多

spring配置出错at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244

 

1.SSM集成:

spring 4.0.5

hibernate 4.3.1;

sessionFactory 注入datasource

 

  1.  
    <bean id="sf" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  2.  
    <property name="dataSource" ref="myDataSource" />
  3.  
    <property name="packagesToScan">
  4.  
    <list>
  5.  
    <value>xx.xx.model</value>
  6.  
    </list>
  7.  
    </property>
  8.  
    <property name="hibernateProperties">
  9.  
    <props>
  10.  
    <prop key="hibernate.dialect">
  11.  
    org.hibernate.dialect.Oracle9Dialect
  12.  
    </prop>
  13.  
    <prop key="hibernate.show_sql">true</prop>
  14.  
    </props>
  15.  
    </property>
  16.  
    </bean>



 

 

2.出错:

 

  1.  
    INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
  2.  
    2016-5-19 22:38:58 org.hibernate.Version logVersion
  3.  
    INFO: HHH000412: Hibernate Core {4.3.1.Final}
  4.  
    2016-5-19 22:38:58 org.hibernate.cfg.Environment <clinit>
  5.  
    INFO: HHH000206: hibernate.properties not found
  6.  
    2016-5-19 22:38:58 org.hibernate.cfg.Environment buildBytecodeProvider
  7.  
    INFO: HHH000021: Bytecode provider name : javassist
  8.  
    2016-5-19 22:38:58 org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure
  9.  
    WARN: HHH000341: Could not obtain connection metadata : 不支持的特性
  10.  
    2016-5-19 22:38:58 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
  11.  
    INFO: HHH000422: Disabling contextual LOB creation as connection was null
  12.  
    2016-5-19 22:38:58 org.springframework.web.context.ContextLoader initWebApplicationContext
  13.  
    严重: Context initialization failed
  14.  
    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
  15.  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
  16.  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
  17.  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
  18.  
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
  19.  
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
  20.  
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
  21.  
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
  22.  
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:684)
  23.  
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
  24.  
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
  25.  
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
  26.  
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
  27.  
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
  28.  
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
  29.  
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
  30.  
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  31.  
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
  32.  
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
  33.  
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
  34.  
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1263)
  35.  
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1978)
  36.  
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
  37.  
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
  38.  
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  39.  
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
  40.  
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
  41.  
    at java.lang.Thread.run(Thread.java:662)
  42.  
    Caused by: java.lang.NullPointerException
  43.  
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244)
  44.  
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
  45.  
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
  46.  
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
  47.  
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
  48.  
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
  49.  
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
  50.  
    at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:343)
  51.  
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431)
  52.  
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416)
  53.  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
  54.  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
  55.  
    ... 26 more
  56.  
    2016-5-19 22:38:58 org.apache.catalina.core.StandardContext listenerStart
  57.  
    严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  58.  
    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
  59.  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
  60.  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
  61.  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
  62.  
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
  63.  
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
  64.  
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
  65.  
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
  66.  
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:684)
  67.  
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
  68.  
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
  69.  
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
  70.  
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
  71.  
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
  72.  
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
  73.  
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
  74.  
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  75.  
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
  76.  
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
  77.  
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
  78.  
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1263)
  79.  
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1978)
  80.  
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
  81.  
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
  82.  
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  83.  
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
  84.  
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
  85.  
    at java.lang.Thread.run(Thread.java:662)
  86.  
    Caused by: java.lang.NullPointerException
  87.  
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244)
  88.  
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
  89.  
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
  90.  
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
  91.  
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
  92.  
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
  93.  
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
  94.  
    at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:343)
  95.  
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431)
  96.  
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416)
  97.  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
  98.  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
  99.  
    ... 26 more
  100.  
     
  101.  
     

 

 

3.查了半天也没发现问题在哪里,

后来看到了一位博友博文: http://blog.csdn.net/luxiaoshuai/article/details/40540929

原来是使用连接池注入的数据源 需要添加如下一条属性:

 

<prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>

 

 

配置如下:

 

  1.  
    <bean id="sf"
  2.  
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  3.  
    <property name="dataSource" ref="myDataSource" />
  4.  
    <property name="packagesToScan">
  5.  
    <list>
  6.  
    <value>xx.xx.model</value>
  7.  
    </list>
  8.  
    </property>
  9.  
    <property name="hibernateProperties">
  10.  
    <props>
  11.  
    <prop key="hibernate.dialect">
  12.  
    org.hibernate.dialect.Oracle9Dialect
  13.  
    </prop>
  14.  
    <prop key="hibernate.show_sql">true</prop>
  15.  
    <!-- 重要: 使用连接池设置false -->
  16.  
    <prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
  17.  
    </props>
  18.  
    </property>
  19.  
    </bean>



 

添加上以后,问题立马解决! 

以后还是要多看源码啊.

 

分享到:
评论

相关推荐

    HIbernate4.3.6整合c3p0所需jar

    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService...

    spring的jar包解决:DispatcherServlet

    java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet at org.apache.catalina.loader.WebappClassLoader.loadClass (WebappClassLoader.java:1680) 严重: Servlet /LogMess ...

    java.lang.NoSuchFieldError: STRING

    解决 java.lang.NoSuchFieldError: STRING at org.jbpm.identity.hibernate.PermissionUserType. 不用jbpm的jbpm-identity.jar 用这个就好

    springBoot 打war包 程序包com.sun.istack.internal不存在的问题及解决方案

    SpringBoot是一种广泛使用的Java开发框架,它简化了基于Spring的应用开发。其中,将SpringBoot应用打包成WAR(Web Application Archive)文件用于部署到Web服务器上是一种常见的需求。然而,在这个过程中可能会遇到...

    commons-beanutils-1.7.0

    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....

    ODI代理找不到驱动

    oracle.odi.core.exception.OdiRuntimeException: java.lang.IllegalArgumentException: Could not load JDBC driver class [com.microsoft.jdbc.sqlserver.SQLServerDriver] at oracle.odi.core.datasource....

    loadrunner监控linux的相关配置

    3. 运行 `./configure` 进行配置 4. 编译源码:`make` 5. 安装:`make install` 6. 验证安装:运行 `rpcinfo -p`,如果没有错误返回,表示安装成功。 其次,LoadRunner 监控还需要 `rsh` 服务的支持。你可以通过 `...

    数据库加载驱动jdbc.zip

    2. **数据库连接配置**:在Java代码中,我们需要使用`Class.forName()`方法来加载JDBC驱动,例如: ```java Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); ``` 然后创建数据库连接,通过`...

    spring-boot-reference.pdf

    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_logout.rar

    SpringSecurity是Java领域中一个强大的安全框架,用于处理Web应用的安全性问题,如认证、授权等。在SpringSecurity中,登出(logout)功能是应用中不可或缺的一部分,它允许用户安全地结束当前会话,清除相关认证...

    详解springboot之jackson的两种配置方式

    Spring Boot 之 Jackson 配置方式详解 Spring Boot 框架中,Jackson 是默认的 JSON 处理器,它提供了两种配置方式来控制 JSON 序列化和反序列化的行为。在本文中,我们将详细介绍这两种配置方式的使用。 方式一:...

    揭秘Spring的魔力:Spring框架在Java开发中的核心作用

    ### 揭秘Spring的魔力:Spring框架在Java开发中的核心作用 #### Java的主要特点及其应用领域 Java作为一门广泛使用的编程语言,自1995年由Sun Microsystems首次发布以来,已经成为众多领域的首选语言之一。Java的...

    Spring.MVC.Cookbook.1784396419

    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框架实战 SSM spring4.1.7+mybatis+SpringMVC 第一部分(Spring+Mybatis) 配置两边 都过

    SSM框架是Java Web开发中的一个重要组合,它结合了Spring框架的强大功能、MyBatis的高效持久层框架以及Spring MVC的Web层控制能力,为开发者提供了简洁高效的Web应用解决方案。 ### 一、环境搭建 #### 1. 开发工具...

    SpringSecurity静态资源.rar

    SpringSecurity是一款广泛应用于Java平台的安全框架,用于保护Web应用程序免受未经授权的访问和攻击。它提供了全面的身份验证、授权和会话管理功能。在“SpringSecurity静态资源.rar”这个压缩包中,我们可以推测...

    linux下php+mysql+apatch搭建web服务器

    3. 配置 MySQL:./configure --help 4. 设置 MySQL 的安装目录:/usr/local/mysql 5. 设置 MySQL 的默认编码:GBK 6. 创建 MySQL 用户和组:groupadd mysql、useradd mysql -g mysql 7. 初始化 MySQL 数据库:./...

    Linux 下 Nginx的安装:(解压,进入目录里面执行,./configure –-> make -> sudo make install)

    在这个阶段,你需要运行`./configure`脚本来配置编译选项。在标题中提到的配置中,`--prefix`用于设置Nginx的安装路径,默认为`/usr/local/nginx`。你可以根据需要添加其他配置参数。例如: ```bash ./configure...

    sqljdbc4.zip

    《SQL JDBC4与Java连接数据库在MyEclipse中的...掌握JDBC的基本用法和高级特性,以及如何在IDE中配置和使用驱动,对于Java开发者来说至关重要。通过实践和理解这些知识,你可以更有效地构建和维护数据驱动的应用程序。

    mysql-connector-java-8.0.11.jar

    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...

    SpringSecurity_day03.pdf

    ### Spring Security与Spring Boot集成详解 #### 一、Spring Security简介 Spring Security 是一个功能强大的安全框架,它为基于 Java 的应用程序提供了身份验证(authentication)、授权(authorization)、CSRF ...

Global site tag (gtag.js) - Google Analytics