web-dev-qa-db-ja.com

Springブートアプリが失敗するorg.postgresql.jdbc4.Jdbc4Connection.createClob()メソッドはまだ実装されていません

私はSpringブートコマンドラインランナーアプリを使用していますが、PostGIS方言でハングします。以下のスタックトレースには何が起こっているのかが含まれています。何が間違っているのか理解できず、休止状態空間クエリがあります。

2018-04-06 12:11:08.554  INFO 31495 --- [           main] replayer.Main                            : No active profile set, falling back to default profiles: default
2018-04-06 12:11:08.780  INFO 31495 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@39d9314d: startup date [Fri Apr 06 12:11:08 NZST 2018]; root of context hierarchy
2018-04-06 12:11:10.811  INFO 31495 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-04-06 12:11:11.149  INFO 31495 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$a0866479] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-04-06 12:11:12.038  INFO 31495 --- [           main] o.s.b.w.embedded.Tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-04-06 12:11:12.113  INFO 31495 --- [           main] o.Apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-04-06 12:11:12.113  INFO 31495 --- [           main] org.Apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.28
2018-04-06 12:11:12.146  INFO 31495 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the Java.library.path: [/usr/Java/packages/lib/AMD64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-04-06 12:11:12.385  INFO 31495 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-04-06 12:11:12.386  INFO 31495 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3615 ms 
2018-04-06 12:11:12.704  INFO 31495 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-04-06 12:11:12.710  INFO 31495 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-04-06 12:11:12.711  INFO 31495 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-04-06 12:11:12.711  INFO 31495 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-04-06 12:11:12.711  INFO 31495 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-04-06 12:11:13.264  INFO 31495 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2018-04-06 12:11:14.376  INFO 31495 --- [           main] com.zaxxer.hikari.pool.PoolBase          : HikariPool-1 - Driver does not support get/set network timeout for connections. (Method org.postgresql.jdbc4.Jdbc4Connection.getNetworkTimeout() is not yet implemented.)
2018-04-06 12:11:14.834  INFO 31495 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2018-04-06 12:11:15.073  INFO 31495 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-04-06 12:11:15.111  INFO 31495 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-04-06 12:11:15.306  INFO 31495 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.0.0.Final}
2018-04-06 12:11:15.310  INFO 31495 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2018-04-06 12:11:15.313  INFO 31495 --- [           main] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2018-04-06 12:11:15.332  INFO 31495 --- [           main] o.h.spatial.integration.SpatialService   : HHH80000001: hibernate-spatial integration enabled : true
2018-04-06 12:11:15.418  INFO 31495 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.0.Final}
2018-04-06 12:11:15.891  INFO 31495 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.spatial.dialect.postgis.PostgisDialect
2018-04-06 13:10:34.209  INFO 2217 --- [           main] o.h.e.j.e.i.LobCreatorBuilderImpl        : HHH000424: Disabling contextual LOB creation as createClob() method threw error : 
Java.lang.reflect.InvocationTargetException

Java.lang.reflect.InvocationTargetException: null
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62) ~[na:1.8.0_161]
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43) ~[na:1.8.0_161]
at Java.lang.reflect.Method.invoke(Method.Java:498) ~[na:1.8.0_161]
at org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.useContextualLobCreation(LobCreatorBuilderImpl.Java:113) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.makeLobCreatorBuilder(LobCreatorBuilderImpl.Java:54) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.<init>(JdbcEnvironmentImpl.Java:247) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.Java:114) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.Java:35) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.Java:88) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.Java:234) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.Java:208) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.Java:189) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.Java:51) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.Java:94) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.Java:217) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.Java:189) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.Java:352) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.Java:111) [hibernate-core-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.Java:770) [hibernate-entitymanager-5.0.0.Final.jar:5.0.0.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.Java:797) [hibernate-entitymanager-5.0.0.Final.jar:5.0.0.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.Java:57) [spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.Java:365) [spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.Java:388) [spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.Java:377) [spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.Java:341) [spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.Java:1769) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.Java:1706) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.Java:583) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.Java:502) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.Java:312) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.Java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.Java:310) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.Java:200) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.Java:1085) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.Java:858) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:549) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.Java:140) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.Java:752) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.Java:388) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.Java:327) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at replayer.Main.main(Main.Java:29) ~[classes/:na]
Caused by: Java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc4.Jdbc4Connection.createClob() is not yet implemented.
at org.postgresql.Driver.notImplemented(Driver.Java:734) ~[postgresql-9.3-1104-jdbc41.jar:na]
at org.postgresql.jdbc4.AbstractJdbc4Connection.createClob(AbstractJdbc4Connection.Java:58) ~[postgresql-9.3-1104-jdbc41.jar:na]
at org.postgresql.jdbc4.Jdbc4Connection.createClob(Jdbc4Connection.Java:21) ~[postgresql-9.3-1104-jdbc41.jar:na]
... 42 common frames omitted

2018-04-06 13:10:34.211  INFO 2217 --- [           main] org.hibernate.type.BasicTypeRegistry     : HHH000270: Type registration [Java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@364b1061
2018-04-06 13:10:34.430  INFO 2217 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-04-06 13:10:34.462  WARN 2217 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'main': Unsatisfied dependency expressed through field 'eboxEventRepository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'repository.EboxEventRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2018-04-06 13:10:34.463  INFO 2217 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2018-04-06 13:10:34.463  INFO 2217 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2018-04-06 13:10:34.486  INFO 2217 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2018-04-06 13:10:34.488  INFO 2217 --- [           main] o.Apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-04-06 13:10:34.507  INFO 2217 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-04-06 13:10:34.641 ERROR 2217 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

**************************
APPLICATION FAILED TO START
***************************

Description:

Field eboxEventRepository in replayer.Main required a bean of type 'repository.EboxEventRepository' that could not be found.


Action:

Consider defining a bean of type 'repository.EboxEventRepository' in your configuration.

私のメインクラスは次のようになります。コマンドラインランナーにしたいので、CommandLineRunnerを実装します。

アプリケーションは、特定のテーブルからデータを読み取り、それをjsonコンテンツとディスクにダンプするだけです。

package replayer;


import com.fasterxml.jackson.databind.ObjectMapper;
import my.model.Event;
import my.model.EventMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.Banner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import repository.EventRepository;

import Java.io.PrintWriter;
import Java.util.Arrays;
import Java.util.List;
import Java.util.UUID;

@SpringBootApplication
public class Main implements CommandLineRunner {

@Autowired
EventRepository eboxEventRepository;

public static void main(String[] args) {

    SpringApplication app = new SpringApplication(Main.class);
    app.setBannerMode(Banner.Mode.OFF);
    app.run(args);

}

@Override
public void run(String... args) throws Exception {
    List<EboxEvent> eboxEvents = eboxEventRepository.findEboxEventBetweenEventTimestamps(null, null);

    final ObjectMapper objectMapper = new ObjectMapper();
    PrintWriter out = new PrintWriter("/tmp/events.tmp");

    for (EboxEvent event : eboxEvents) {
        EventMessage message = new EventMessage.Builder(EventMessage.Type.DATA_CHANGED,
                        EventMessage.Operation.CREATE,
                        my.model.Event.class.getName()).eventId(UUID.randomUUID().toString()).dataAfter(Arrays.asList(event))
                        .build();
        String json = objectMapper.writeValueAsString(message);
        out.println(json);
    }
}

}

そして、私のpom depenedenciesはこのようなものです

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.Apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.7</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>5.0.0.Final</version>
        <exclusions>
            <exclusion>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.0-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.1-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-spatial</artifactId>
        <version>5.0.0.Final</version>
        <exclusions>
            <exclusion>
                <groupId>postgresql</groupId>
                <artifactId>postgresql</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.0.0.Final</version>
        <exclusions>
            <exclusion>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.0-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.1-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.3-1104-jdbc41</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.21</version>
    </dependency>

</dependencies>
8
Pavanraotk

createClobの失敗が原因である可能性があります。 githubに関する同様の問題 https://github.com/pgjdbc/pgjdbc/issues/1102

参照されるソリューションは

http://vkuzel.blogspot.in/2016/03/spring-boot-jpa-hibernate-atomikos.html

jDBCメタデータの使用を無効にし、正しい方言を設定します。

spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect

またはYAMLで:

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

これをapplication.propertiesに追加するだけで、うまくいくかもしれません。それは私のために働いた。

1
Mohammad Sahid

このエラーはHibernateが原因です。休止状態のファイル構成を使用しているため、答えはうまくいきませんでした。

あなたのhibernate.cfg.xmlファイル追加プロパティ:

<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>

たぶん、適切なPostgreSQLダイアレクトを設定することもあります:

<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL9Dialect</property>
1
ImND