[Question] MessageBodyWriter not found for media type=application/json
liming1010 opened this issue · 10 comments
Problem Type (问题类型)
rest-api (结果不合预期)
Before submit
- 我已经确认现有的 Issues 与 FAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)
Environment (环境信息)
server版本1.0
toolchain 版本1.0
maven
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-client</artifactId>
<version>1.0.0</version>
</dependency>
Your Question (问题描述)
使用
hugeClient = HugeClient.builder(properties.getProperty("hugeGraphUrl"), properties.getProperty("graph"))
.configUser("**", "**") // 默认未开启用户权限
.build();
连接成功
创建元数据错误:
schema.propertyKey(value.getHp()).asText().ifNotExist().create();
error:
`严重: MessageBodyWriter not found for media type=application/json, type=class org.apache.hugegraph.structure.schema.PropertyKey, genericType=class org.apache.hugegraph.structure.schema.PropertyKey.
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.UndeclaredThrowableException
at com.tpy.commons.HugeFactory.init(HugeFactory.java:33)
at com.tpy.commons.HugeFactory.<init>(HugeFactory.java:18)
at com.tpy.service.HugeService.<init>(HugeService.java:30)
at com.tpy.service.UrlHandle.<init>(UrlHandle.java:29)
at com.tpy.ServiceApplication.main(ServiceApplication.java:17)
Caused by: java.lang.reflect.UndeclaredThrowableException
at jdk.proxy2/jdk.proxy2.$Proxy28.create(Unknown Source)
at com.tpy.commons.HugeFactory.initProperty(HugeFactory.java:44)
at com.tpy.commons.HugeFactory.init(HugeFactory.java:30)
... 4 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.apache.hugegraph.structure.schema.BuilderProxy.invoke(BuilderProxy.java:52)
... 7 more
Caused by: org.apache.hugegraph.rest.ClientException: Failed to do request
at org.apache.hugegraph.rest.AbstractRestClient.request(AbstractRestClient.java:200)
at org.apache.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:227)
at org.apache.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:206)
at org.apache.hugegraph.api.schema.PropertyKeyAPI.create(PropertyKeyAPI.java:48)
at org.apache.hugegraph.driver.SchemaManager.addPropertyKey(SchemaManager.java:85)
at org.apache.hugegraph.driver.SchemaManager.addPropertyKey(SchemaManager.java:80)
at org.apache.hugegraph.structure.schema.PropertyKey$BuilderImpl.create(PropertyKey.java:157)
at org.apache.hugegraph.structure.schema.PropertyKey$BuilderImpl.create(PropertyKey.java:140)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
... 9 more
Caused by: jakarta.ws.rs.ProcessingException: org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class org.apache.hugegraph.structure.schema.PropertyKey, genericType=class org.apache.hugegraph.structure.schema.PropertyKey.
at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:531)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:297)
at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$0(JerseyInvocation.java:662)
at org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:697)
at org.glassfish.jersey.client.JerseyInvocation.lambda$runInScope$3(JerseyInvocation.java:691)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:205)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:390)
at org.glassfish.jersey.client.JerseyInvocation.runInScope(JerseyInvocation.java:691)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:661)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:439)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:345)
at org.apache.hugegraph.rest.AbstractRestClient.lambda$post$1(AbstractRestClient.java:229)
at org.apache.hugegraph.rest.AbstractRestClient.request(AbstractRestClient.java:198)
... 17 more
Caused by: org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class org.apache.hugegraph.structure.schema.PropertyKey, genericType=class org.apache.hugegraph.structure.schema.PropertyKey.
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:224)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
at org.glassfish.jersey.spi.ContentEncoder.aroundWriteTo(ContentEncoder.java:113)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1116)
at org.glassfish.jersey.client.ClientRequest.doWriteEntity(ClientRequest.java:461)
at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:443)
at org.glassfish.jersey.apache.connector.ApacheConnector$1.writeTo(ApacheConnector.java:637)
at org.apache.http.impl.execchain.RequestEntityProxy.writeTo(RequestEntityProxy.java:121)
at org.apache.http.impl.DefaultBHttpClientConnection.sendRequestEntity(DefaultBHttpClientConnection.java:156)
at org.apache.http.impl.conn.CPoolProxy.sendRequestEntity(CPoolProxy.java:152)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:238)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:483)
... 31 more`
访问http://192.168.0.183:8080/graphs
返回
{"graphs":["hugegraph"]}
服务ok
Vertex/Edge example (问题点 / 边数据举例)
No response
Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
No response
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-client</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</exclusion>
</exclusions>
</dependency>
我本地排除org.glassfish.jersey.media:jersey-media-json-jackson依赖后,遇到了和你相同的错误。
我猜测你可能也是类似的情况
检查下你的项目中jersey-media-json-jackson依赖是否正常?
如果可以最好贴出你项目完整的pom依赖
[INFO] -------------------------< org.example:Url >--------------------------
[INFO] Building Url 1.0-SNAPSHOT [1/5]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ Url ---
[INFO] org.example:Url:pom:1.0-SNAPSHOT
[INFO] +- org.slf4j:slf4j-api:jar:2.0.5:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.4.7:compile
[INFO] \- ch.qos.logback:logback-core:jar:1.4.7:compile
[INFO]
[INFO] -------------------------< org.example:model >--------------------------
[INFO] Building model 1.0-SNAPSHOT [2/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ model ---
[INFO] org.example:model:jar:1.0-SNAPSHOT
[INFO] +- org.slf4j:slf4j-api:jar:2.0.5:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.4.7:compile
[INFO] \- ch.qos.logback:logback-core:jar:1.4.7:compile
[INFO]
[INFO] ---------------------------< org.example:db >---------------------------
[INFO] Building db 1.0-SNAPSHOT [3/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ db ---
[INFO] org.example:db:jar:1.0-SNAPSHOT
[INFO] +- org.postgresql:postgresql:jar:42.6.0:compile
[INFO] | \- org.checkerframework:checker-qual:jar:3.31.0:runtime
[INFO] +- com.zaxxer:HikariCP:jar:5.0.1:compile
[INFO] +- com.querydsl:querydsl-sql:jar:5.0.0:compile
[INFO] | \- com.querydsl:querydsl-core:jar:5.0.0:compile
[INFO] | \- com.mysema.commons:mysema-commons-lang:jar:0.2.4:compile
[INFO] +- com.querydsl:querydsl-sql-codegen:jar:5.0.0:provided
[INFO] | \- com.querydsl:querydsl-codegen:jar:5.0.0:provided
[INFO] | +- com.querydsl:codegen-utils:jar:5.0.0:provided
[INFO] | | \- org.eclipse.jdt:ecj:jar:3.26.0:provided
[INFO] | +- javax.inject:javax.inject:jar:1:provided
[INFO] | \- io.github.classgraph:classgraph:jar:4.8.108:provided
[INFO] +- jakarta.persistence:jakarta.persistence-api:jar:3.1.0:compile
[INFO] +- org.example:model:jar:1.0-SNAPSHOT:compile
[INFO] +- org.slf4j:slf4j-api:jar:2.0.5:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.4.7:compile
[INFO] \- ch.qos.logback:logback-core:jar:1.4.7:compile
[INFO]
[INFO] --------------------------< org.example:Huge >--------------------------
[INFO] Building Huge 1.0-SNAPSHOT [4/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ Huge ---
[INFO] org.example:Huge:jar:1.0-SNAPSHOT
[INFO] +- org.apache.hugegraph:hugegraph-client:jar:1.0.0:compile
[INFO] | +- org.apache.hugegraph:hugegraph-common:jar:1.0.0:compile
[INFO] | | +- junit:junit:jar:4.13.1:compile
[INFO] | | | \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] | | +- org.apache.logging.log4j:log4j-api:jar:2.18.0:compile
[INFO] | | +- org.apache.logging.log4j:log4j-core:jar:2.18.0:compile
[INFO] | | +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.18.0:compile
[INFO] | | +- org.glassfish:javax.json:jar:1.0:compile
[INFO] | | +- commons-configuration:commons-configuration:jar:1.10:compile
[INFO] | | | +- commons-lang:commons-lang:jar:2.6:compile
[INFO] | | | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | | +- org.apache.commons:commons-configuration2:jar:2.8.0:compile
[INFO] | | | +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] | | | \- org.apache.commons:commons-text:jar:1.9:compile
[INFO] | | +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] | | +- commons-io:commons-io:jar:2.7:compile
[INFO] | | +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.13:compile
[INFO] | | +- com.google.guava:guava:jar:30.0-jre:compile
[INFO] | | | +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] | | | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] | | | +- org.checkerframework:checker-qual:jar:3.5.0:compile
[INFO] | | | +- com.google.errorprone:error_prone_annotations:jar:2.3.4:compile
[INFO] | | | \- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] | | +- com.google.code.findbugs:jsr305:jar:3.0.1:compile
[INFO] | | +- joda-time:joda-time:jar:2.10.8:compile
[INFO] | | +- org.javassist:javassist:jar:3.28.0-GA:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.0-rc1:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-core:jar:2.14.0-rc1:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.0-rc1:compile
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.14.0-rc1:compile
[INFO] | | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.14.0-rc1:compile
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.14.0-rc1:compile
[INFO] | | +- org.glassfish.jersey.core:jersey-client:jar:3.0.3:compile
[INFO] | | | \- jakarta.inject:jakarta.inject-api:jar:2.0.0:compile
[INFO] | | +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:3.0.3:compile
[INFO] | | | +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:3.0.3:compile
[INFO] | | | \- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] | | | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | | +- org.glassfish.jersey.connectors:jersey-apache-connector:jar:3.0.3:compile
[INFO] | | | \- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] | | | \- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] | | +- org.glassfish.jersey.inject:jersey-hk2:jar:3.0.3:compile
[INFO] | | | \- org.glassfish.hk2:hk2-locator:jar:3.0.1:compile
[INFO] | | | +- org.glassfish.hk2.external:aopalliance-repackaged:jar:3.0.1:compile
[INFO] | | | +- org.glassfish.hk2:hk2-api:jar:3.0.1:compile
[INFO] | | | \- org.glassfish.hk2:hk2-utils:jar:3.0.1:compile
[INFO] | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0-RC2:compile
[INFO] | | \- com.sun.xml.bind:jaxb-impl:jar:3.0.2:runtime
[INFO] | | \- com.sun.xml.bind:jaxb-core:jar:3.0.2:runtime
[INFO] | | \- com.sun.activation:jakarta.activation:jar:2.0.1:runtime
[INFO] | +- org.lz4:lz4-java:jar:1.4.0:compile
[INFO] | \- org.glassfish.jersey.containers:jersey-container-servlet:jar:3.0.3:compile
[INFO] | +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:3.0.3:compile
[INFO] | +- org.glassfish.jersey.core:jersey-common:jar:3.0.3:compile
[INFO] | | +- jakarta.annotation:jakarta.annotation-api:jar:2.0.0:compile
[INFO] | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.3:compile
[INFO] | +- org.glassfish.jersey.core:jersey-server:jar:3.0.3:compile
[INFO] | | \- jakarta.validation:jakarta.validation-api:jar:3.0.0:compile
[INFO] | \- jakarta.ws.rs:jakarta.ws.rs-api:jar:3.0.0:compile
[INFO] +- org.example:model:jar:1.0-SNAPSHOT:compile
[INFO] +- org.slf4j:slf4j-api:jar:2.0.5:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.4.7:compile
[INFO] \- ch.qos.logback:logback-core:jar:1.4.7:compile
[INFO]
[INFO] ------------------------< org.example:service >-------------------------
[INFO] Building service 1.0-SNAPSHOT [5/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ service ---
[INFO] org.example:service:jar:1.0-SNAPSHOT
[INFO] +- org.seleniumhq.selenium:selenium-java:jar:4.8.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-api:jar:4.8.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-chrome-driver:jar:4.8.1:compile
[INFO] | | +- com.google.auto.service:auto-service-annotations:jar:1.0.1:compile
[INFO] | | +- com.google.auto.service:auto-service:jar:1.0.1:compile
[INFO] | | | \- com.google.auto:auto-common:jar:1.2:compile
[INFO] | | +- com.google.guava:guava:jar:31.1-jre:compile
[INFO] | | | +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] | | | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] | | | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] | | | +- com.google.errorprone:error_prone_annotations:jar:2.11.0:compile
[INFO] | | | \- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] | | +- org.seleniumhq.selenium:selenium-chromium-driver:jar:4.8.1:compile
[INFO] | | \- org.seleniumhq.selenium:selenium-json:jar:4.8.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-devtools-v108:jar:4.8.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-devtools-v109:jar:4.8.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-devtools-v110:jar:4.8.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-devtools-v85:jar:4.8.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-edge-driver:jar:4.8.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-firefox-driver:jar:4.8.1:compile
[INFO] | | \- org.seleniumhq.selenium:selenium-http:jar:4.8.1:compile
[INFO] | | \- dev.failsafe:failsafe:jar:3.3.0:compile
[INFO] | +- org.seleniumhq.selenium:selenium-ie-driver:jar:4.8.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-remote-driver:jar:4.8.1:compile
[INFO] | | +- com.beust:jcommander:jar:1.82:compile
[INFO] | | +- io.netty:netty-buffer:jar:4.1.87.Final:compile
[INFO] | | +- io.netty:netty-codec-http:jar:4.1.87.Final:compile
[INFO] | | | +- io.netty:netty-codec:jar:4.1.87.Final:compile
[INFO] | | | \- io.netty:netty-handler:jar:4.1.87.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.87.Final:compile
[INFO] | | +- io.netty:netty-transport-classes-epoll:jar:4.1.87.Final:compile
[INFO] | | +- io.netty:netty-transport-classes-kqueue:jar:4.1.87.Final:compile
[INFO] | | +- io.netty:netty-transport-native-epoll:jar:4.1.87.Final:linux-x86_64
[INFO] | | +- io.netty:netty-transport-native-kqueue:jar:4.1.87.Final:osx-x86_64
[INFO] | | +- io.netty:netty-transport-native-unix-common:jar:4.1.87.Final:compile
[INFO] | | +- io.netty:netty-transport:jar:4.1.87.Final:compile
[INFO] | | | \- io.netty:netty-resolver:jar:4.1.87.Final:compile
[INFO] | | +- io.opentelemetry:opentelemetry-api:jar:1.22.0:compile
[INFO] | | +- io.opentelemetry:opentelemetry-context:jar:1.22.0:compile
[INFO] | | +- io.opentelemetry:opentelemetry-exporter-logging:jar:1.22.0:compile
[INFO] | | | +- io.opentelemetry:opentelemetry-sdk-metrics:jar:1.22.0:compile
[INFO] | | | \- io.opentelemetry:opentelemetry-sdk-logs:jar:1.22.0-alpha:compile
[INFO] | | | \- io.opentelemetry:opentelemetry-api-logs:jar:1.22.0-alpha:compile
[INFO] | | +- io.opentelemetry:opentelemetry-sdk-common:jar:1.22.0:compile
[INFO] | | +- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:jar:1.22.0:compile
[INFO] | | +- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:jar:1.22.0-alpha:compile
[INFO] | | +- io.opentelemetry:opentelemetry-sdk-trace:jar:1.22.0:compile
[INFO] | | +- io.opentelemetry:opentelemetry-sdk:jar:1.22.0:compile
[INFO] | | +- io.opentelemetry:opentelemetry-semconv:jar:1.22.0-alpha:compile
[INFO] | | +- io.ous:jtoml:jar:2.0.0:compile
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.12.22:compile
[INFO] | | +- org.apache.commons:commons-exec:jar:1.3:compile
[INFO] | | +- org.asynchttpclient:async-http-client:jar:2.12.3:compile
[INFO] | | | +- org.asynchttpclient:async-http-client-netty-utils:jar:2.12.3:compile
[INFO] | | | +- io.netty:netty-codec-socks:jar:4.1.60.Final:compile
[INFO] | | | +- io.netty:netty-handler-proxy:jar:4.1.60.Final:compile
[INFO] | | | +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.60.Final:compile
[INFO] | | | +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.60.Final:compile
[INFO] | | | +- org.reactivestreams:reactive-streams:jar:1.0.3:compile
[INFO] | | | +- com.typesafe.netty:netty-reactive-streams:jar:2.0.4:compile
[INFO] | | | \- com.sun.activation:jakarta.activation:jar:1.2.2:compile
[INFO] | | \- org.seleniumhq.selenium:selenium-manager:jar:4.8.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-safari-driver:jar:4.8.1:compile
[INFO] | \- org.seleniumhq.selenium:selenium-support:jar:4.8.1:compile
[INFO] +- org.jsoup:jsoup:jar:1.15.3:compile
[INFO] +- commons-io:commons-io:jar:2.11.0:compile
[INFO] +- org.example:db:jar:1.0-SNAPSHOT:compile
[INFO] | +- org.postgresql:postgresql:jar:42.6.0:compile
[INFO] | | \- org.checkerframework:checker-qual:jar:3.31.0:compile
[INFO] | +- com.zaxxer:HikariCP:jar:5.0.1:compile
[INFO] | +- com.querydsl:querydsl-sql:jar:5.0.0:compile
[INFO] | | \- com.querydsl:querydsl-core:jar:5.0.0:compile
[INFO] | | \- com.mysema.commons:mysema-commons-lang:jar:0.2.4:compile
[INFO] | \- jakarta.persistence:jakarta.persistence-api:jar:3.1.0:compile
[INFO] +- org.example:Huge:jar:1.0-SNAPSHOT:compile
[INFO] | \- org.apache.hugegraph:hugegraph-client:jar:1.0.0:compile
[INFO] | +- org.apache.hugegraph:hugegraph-common:jar:1.0.0:compile
[INFO] | | +- junit:junit:jar:4.13.1:compile
[INFO] | | | \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] | | +- org.apache.logging.log4j:log4j-api:jar:2.18.0:compile
[INFO] | | +- org.apache.logging.log4j:log4j-core:jar:2.18.0:compile
[INFO] | | +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.18.0:compile
[INFO] | | +- org.glassfish:javax.json:jar:1.0:compile
[INFO] | | +- commons-configuration:commons-configuration:jar:1.10:compile
[INFO] | | | +- commons-lang:commons-lang:jar:2.6:compile
[INFO] | | | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | | +- org.apache.commons:commons-configuration2:jar:2.8.0:compile
[INFO] | | | +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] | | | \- org.apache.commons:commons-text:jar:1.9:compile
[INFO] | | +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] | | +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.13:compile
[INFO] | | +- joda-time:joda-time:jar:2.10.8:compile
[INFO] | | +- org.javassist:javassist:jar:3.28.0-GA:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.0-rc1:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-core:jar:2.14.0-rc1:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.0-rc1:compile
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.14.0-rc1:compile
[INFO] | | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.14.0-rc1:compile
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.14.0-rc1:compile
[INFO] | | +- org.glassfish.jersey.core:jersey-client:jar:3.0.3:compile
[INFO] | | | \- jakarta.inject:jakarta.inject-api:jar:2.0.0:compile
[INFO] | | +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:3.0.3:compile
[INFO] | | | +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:3.0.3:compile
[INFO] | | | \- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] | | | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | | +- org.glassfish.jersey.connectors:jersey-apache-connector:jar:3.0.3:compile
[INFO] | | | \- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] | | | \- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] | | +- org.glassfish.jersey.inject:jersey-hk2:jar:3.0.3:compile
[INFO] | | | \- org.glassfish.hk2:hk2-locator:jar:3.0.1:compile
[INFO] | | | +- org.glassfish.hk2.external:aopalliance-repackaged:jar:3.0.1:compile
[INFO] | | | +- org.glassfish.hk2:hk2-api:jar:3.0.1:compile
[INFO] | | | \- org.glassfish.hk2:hk2-utils:jar:3.0.1:compile
[INFO] | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0-RC2:compile
[INFO] | | \- com.sun.xml.bind:jaxb-impl:jar:3.0.2:runtime
[INFO] | | \- com.sun.xml.bind:jaxb-core:jar:3.0.2:runtime
[INFO] | +- org.lz4:lz4-java:jar:1.4.0:compile
[INFO] | \- org.glassfish.jersey.containers:jersey-container-servlet:jar:3.0.3:compile
[INFO] | +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:3.0.3:compile
[INFO] | +- org.glassfish.jersey.core:jersey-common:jar:3.0.3:compile
[INFO] | | +- jakarta.annotation:jakarta.annotation-api:jar:2.0.0:compile
[INFO] | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.3:compile
[INFO] | +- org.glassfish.jersey.core:jersey-server:jar:3.0.3:compile
[INFO] | | \- jakarta.validation:jakarta.validation-api:jar:3.0.0:compile
[INFO] | \- jakarta.ws.rs:jakarta.ws.rs-api:jar:3.0.0:compile
[INFO] +- org.example:model:jar:1.0-SNAPSHOT:compile
[INFO] +- org.slf4j:slf4j-api:jar:2.0.5:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.4.7:compile
[INFO] \- ch.qos.logback:logback-core:jar:1.4.7:compile
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for url 1.0-SNAPSHOT:
[INFO]
[INFO] Url .............................................. SUCCESS [ 0.615 s]
[INFO] model .............................................. SUCCESS [ 0.023 s]
[INFO] db ................................................. SUCCESS [ 0.065 s]
[INFO] Huge ............................................... SUCCESS [ 0.285 s]
[INFO] service ............................................ SUCCESS [ 0.203 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.403 s
[INFO] Finished at: 2023-12-01T10:44:29+08:00
这是我的依赖关系,查询了jersey-media-json-jackson, 没有重复
使用IDEA连接后可以正常创建propertyKey,但是打成jar执行就会出现上面的错误
环境jdk21
IDEA2023版本
环境都是一样的,不知道为什么
使用IDEA连接后可以正常创建propertyKey,但是打成jar执行就会出现上面的错误 环境jdk21 IDEA2023版本 环境都是一样的,不知道为什么
你是用的什么方式打成jar包的?spring boot还是什么?
使用IDEA连接后可以正常创建propertyKey,但是打成jar执行就会出现上面的错误 环境jdk21 IDEA2023版本 环境都是一样的,不知道为什么
你是用的什么方式打成jar包的?spring boot还是什么?
就是普通的jar
使用IDEA连接后可以正常创建propertyKey,但是打成jar执行就会出现上面的错误 环境jdk21 IDEA2023版本 环境都是一样的,不知道为什么
你是用的什么方式打成jar包的?spring boot还是什么?
就是普通的jar
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<attach>false</attach>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.tpy.ServiceApplication</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<!--<goal>assembly</goal>-->
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
这是jar生成方式
使用IDEA连接后可以正常创建propertyKey,但是打成jar执行就会出现上面的错误 环境jdk21 IDEA2023版本 环境都是一样的,不知道为什么
我猜测可能是你打包的方式导致的,用spring boot的打包方式是没问题的。
但是用其他fat jar的方式就可能有问题了。因为jersey-media-json-jackson中是通过spi的方式注册JacksonFeature的,fat jar的方式可能导致spi失效
这里的关键就在于jersey-media-json-jackson.jar中的META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable文件。
你可以试下把这个文件拷贝到自己主项目中的resources目录下(保持META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable的路径不变),再打包测试。
使用IDEA连接后可以正常创建propertyKey,但是打成jar执行就会出现上面的错误 环境jdk21 IDEA2023版本 环境都是一样的,不知道为什么
你是用的什么方式打成jar包的?spring boot还是什么?
就是普通的jar
<build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <appendAssemblyId>false</appendAssemblyId> <attach>false</attach> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>com.tpy.ServiceApplication</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <!--<goal>assembly</goal>--> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
这是jar生成方式
这种方式打包方式会将所有依赖打包到一个可执行的JAR文件中,导致SPI失效。建议可是换成使用maven-shade-plugin插件进行打包
使用IDEA连接后可以正常创建propertyKey,但是打成jar执行就会出现上面的错误 环境jdk21 IDEA2023版本 环境都是一样的,不知道为什么
我猜测可能是你打包的方式导致的,用spring boot的打包方式是没问题的。 但是用其他fat jar的方式就可能有问题了。因为jersey-media-json-jackson中是通过spi的方式注册JacksonFeature的,fat jar的方式可能导致spi失效
这里的关键就在于jersey-media-json-jackson.jar中的META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable文件。 你可以试下把这个文件拷贝到自己主项目中的resources目录下(保持META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable的路径不变),再打包测试。
按照你的方式可以了,谢谢
使用IDEA连接后可以正常创建propertyKey,但是打成jar执行就会出现上面的错误 环境jdk21 IDEA2023版本 环境都是一样的,不知道为什么
我猜测可能是你打包的方式导致的,用spring boot的打包方式是没问题的。 但是用其他fat jar的方式就可能有问题了。因为jersey-media-json-jackson中是通过spi的方式注册JacksonFeature的,fat jar的方式可能导致spi失效
这里的关键就在于jersey-media-json-jackson.jar中的META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable文件。 你可以试下把这个文件拷贝到自己主项目中的resources目录下(保持META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable的路径不变),再打包测试。按照你的方式可以了,谢谢
好的,那就说明确实是fatjar导致spi失效的问题。
这种打包方式,涉及到spi的场景都会有问题