我试图将微服务作为依赖于RocksDB的Spring Boot应用程序运行。目前,我一直在下面收到异常消息。
环境: Windows 10 v.1809 OpenJDK 10.2 构建系统-Maven 3.6 InteliJ理念2018.3.1 RocksDB:
<dependency>
<groupId>org.rocksdb</groupId>
<artifactId>rocksdbjni</artifactId>
<version>5.17.2</version>
</dependency>
Kafka(2.0)和Zookeeper在Docker容器中运行。
服务启动后,每个kafka线程都会引发异常:
线程“线程”中的异常java.lang.NoClassDefFoundError:无法 在以下位置初始化类org.rocksdb.Options org.apache.kafka.streams.state.internals.RocksDBStore.openDB(RocksDBStore.java:128) 在 org.apache.kafka.streams.state.internals.RocksDBStore.init(RocksDBStore.java:185) 在 org.apache.kafka.streams.state.internals.ChangeLoggingKeyValueBytesStore.init(ChangeLoggingKeyValueBytesStore.java:40) 在 org.apache.kafka.streams.state.internals.CachingKeyValueStore.init(CachingKeyValueStore.java:59) 在 org.apache.kafka.streams.state.internals.InnerMeteredKeyValueStore.init(InnerMeteredKeyValueStore.java:160) 在 org.apache.kafka.streams.state.internals.MeteredKeyValueBytesStore.init(MeteredKeyValueBytesStore.java:104) 在 org.apache.kafka.streams.processor.internals.AbstractTask.registerStateStores(AbstractTask.java:225) 在 org.apache.kafka.streams.processor.internals.StreamTask.initializeStateStores(StreamTask.java:159) 在 org.apache.kafka.streams.processor.internals.AssignedTasks.initializeNewTasks(AssignedTasks.java:123) 在 org.apache.kafka.streams.processor.internals.TaskManager.updateNewAndRestoringTasks(TaskManager.java:250) 在 org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:810) 在 org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:771) 在 org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:741)
我尝试使用一些从4.9开始的旧版RocksDB。 手动设置ROCKSDB_SHAREDLIB_DIR环境变量。
有人可以分享任何想法是什么问题以及如何解决吗?
[ UPD ] 我添加了服务器的父pom文件和我要运行的服务的子pom文件。
服务器:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>group</groupId>
<artifactId>server</artifactId>
<version>0.13.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>name</name>
<!-- Global Properties -->
<properties>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
<spring-boot.version>2.0.5.RELEASE</spring-boot.version>
<!-- Maven Properties -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
<!-- Maven Plugin Versions -->
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
<maven-javadoc-plugin.version>2.10.4</maven-javadoc-plugin.version>
<!-- Standard Dependency Versions -->
<commons-collections.version>3.2.2</commons-collections.version>
<commons-io.version>2.5</commons-io.version>
<guava.version>21.0</guava.version>
<hibernate-enhance-plugin.version>5.3.6.Final</hibernate-enhance-plugin.version>
<hibernate-ehcache.version>5.3.6.Final</hibernate-ehcache.version>
<hibernate-core.version>5.3.6.Final</hibernate-core.version>
<java.version>10</java.version>
<jms.version>2.0.1</jms.version>
<log4j.version>2.8.2</log4j.version>
<activemq.version>5.15.4</activemq.version>
<activemq-core.version>5.7.0</activemq-core.version>
<javax.inject.version>1</javax.inject.version>
<json-patch.version>1.9</json-patch.version>
<keycloak.version>4.3.0.Final</keycloak.version>
<jaxb.version>2.3.0</jaxb.version>
<liquibase.version>3.5.3</liquibase.version>
<postgresql.version>42.1.1</postgresql.version>
<!-- Standard Testing Versions -->
<jacoco.version>0.7.9</jacoco.version>
<junit.version>5.2.0</junit.version>
<mockito.version>2.21.0</mockito.version>
<maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version>
<!-- Code-generating Tool Versions -->
<org.mapstruct.version>1.2.0.Final</org.mapstruct.version>
<org.projectlombok.version>1.18.0</org.projectlombok.version>
<!-- Kafka Properties -->
<spring-cloud-stream-binder-kafka.version>2.0.1.RELEASE</spring-cloud-stream-binder-kafka.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<executions>
<execution>
<id>aggregate</id>
<goals>
<goal>aggregate</goal>
</goals>
<phase>site</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<forkCount>4</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xmx2048m</argLine>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Common Dependencies -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commons-collections.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
<scope>provided</scope>
</dependency>
<!-- Spring Cloud Dependencies -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
</dependency>
<!-- Jackson JSON Dependencies -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Json Patch support -->
<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-patch</artifactId>
<version>${json-patch.version}</version>
</dependency>
<!-- Testing Dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<!-- Exclude JUnit 4 from starter-test (and all other related test-starter, i.e
those for security and project reactor -->
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<!-- Spring Cloud Dependencies -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Spring Boot Dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-core.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>${hibernate-ehcache.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
服务:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>server</artifactId>
<groupId>group</groupId>
<version>0.13.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>service</artifactId>
<name>service</name>
<packaging>jar</packaging>
<!-- Global Properties -->
<properties>
<!-- Traffic Control Properties -->
<tc.build.version>${maven.build.timestamp}</tc.build.version>
<!-- Maven Properties -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
<!-- Spring Boot Properties -->
<start-class>ServiceApplication</start-class>
<spring-cloud-stream-binder-kafka.version>2.0.1.RELEASE</spring-cloud-stream-binder-kafka.version>
<!-- Kafka Properties -->
<kafka-streams-test-utils.version>2.0.0</kafka-streams-test-utils.version>
<!-- Cache Properties -->
<ehcache.version>2.10.4</ehcache.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>${java.version}</compilerVersion>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<compilerArg>
<!-- The MapStruct property forces to create component from generated mapper to look up in Spring IoC container -->
-Amapstruct.defaultComponentModel=spring
</compilerArg>
<compilerArg>
<!-- The MapStruct property forces to create component from generated mapper to look up in Spring IoC container -->
-Amapstruct.unmappedTargetPolicy=ERROR
</compilerArg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<!-- Custom AccessorNamingStrategy SPI implementation -->
<groupId>group</groupId>
<artifactId>core-lib</artifactId>
<version>${project.parent.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>aggregate</id>
<goals>
<goal>aggregate</goal>
</goals>
<phase>site</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Dropwizard Metrics + Prometheus Dependencies -->
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
<!-- Spring Boot Dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<!-- Spring Framework Dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<!-- Spring Integration Dependencies -->
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-jms</artifactId>
</dependency>
<!-- Spring Cloud Dependencies -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Spring Cloud Stream -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
<version>${spring-cloud-stream-binder-kafka.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka-streams</artifactId>
<version>${spring-cloud-stream-binder-kafka.version}</version>
<exclusions>
<exclusion>
<artifactId>rocksdbjni</artifactId>
<groupId>org.rocksdb</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.rocksdb</groupId>
<artifactId>rocksdbjni</artifactId>
<version>5.17.2</version>
</dependency>
<!-- Keycloak Dependencies -->
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
<version>${keycloak.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-security-adapter</artifactId>
<version>${keycloak.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
<version>${keycloak.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak.bom</groupId>
<artifactId>keycloak-adapter-bom</artifactId>
<version>${keycloak.version}</version>
<type>pom</type>
</dependency>
<!-- Testing Dependencies -->
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>${jacoco.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams-test-utils</artifactId>
<version>${kafka-streams-test-utils.version}</version>
<scope>test</scope>
</dependency>
<!-- Code-generating Tool Dependencies -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
<!-- Ehcache Dependencies -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>${ehcache.version}</version>
</dependency>
</dependencies>
</project>
如果未在pom文件中设置RocksDB的依赖关系,SpingCloud将使用一些较旧的RocksDB版本,如我所记得的5.7.3。并产生相同的异常。
答案 0 :(得分:1)
看来,我的问题是由
引起的“ java.lang.UnsatisfiedLinkError:Local \ Temp \ librocksdbjni6935746072594020003.dll:找不到依赖的库”
被我最初询问的15个重复异常所隐藏。
通过安装Microsoft Visual C ++ 2015 Redistributableх64解决了该问题。 请注意,无论所有较新的可再发行组件,都应安装2015软件包 您已经拥有的版本。
答案 1 :(得分:0)
此问题的根本原因是正确的-错过了“ Microsoft Visual C ++ Redistributable”,但我尚未安装确切的版本-“ Microsoft Visual C ++ 2015 Redistributableх64”,并且类似的环境运行良好,没有错误。
我具有以下已安装的“ MS C ++可再发行”版本的列表:
-Microsoft Visual C ++ 2005可再发行组件(8.0.61001)
-Microsoft Visual C ++ 2005可再发行组件(x64)(8.0.61000)
-Microsoft Visual C ++ 2005可再发行组件(x64)(8.0.56336)
-Microsoft Visual C ++ 2008可再发行-x64(9.0.30729.4148)
-Microsoft Visual C ++ 2008可再发行-x64(9.0.21022)
-Microsoft Visual C ++ 2008可再发行-x64(9.0.30729.6161)
-Microsoft Visual C ++ 2008可再发行-x86(9.0.30729.6161)
-Microsoft Visual C ++ 2008可再发行-x86(9.0.21022)
-Microsoft Visual C ++ 2008可再发行-x64(9.0.30729)
-Microsoft Visual C ++ 2008可再发行-x86(9.0.30729)
-Microsoft Visual C ++ 2008可再发行-x86(9.0.30729.4148)
-Microsoft Visual C ++ 2008可再发行-x86(9.0.30729)
-Microsoft Visual C ++ 2010 x64可再发行组件(10.0.40219)
-Microsoft Visual C ++ 2010 x86可再发行组件(10.0.40219)