pgjdbc: org.postgresql.jdbc.PgConnection.createClob() is not yet implemented

Hello!

Trying to use postgres driver 4.2.1 in Spring Boot 2.0.0.RC1 which includes Hibernate 5.2.12 results in exception during application start -

example_api  | 2018-02-06 08:51:16.069  INFO 1 --- [           main] o.h.e.j.e.i.LobCreatorBuilderImpl        : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
example_api  | 
example_api  | java.lang.reflect.InvocationTargetException: null
example_api  | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
example_api  | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
example_api  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
example_api  | 	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
example_api  | 	at org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.useContextualLobCreation(LobCreatorBuilderImpl.java:113) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.makeLobCreatorBuilder(LobCreatorBuilderImpl.java:54) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.<init>(JdbcEnvironmentImpl.java:271) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:114) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:242) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:858) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:885) [hibernate-core-5.2.12.Final.jar!/:5.2.12.Final]
example_api  | 	at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) [spring-orm-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) [spring-orm-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:388) [spring-orm-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) [spring-orm-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) [spring-orm-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) [spring-beans-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) [spring-beans-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) [spring-beans-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) [spring-beans-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) [spring-beans-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) [spring-beans-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) [spring-beans-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1085) ~[spring-context-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:858) ~[spring-context-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
example_api  | 	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:138) ~[spring-boot-2.0.0.RC1.jar!/:2.0.0.RC1]
example_api  | 	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-2.0.0.RC1.jar!/:2.0.0.RC1]
example_api  | 	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) ~[spring-boot-2.0.0.RC1.jar!/:2.0.0.RC1]
example_api  | 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.0.RC1.jar!/:2.0.0.RC1]
example_api  | 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) ~[spring-boot-2.0.0.RC1.jar!/:2.0.0.RC1]
example_api  | 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) ~[spring-boot-2.0.0.RC1.jar!/:2.0.0.RC1]
example_api  | 	at com.mcorral.VisitorApplication.main(VisitorApplication.java:12) ~[classes!/:na]
example_api  | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
example_api  | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
example_api  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
example_api  | 	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
example_api  | 	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[app.jar:na]
example_api  | 	at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[app.jar:na]
example_api  | 	at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) ~[app.jar:na]
example_api  | 	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) ~[app.jar:na]
example_api  | Caused by: java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented.
example_api  | 	at org.postgresql.Driver.notImplemented(Driver.java:683) ~[postgresql-42.2.1.jar!/:42.2.1]
example_api  | 	at org.postgresql.jdbc.PgConnection.createClob(PgConnection.java:1252) ~[postgresql-42.2.1.jar!/:42.2.1]
example_api  | 	... 52 common frames omitted

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 26 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@mkpaz The property hibernate.jdbc.lob.non_contextual_creation works, you just need to use it like this if you’re using Spring Boot:

spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true

This is a Hinernate issue https://hibernate.atlassian.net/browse/HHH-12368

Suggested workarounds hibernate.temp.use_jdbc_metadata_defaults and hibernate.jdbc.lob.non_contextual_creation both haven’t worked for me. So I’ve just disabled logging for corresponding class:

logging:
  level:
    org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl: ERROR

Yes, it doesn’t prevent application from starting.

spring:
  jpa:
    database-platform: org.hibernate.dialect.PostgreSQL9Dialect
    properties:
      hibernate:
        temp:
          use_jdbc_metadata_defaults: false
        jdbc:
          lob:
            non_contextual_creation: true

use_jdbc_metadata_defaults: false or non_contextual_creation: true two work `fine```

This configuration is work find: spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect

To be fair, that exception shouldn’t prevent your application from starting. It’s just Hibernate telling you that, HHH000424: Disabling contextual LOB creation as createClob() caused by unsupported method org.postgresql.jdbc.PgConnection.createClob()

The solution is https://vkuzel.com/spring-boot-jpa-hibernate-atomikos-postgresql-exception

hese exceptions appears because JPA (Hibernate) supported by Atomikos is trying to verify PostgreSQL CLOB feature. This feature is not implemented by JDBC driver, so driver throws an unimportant exception. Unfortunately Atomikos has an exception listener which marks a connection as erroneous if any exception occurs.

To suppress this behaviour you have to disable driver’s feature detection and then configure it’s features manually. This is kind of shady undocumented way of how to do that, but it works.

Disable feature detection by this undocumented parameter. Check the org.hibernate.engine.jdbc.internal.JdbcServiceImpl.configure method for more details.

spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false

Because detection is disabled you have to set correct dialect by hand.

spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect

Looks like their issue then. It’s perfectly within spec to throw an exception there